@ukhomeoffice/cop-react-form-renderer 8.0.6 → 8.0.7-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
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),T=require("@ukhomeoffice/cop-react-components"),N=require("react"),Dt=require("uuid"),W=require("dayjs"),Ye=require("dayjs/plugin/customParseFormat"),pn=require("dayjs/plugin/isToday"),ro=require("dayjs/plugin/isLeapYear"),He={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},oo="alert",io="autocomplete",lo="calculation",ao="checkboxes",co="collection",uo="collection-summary",fo="container",ho="date",mo="details",po="email",Eo="file",Ao="heading",yo="html",So="inset-text",To="list",Co="multifile",go="paragraph",bo="phone-number",wo="radios",_o="select",Po="text",Io="textarea",xo="time",Oo="warning",_={ALERT:oo,AUTOCOMPLETE:io,CALCULATION:lo,CHECKBOXES:ao,COLLECTION:co,COLLECTION_SUMMARY:uo,CONTAINER:fo,DATE:ho,DETAILS:mo,EMAIL:po,FILE:Eo,HEADING:Ao,HTML:yo,INSET_TEXT:So,LIST:To,MULTI_FILE:Co,PARAGRAPH:go,PHONE_NUMBER:bo,RADIOS:wo,SELECT:_o,TEXT:Po,TEXT_AREA:Io,TIME:xo,WARNING:Oo},Ro="blur",No="submit",Do="cancel",Ie={BLUR:Ro,SUBMIT:No,CANCEL:Do},vo="cya",Lo="hub",Fo="partial-cya",re={CYA:vo,HUB:Lo,PARTIAL_CYA:Fo},Uo="cya",jo="form",Mo="form-with-task-list",ko="hub-and-spoke",Bo="task-list",$o="task-list-cya",Yo="wizard",ne={CYA:Uo,FORM:jo,FORM_WITH_TASK:Mo,HUB:ko,TASK:Bo,TASK_CYA:$o,WIZARD:Yo},Ho="CYA",Vo="TASK",Se={CYA:Ho,TASK:Vo},Xt="cancel",Ts="collectionAdd",Cs="collectionDuplicate",gs="collectionRemove",bs="navigate",Jt="saveAndContinue",Qt="saveAndNavigate",Zt="saveAndReturn",en="submit",St={CANCEL:Xt,COLLECTION_ADD:Ts,COLLECTION_DUPLICATE:Cs,COLLECTION_REMOVE:gs,NAVIGATE:bs,SAVE_AND_CONTINUE:Jt,SAVE_AND_NAVIGATE:Qt,SAVE_AND_RETURN:Zt,SUBMIT:en},qo={[Xt]:{type:Xt,validate:!1,label:"Cancel",classModifiers:"secondary"},[Ts]:void 0,[Cs]:void 0,[gs]:void 0,[bs]:void 0,[Jt]:{type:Jt,validate:!0,label:"Save and continue"},[Qt]:{type:Qt,validate:!0,label:"Save and continue"},[Zt]:{type:Zt,validate:!1,label:"Save and return later",classModifiers:"secondary"},[en]:{type:en,validate:!0}},z={TYPES:St,DEFAULTS:qo},ws="complete",_s="inProgress",Ps="notStarted",Is="cannotStartYet",xs="skipped",Go={COMPLETE:ws,IN_PROGRESS:_s,NOT_STARTED:Ps,CANNOT_START_YET:Is,SKIPPED:xs},Ko={[ws]:{label:"Completed",colour:"dark-blue"},[_s]:{label:"In Progress",colour:"white"},[Ps]:{label:"Not Started",colour:"dark-grey"},[Is]:{label:"Cannot Start Yet",colour:"dark-grey"},[xs]:{label:"Skipped",colour:"dark-grey"}},q={TYPES:Go,DETAILS:Ko},Wo={CollectionLabels:He,ComponentTypes:_,EventTypes:Ie,FormPages:re,FormTypes:ne,HubFormats:Se,PageAction:z,TaskStates:q},Os=e=>{try{const t=zo(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},zo=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return ht(e,(n,s)=>n*s);case"divide":return ht(e,(n,s)=>n/s);case"plus":return ht(e,(n,s)=>n+s);case"minus":return ht(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},ht=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return Xo(n.map(s=>Jo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},Xo=(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},Jo=(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 Os({...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)=>T.Utils.interpolateString("${"+e+"}",t),Zo=(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 he.getSource(t,n)}return e.value},mt=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},En=(e,t,n)=>{if(e&&typeof e=="object"){const s=Zo(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=mt(t),o=mt(s);return r!=null&&o!=null&&r<o}case">":{const r=mt(t),o=mt(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},ei=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=he.getDataPath(s.field,n);return{...s,field:r}})}},ti=e=>Array.isArray(e)||!!(e.field&&e.op),Rs=e=>e&&!ti(e)?ei(e):e,Ns=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ns(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=he.getSource(t,i);return En(o,l,t)};return n==="and"?s.every(r):s.some(r)},Me=(e,t)=>{const n=Rs(e);return n?Ns(n,t):!0},ni=(e,t)=>{const n=Rs(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=he.getSource(t,r.field);return En(r,o,t)}):!0},le={meetsOne:ni,meetsAll:Me,met:En},si=(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},pt=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?le.meetsOne(n,e.formData):le.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:T.Utils.interpolateString(n.value,e.formData),label:T.Utils.interpolateString(n.label,e.formData),hint:T.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),ri=(e,t)=>{const n=e.formData[t].map(s=>({value:T.Utils.interpolateString(e.item.value,s),label:T.Utils.interpolateString(e.item.label,s),hint:T.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Ds=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=ri(e,e?.data?.collection);return t(pt(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=si(e.options,e.data.options);return t(pt(e,n))}if(e.options)return t(pt(e,e.options));if(e.data&&e.data.options)return t(pt(e,e.data.options))}return t([])},oi=6e3,ii=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},kn=e=>e===0,vs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),li=(e,t)=>{let n=0;return e.synonyms.some(r=>vs(r,t))&&(n=4),n},ai=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return vs(i,n)})&&(s=5),s},ci=(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=ii(i,r)),kn(o)&&e.synonyms&&(o=li(e,t)),kn(o)&&s.item?.extraFieldsToSearch&&(o=ai(s,e,t)),{score:o,label:r,option:e}},ui=(e,t,n)=>(s,r)=>{const o=ci(r,e,t,n);return o.score>0&&s.push(o),s},di=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),fi=e=>{let t=[];Ds(e,s=>{t=s});const n=e?.item?T.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(ui(o,n,e),[]).sort(di).slice(0,oi).map(l=>l.option);r(i)}},ve=".",An="/",Ls=`${ve}${ve}`,Bn=`${ve}${An}`,tn=e=>e.join(ve),nn=(e,t=ve)=>e.split(t),hi=e=>e===Ls,mi=e=>[ve,Ls].indexOf(e)>-1,pi=e=>e&&e.indexOf(ve)===0,Ei=e=>e.indexOf(Bn)===0?e:`${Bn}${e}`,Ai=(e,t)=>{const n=Ei(t),s=nn(n,An).filter(hi).length+1,r=e?nn(e):[];return s>=r.length?"":tn(r.slice(0,-s))},yi=(e,t)=>{const n=nn(t,An).filter(s=>!mi(s));return e?`${e}.${tn(n)}`:tn(n)},Si=(e,t)=>pi(e)?yi(Ai(t,e),e):e,Ti=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},Ci=e=>e.includes("["),gi=e=>e.replace("]","").split("["),se=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&Ci(s)){const[r,o]=gi(s);return Ti(n[r],o)}return n?n[s]:void 0},e)},bi=(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}},wi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...bi(n,t)}):[],_i=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},Fs=(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},Us=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=se(n,e.source.field))},Pi=(e,t)=>{e.forEach(n=>Us(n,t))},Ii=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Us(s,t))})},xi=(e,t,n)=>{const s={...n};return Pi(t,s),Ii(e,s),s},Oi=(e,t)=>({...e,components:js(e.components,t)}),Ri=(e,t)=>({...e,item:js(e.item,t)}),js=(e,t)=>e.map(n=>Ms(n,t)),Ms=(e,t)=>{if(e){if(e.type===_.CONTAINER)return Oi(e,t);if(e.type===_.COLLECTION)return Ri(e,t);if(e.type===_.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:T.Utils.interpolateString(e.data.url,t)}}}return e},he={applyFormula:Os,getAutocompleteSource:fi,getDataPath:Si,getOptions:Ds,getSource:se,refData:{setupUrl:Ms,toOptions:wi},deleteValues:_i,setDataItem:Fs,setupForm:xi},ot=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,xe=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t),it=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),xe(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||he.getSource(t,s.full_path);Array.isArray(r.nested)&&ot(o,r)&&xe(r,t)&&(n=n.concat(r.nested))})}),n},$n=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],ee=(e,t)=>{const n=Array.isArray(t)?[...$n,...t]:$n;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ni}=Object.prototype,{getPrototypeOf:ke}=Object,{iterator:lt,toStringTag:Bs}=Symbol,_t=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),st=(e,t)=>{let n=e;const s=[];for(;n!=null&&n!==Object.prototype;){if(s.indexOf(n)!==-1)return!1;if(s.push(n),_t(n,t))return!0;n=ke(n)}return!1},Di=(e,t)=>e!=null&&st(e,t)?e[t]:void 0,yn=(e=>t=>{const n=Ni.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),we=e=>(e=e.toLowerCase(),t=>yn(t)===e),vt=e=>t=>typeof t===e,{isArray:Le}=Array,Be=vt("undefined");function Ve(e){return e!==null&&!Be(e)&&e.constructor!==null&&!Be(e.constructor)&&ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const $s=we("ArrayBuffer");function vi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$s(e.buffer),t}const Li=vt("string"),ye=vt("function"),Ys=vt("number"),qe=e=>e!==null&&typeof e=="object",Fi=e=>e===!0||e===!1,Tt=e=>{if(!qe(e))return!1;const t=ke(e);return(t===null||t===Object.prototype||ke(t)===null)&&!st(e,Bs)&&!st(e,lt)},Ui=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ji=we("Date"),Mi=we("File"),ki=e=>!!(e&&typeof e.uri<"u"),Bi=e=>e&&typeof e.getParts<"u",$i=we("Blob"),Yi=we("FileList"),Hi=e=>qe(e)&&ye(e.pipe);function Vi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Yn=Vi(),Hn=typeof Yn.FormData<"u"?Yn.FormData:void 0,qi=e=>{if(!e)return!1;if(Hn&&e instanceof Hn)return!0;const t=ke(e);if(!t||t===Object.prototype||!ye(e.append))return!1;const n=yn(e);return n==="formdata"||n==="object"&&ye(e.toString)&&e.toString()==="[object FormData]"},Gi=we("URLSearchParams"),[Ki,Wi,zi,Xi]=["ReadableStream","Request","Response","Headers"].map(we),Ji=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function at(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(Ve(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 Hs(e,t){if(Ve(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 Ne=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Vs=e=>!Be(e)&&e!==Ne;function sn(...e){const{caseless:t,skipUndefined:n}=Vs(this)&&this||{},s={},r=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const l=t&&typeof i=="string"&&Hs(s,i)||i,a=_t(s,l)?s[l]:void 0;Tt(a)&&Tt(o)?s[l]=sn(a,o):Tt(o)?s[l]=sn({},o):Le(o)?s[l]=o.slice():(!n||!Be(o))&&(s[l]=o)};for(let o=0,i=e.length;o<i;o++){const l=e[o];if(!l||Ve(l)||(at(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];cl.call(l,u)&&r(l[u],u)}}return s}const Qi=(e,t,n,{allOwnKeys:s}={})=>(at(t,(r,o)=>{n&&ye(r)?Object.defineProperty(e,o,{__proto__:null,value:ks(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),Zi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),el=(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)},tl=(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&&ke(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},nl=(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},sl=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Ys(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},rl=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ke(Uint8Array)),ol=(e,t)=>{const s=(e&&e[lt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},il=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},ll=we("HTMLFormElement"),al=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),{propertyIsEnumerable:cl}=Object.prototype,ul=we("RegExp"),qs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};at(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},dl=e=>{qs(e,(t,n)=>{if(ye(e)&&["arguments","caller","callee"].includes(n))return!1;const s=e[n];if(ye(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+"'")})}})},fl=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},hl=()=>{},ml=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pl(e){return!!(e&&ye(e.append)&&e[Bs]==="FormData"&&e[lt])}const El=e=>{const t=new WeakSet,n=s=>{if(qe(s)){if(t.has(s))return;if(Ve(s))return s;if(!("toJSON"in s)){t.add(s);const r=Le(s)?[]:{};return at(s,(o,i)=>{const l=n(o);!Be(l)&&(r[i]=l)}),t.delete(s),r}}return s};return n(e)},Al=we("AsyncFunction"),yl=e=>e&&(qe(e)||ye(e))&&ye(e.then)&&ye(e.catch),Gs=((e,t)=>e?setImmediate:t?((n,s)=>(Ne.addEventListener("message",({source:r,data:o})=>{r===Ne&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),Ne.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ye(Ne.postMessage)),Sl=typeof queueMicrotask<"u"?queueMicrotask.bind(Ne):typeof process<"u"&&process.nextTick||Gs,Ks=e=>e!=null&&ye(e[lt]),Tl=e=>e!=null&&st(e,lt)&&Ks(e),m={isArray:Le,isArrayBuffer:$s,isBuffer:Ve,isFormData:qi,isArrayBufferView:vi,isString:Li,isNumber:Ys,isBoolean:Fi,isObject:qe,isPlainObject:Tt,isEmptyObject:Ui,isReadableStream:Ki,isRequest:Wi,isResponse:zi,isHeaders:Xi,isUndefined:Be,isDate:ji,isFile:Mi,isReactNativeBlob:ki,isReactNative:Bi,isBlob:$i,isRegExp:ul,isFunction:ye,isStream:Hi,isURLSearchParams:Gi,isTypedArray:rl,isFileList:Yi,forEach:at,merge:sn,extend:Qi,trim:Ji,stripBOM:Zi,inherits:el,toFlatObject:tl,kindOf:yn,kindOfTest:we,endsWith:nl,toArray:sl,forEachEntry:ol,matchAll:il,isHTMLForm:ll,hasOwnProperty:_t,hasOwnProp:_t,hasOwnInPrototypeChain:st,getSafeProp:Di,reduceDescriptors:qs,freezeMethods:dl,toObjectSet:fl,toCamelCase:al,noop:hl,toFiniteNumber:ml,findKey:Hs,global:Ne,isContextDefined:Vs,isSpecCompliantForm:pl,toJSONObject:El,isAsyncFn:Al,isThenable:yl,setImmediate:Gs,asap:Sl,isIterable:Ks,isSafeIterable:Tl},Cl=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"]),gl=e=>{const t={};let n,s,r;return e&&e.split(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),T=require("@ukhomeoffice/cop-react-components"),N=require("react"),Dt=require("uuid"),W=require("dayjs"),Ye=require("dayjs/plugin/customParseFormat"),pn=require("dayjs/plugin/isToday"),ro=require("dayjs/plugin/isLeapYear"),He={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},oo="alert",io="autocomplete",lo="calculation",ao="checkboxes",co="collection",uo="collection-summary",fo="container",ho="date",mo="details",po="email",Eo="file",Ao="heading",yo="html",So="inset-text",To="list",Co="multifile",go="paragraph",bo="phone-number",wo="radios",_o="select",Po="text",Io="textarea",xo="time",Oo="warning",P={ALERT:oo,AUTOCOMPLETE:io,CALCULATION:lo,CHECKBOXES:ao,COLLECTION:co,COLLECTION_SUMMARY:uo,CONTAINER:fo,DATE:ho,DETAILS:mo,EMAIL:po,FILE:Eo,HEADING:Ao,HTML:yo,INSET_TEXT:So,LIST:To,MULTI_FILE:Co,PARAGRAPH:go,PHONE_NUMBER:bo,RADIOS:wo,SELECT:_o,TEXT:Po,TEXT_AREA:Io,TIME:xo,WARNING:Oo},Ro="blur",No="submit",Do="cancel",Ie={BLUR:Ro,SUBMIT:No,CANCEL:Do},vo="cya",Lo="hub",Fo="partial-cya",re={CYA:vo,HUB:Lo,PARTIAL_CYA:Fo},Uo="cya",jo="form",Mo="form-with-task-list",ko="hub-and-spoke",Bo="task-list",$o="task-list-cya",Yo="wizard",ne={CYA:Uo,FORM:jo,FORM_WITH_TASK:Mo,HUB:ko,TASK:Bo,TASK_CYA:$o,WIZARD:Yo},Ho="CYA",Vo="TASK",Se={CYA:Ho,TASK:Vo},Xt="cancel",Ts="collectionAdd",Cs="collectionDuplicate",gs="collectionRemove",bs="navigate",Jt="saveAndContinue",Qt="saveAndNavigate",Zt="saveAndReturn",en="submit",St={CANCEL:Xt,COLLECTION_ADD:Ts,COLLECTION_DUPLICATE:Cs,COLLECTION_REMOVE:gs,NAVIGATE:bs,SAVE_AND_CONTINUE:Jt,SAVE_AND_NAVIGATE:Qt,SAVE_AND_RETURN:Zt,SUBMIT:en},qo={[Xt]:{type:Xt,validate:!1,label:"Cancel",classModifiers:"secondary"},[Ts]:void 0,[Cs]:void 0,[gs]:void 0,[bs]:void 0,[Jt]:{type:Jt,validate:!0,label:"Save and continue"},[Qt]:{type:Qt,validate:!0,label:"Save and continue"},[Zt]:{type:Zt,validate:!1,label:"Save and return later",classModifiers:"secondary"},[en]:{type:en,validate:!0}},z={TYPES:St,DEFAULTS:qo},ws="complete",_s="inProgress",Ps="notStarted",Is="cannotStartYet",xs="skipped",Go={COMPLETE:ws,IN_PROGRESS:_s,NOT_STARTED:Ps,CANNOT_START_YET:Is,SKIPPED:xs},Ko={[ws]:{label:"Completed",colour:"dark-blue"},[_s]:{label:"In Progress",colour:"white"},[Ps]:{label:"Not Started",colour:"dark-grey"},[Is]:{label:"Cannot Start Yet",colour:"dark-grey"},[xs]:{label:"Skipped",colour:"dark-grey"}},q={TYPES:Go,DETAILS:Ko},Wo={CollectionLabels:He,ComponentTypes:P,EventTypes:Ie,FormPages:re,FormTypes:ne,HubFormats:Se,PageAction:z,TaskStates:q},Os=e=>{try{const t=zo(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},zo=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return ht(e,(n,s)=>n*s);case"divide":return ht(e,(n,s)=>n/s);case"plus":return ht(e,(n,s)=>n+s);case"minus":return ht(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},ht=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return Xo(n.map(s=>Jo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},Xo=(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},Jo=(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 Os({...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)=>T.Utils.interpolateString("${"+e+"}",t),Zo=(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 he.getSource(t,n)}return e.value},mt=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},En=(e,t,n)=>{if(e&&typeof e=="object"){const s=Zo(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=mt(t),o=mt(s);return r!=null&&o!=null&&r<o}case">":{const r=mt(t),o=mt(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},ei=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=he.getDataPath(s.field,n);return{...s,field:r}})}},ti=e=>Array.isArray(e)||!!(e.field&&e.op),Rs=e=>e&&!ti(e)?ei(e):e,Ns=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ns(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=he.getSource(t,i);return En(o,l,t)};return n==="and"?s.every(r):s.some(r)},Me=(e,t)=>{const n=Rs(e);return n?Ns(n,t):!0},ni=(e,t)=>{const n=Rs(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=he.getSource(t,r.field);return En(r,o,t)}):!0},le={meetsOne:ni,meetsAll:Me,met:En},si=(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},pt=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?le.meetsOne(n,e.formData):le.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:T.Utils.interpolateString(n.value,e.formData),label:T.Utils.interpolateString(n.label,e.formData),hint:T.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),ri=(e,t)=>{const n=e.formData[t].map(s=>({value:T.Utils.interpolateString(e.item.value,s),label:T.Utils.interpolateString(e.item.label,s),hint:T.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Ds=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=ri(e,e?.data?.collection);return t(pt(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=si(e.options,e.data.options);return t(pt(e,n))}if(e.options)return t(pt(e,e.options));if(e.data&&e.data.options)return t(pt(e,e.data.options))}return t([])},oi=6e3,ii=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},kn=e=>e===0,vs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),li=(e,t)=>{let n=0;return e.synonyms.some(r=>vs(r,t))&&(n=4),n},ai=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return vs(i,n)})&&(s=5),s},ci=(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=ii(i,r)),kn(o)&&e.synonyms&&(o=li(e,t)),kn(o)&&s.item?.extraFieldsToSearch&&(o=ai(s,e,t)),{score:o,label:r,option:e}},ui=(e,t,n)=>(s,r)=>{const o=ci(r,e,t,n);return o.score>0&&s.push(o),s},di=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),fi=e=>{let t=[];Ds(e,s=>{t=s});const n=e?.item?T.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(ui(o,n,e),[]).sort(di).slice(0,oi).map(l=>l.option);r(i)}},ve=".",An="/",Ls=`${ve}${ve}`,Bn=`${ve}${An}`,tn=e=>e.join(ve),nn=(e,t=ve)=>e.split(t),hi=e=>e===Ls,mi=e=>[ve,Ls].indexOf(e)>-1,pi=e=>e&&e.indexOf(ve)===0,Ei=e=>e.indexOf(Bn)===0?e:`${Bn}${e}`,Ai=(e,t)=>{const n=Ei(t),s=nn(n,An).filter(hi).length+1,r=e?nn(e):[];return s>=r.length?"":tn(r.slice(0,-s))},yi=(e,t)=>{const n=nn(t,An).filter(s=>!mi(s));return e?`${e}.${tn(n)}`:tn(n)},Si=(e,t)=>pi(e)?yi(Ai(t,e),e):e,Ti=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},Ci=e=>e.includes("["),gi=e=>e.replace("]","").split("["),se=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&Ci(s)){const[r,o]=gi(s);return Ti(n[r],o)}return n?n[s]:void 0},e)},bi=(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}},wi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...bi(n,t)}):[],_i=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},Fs=(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},Us=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=se(n,e.source.field))},Pi=(e,t)=>{e.forEach(n=>Us(n,t))},Ii=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Us(s,t))})},xi=(e,t,n)=>{const s={...n};return Pi(t,s),Ii(e,s),s},Oi=(e,t)=>({...e,components:js(e.components,t)}),Ri=(e,t)=>({...e,item:js(e.item,t)}),js=(e,t)=>e.map(n=>Ms(n,t)),Ms=(e,t)=>{if(e){if(e.type===P.CONTAINER)return Oi(e,t);if(e.type===P.COLLECTION)return Ri(e,t);if(e.type===P.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:T.Utils.interpolateString(e.data.url,t)}}}return e},he={applyFormula:Os,getAutocompleteSource:fi,getDataPath:Si,getOptions:Ds,getSource:se,refData:{setupUrl:Ms,toOptions:wi},deleteValues:_i,setDataItem:Fs,setupForm:xi},ot=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,xe=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t),it=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),xe(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||he.getSource(t,s.full_path);Array.isArray(r.nested)&&ot(o,r)&&xe(r,t)&&(n=n.concat(r.nested))})}),n},$n=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],ee=(e,t)=>{const n=Array.isArray(t)?[...$n,...t]:$n;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ni}=Object.prototype,{getPrototypeOf:ke}=Object,{iterator:lt,toStringTag:Bs}=Symbol,_t=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),st=(e,t)=>{let n=e;const s=[];for(;n!=null&&n!==Object.prototype;){if(s.indexOf(n)!==-1)return!1;if(s.push(n),_t(n,t))return!0;n=ke(n)}return!1},Di=(e,t)=>e!=null&&st(e,t)?e[t]:void 0,yn=(e=>t=>{const n=Ni.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),we=e=>(e=e.toLowerCase(),t=>yn(t)===e),vt=e=>t=>typeof t===e,{isArray:Le}=Array,Be=vt("undefined");function Ve(e){return e!==null&&!Be(e)&&e.constructor!==null&&!Be(e.constructor)&&ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const $s=we("ArrayBuffer");function vi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$s(e.buffer),t}const Li=vt("string"),ye=vt("function"),Ys=vt("number"),qe=e=>e!==null&&typeof e=="object",Fi=e=>e===!0||e===!1,Tt=e=>{if(!qe(e))return!1;const t=ke(e);return(t===null||t===Object.prototype||ke(t)===null)&&!st(e,Bs)&&!st(e,lt)},Ui=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ji=we("Date"),Mi=we("File"),ki=e=>!!(e&&typeof e.uri<"u"),Bi=e=>e&&typeof e.getParts<"u",$i=we("Blob"),Yi=we("FileList"),Hi=e=>qe(e)&&ye(e.pipe);function Vi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Yn=Vi(),Hn=typeof Yn.FormData<"u"?Yn.FormData:void 0,qi=e=>{if(!e)return!1;if(Hn&&e instanceof Hn)return!0;const t=ke(e);if(!t||t===Object.prototype||!ye(e.append))return!1;const n=yn(e);return n==="formdata"||n==="object"&&ye(e.toString)&&e.toString()==="[object FormData]"},Gi=we("URLSearchParams"),[Ki,Wi,zi,Xi]=["ReadableStream","Request","Response","Headers"].map(we),Ji=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function at(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(Ve(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 Hs(e,t){if(Ve(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 Ne=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Vs=e=>!Be(e)&&e!==Ne;function sn(...e){const{caseless:t,skipUndefined:n}=Vs(this)&&this||{},s={},r=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const l=t&&typeof i=="string"&&Hs(s,i)||i,a=_t(s,l)?s[l]:void 0;Tt(a)&&Tt(o)?s[l]=sn(a,o):Tt(o)?s[l]=sn({},o):Le(o)?s[l]=o.slice():(!n||!Be(o))&&(s[l]=o)};for(let o=0,i=e.length;o<i;o++){const l=e[o];if(!l||Ve(l)||(at(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];cl.call(l,u)&&r(l[u],u)}}return s}const Qi=(e,t,n,{allOwnKeys:s}={})=>(at(t,(r,o)=>{n&&ye(r)?Object.defineProperty(e,o,{__proto__:null,value:ks(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),Zi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),el=(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)},tl=(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&&ke(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},nl=(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},sl=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Ys(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},rl=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ke(Uint8Array)),ol=(e,t)=>{const s=(e&&e[lt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},il=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},ll=we("HTMLFormElement"),al=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),{propertyIsEnumerable:cl}=Object.prototype,ul=we("RegExp"),qs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};at(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},dl=e=>{qs(e,(t,n)=>{if(ye(e)&&["arguments","caller","callee"].includes(n))return!1;const s=e[n];if(ye(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+"'")})}})},fl=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},hl=()=>{},ml=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pl(e){return!!(e&&ye(e.append)&&e[Bs]==="FormData"&&e[lt])}const El=e=>{const t=new WeakSet,n=s=>{if(qe(s)){if(t.has(s))return;if(Ve(s))return s;if(!("toJSON"in s)){t.add(s);const r=Le(s)?[]:{};return at(s,(o,i)=>{const l=n(o);!Be(l)&&(r[i]=l)}),t.delete(s),r}}return s};return n(e)},Al=we("AsyncFunction"),yl=e=>e&&(qe(e)||ye(e))&&ye(e.then)&&ye(e.catch),Gs=((e,t)=>e?setImmediate:t?((n,s)=>(Ne.addEventListener("message",({source:r,data:o})=>{r===Ne&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),Ne.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ye(Ne.postMessage)),Sl=typeof queueMicrotask<"u"?queueMicrotask.bind(Ne):typeof process<"u"&&process.nextTick||Gs,Ks=e=>e!=null&&ye(e[lt]),Tl=e=>e!=null&&st(e,lt)&&Ks(e),m={isArray:Le,isArrayBuffer:$s,isBuffer:Ve,isFormData:qi,isArrayBufferView:vi,isString:Li,isNumber:Ys,isBoolean:Fi,isObject:qe,isPlainObject:Tt,isEmptyObject:Ui,isReadableStream:Ki,isRequest:Wi,isResponse:zi,isHeaders:Xi,isUndefined:Be,isDate:ji,isFile:Mi,isReactNativeBlob:ki,isReactNative:Bi,isBlob:$i,isRegExp:ul,isFunction:ye,isStream:Hi,isURLSearchParams:Gi,isTypedArray:rl,isFileList:Yi,forEach:at,merge:sn,extend:Qi,trim:Ji,stripBOM:Zi,inherits:el,toFlatObject:tl,kindOf:yn,kindOfTest:we,endsWith:nl,toArray:sl,forEachEntry:ol,matchAll:il,isHTMLForm:ll,hasOwnProperty:_t,hasOwnProp:_t,hasOwnInPrototypeChain:st,getSafeProp:Di,reduceDescriptors:qs,freezeMethods:dl,toObjectSet:fl,toCamelCase:al,noop:hl,toFiniteNumber:ml,findKey:Hs,global:Ne,isContextDefined:Vs,isSpecCompliantForm:pl,toJSONObject:El,isAsyncFn:Al,isThenable:yl,setImmediate:Gs,asap:Sl,isIterable:Ks,isSafeIterable:Tl},Cl=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"]),gl=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]&&Cl[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t};function bl(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 wl=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),_l=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Sn(e,t){return m.isArray(e)?e.map(n=>Sn(n,t)):bl(String(e).replace(t,""))}const Pl=e=>Sn(e,wl),Il=e=>Sn(e,_l);function Ws(e){const t=Object.create(null);return m.forEach(e.toJSON(),(n,s)=>{t[s]=Il(n)}),t}const Vn=Symbol("internals");function et(e){return e&&String(e).trim().toLowerCase()}function Ct(e){return e===!1||e==null?e:m.isArray(e)?e.map(Ct):Pl(String(e))}function xl(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 Ol=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Yt(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 Rl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function Nl(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 fe=class{constructor(t){t&&this.set(t)}set(t,n,s){const r=this;function o(l,a,c){const u=et(a);if(!u)return;const f=m.findKey(r,u);(!f||r[f]===void 0||c===!0||c===void 0&&r[f]!==!1)&&(r[f||a]=Ct(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())&&!Ol(t))i(gl(t),n);else if(m.isObject(t)&&m.isSafeIterable(t)){let l=Object.create(null),a,c;for(const u of t){if(!m.isArray(u))throw new TypeError("Object iterator must return a key-value pair");c=u[0],m.hasOwnProp(l,c)?(a=l[c],l[c]=m.isArray(a)?[...a,u[1]]:[a,u[1]]):l[c]=u[1]}i(l,n)}else t!=null&&o(n,t,s);return this}get(t,n){if(t=et(t),t){const s=m.findKey(this,t);if(s){const r=this[s];if(!n)return r;if(n===!0)return xl(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=et(t),t){const s=m.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Yt(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let r=!1;function o(i){if(i=et(i),i){const l=m.findKey(s,i);l&&(!n||Yt(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||Yt(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]=Ct(r),delete n[o];return}const l=t?Rl(o):String(o).trim();l!==o&&delete n[o],n[l]=Ct(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[Vn]=this[Vn]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=et(i);s[l]||(Nl(r,i),s[l]=!0)}return m.isArray(t)?t.forEach(o):o(t),this}};fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(fe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});m.freezeMethods(fe);const Dl="[REDACTED ****]";function vl(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 Ll(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 fe&&(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)&&vl(o))return s.pop(),o;i=Object.create(null);for(const[l,a]of Object.entries(o)){const c=n.has(l.toLowerCase())?Dl:r(a);m.isUndefined(c)||(i[l]=c)}}return s.pop(),i};return r(e)}let D=class zs extends Error{static from(t,n,s,r,o,i){const l=new zs(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?Ll(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 Fl=null,Xs=100;function rn(e){return m.isPlainObject(e)||m.isArray(e)}function Js(e){return m.endsWith(e,"[]")?e.slice(0,-2):e}function Ht(e,t,n){return e?e.concat(t).map(function(r,o){return r=Js(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function Ul(e){return m.isArray(e)&&!e.some(rn)}const jl=m.toFlatObject(m,{},null,function(t){return/^is[A-Z]/.test(t)});function Lt(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(I,y){return!m.isUndefined(y[I])});const s=n.metaTokens,r=n.visitor||S,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,a=n.maxDepth===void 0?Xs:n.maxDepth,c=l&&m.isSpecCompliantForm(t),u=[];if(!m.isFunction(r))throw new TypeError("visitor must be a function");function f(E){if(E===null)return"";if(m.isDate(E))return E.toISOString();if(m.isBoolean(E))return E.toString();if(!c&&m.isBlob(E))throw new D("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(E)||m.isTypedArray(E)?c&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function h(E){if(E>a)throw new D("Object is too deeply nested ("+E+" levels). Max depth: "+a,D.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(E,I){if(a===1/0)return JSON.stringify(E);const y=[];return JSON.stringify(E,function(P,F){if(!m.isObject(F))return F;for(;y.length&&y[y.length-1]!==this;)y.pop();return y.push(F),h(I+y.length-1),F})}function S(E,I,y){let b=E;if(m.isReactNative(t)&&m.isReactNativeBlob(E))return t.append(Ht(y,I,o),f(E)),!1;if(E&&!y&&typeof E=="object"){if(m.endsWith(I,"{}"))I=s?I:I.slice(0,-2),E=p(E,1);else if(m.isArray(E)&&Ul(E)||(m.isFileList(E)||m.endsWith(I,"[]"))&&(b=m.toArray(E)))return I=Js(I),b.forEach(function(F,g){!(m.isUndefined(F)||F===null)&&t.append(i===!0?Ht([I],g,o):i===null?I:I+"[]",f(F))}),!1}return rn(E)?!0:(t.append(Ht(y,I,o),f(E)),!1)}const A=Object.assign(jl,{defaultVisitor:S,convertValue:f,isVisitable:rn});function C(E,I,y=0){if(!m.isUndefined(E)){if(h(y),u.indexOf(E)!==-1)throw new Error("Circular reference detected in "+I.join("."));u.push(E),m.forEach(E,function(P,F){(!(m.isUndefined(P)||P===null)&&r.call(t,P,m.isString(F)?F.trim():F,I,A))===!0&&C(P,I?I.concat(F):[F],y+1)}),u.pop()}}if(!m.isObject(e))throw new TypeError("data must be an object");return C(e),t}function qn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(s){return t[s]})}function Tn(e,t){this._pairs=[],e&&Lt(e,this,t)}const Qs=Tn.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,qn)}:qn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Ml(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Zs(e,t,n){if(!t)return e;const s=m.isFunction(n)?{serialize:n}:n,r=m.getSafeProp(s,"encode")||Ml,o=m.getSafeProp(s,"serialize");let i;if(o?i=o(t,s):i=m.isURLSearchParams(t)?t.toString():new Tn(t,s).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Gn{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 Cn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},kl=typeof URLSearchParams<"u"?URLSearchParams:Tn,Bl=typeof FormData<"u"?FormData:null,$l=typeof Blob<"u"?Blob:null,Yl={isBrowser:!0,classes:{URLSearchParams:kl,FormData:Bl,Blob:$l},protocols:["http","https","file","blob","url","data"]},gn=typeof window<"u"&&typeof document<"u",on=typeof navigator=="object"&&navigator||void 0,Hl=gn&&(!on||["ReactNative","NativeScript","NS"].indexOf(on.product)<0),Vl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ql=gn&&window.location.href||"http://localhost",Gl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:gn,hasStandardBrowserEnv:Hl,hasStandardBrowserWebWorkerEnv:Vl,navigator:on,origin:ql},Symbol.toStringTag,{value:"Module"})),ie={...Gl,...Yl};function Kl(e,t){return Lt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}const Kn=Xs;function er(e){if(e>Kn)throw new D("FormData field is too deeply nested ("+e+" levels). Max depth: "+Kn,D.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Wl(e){const t=[],n=/\w+|\[(\w*)]/g;let s;for(;(s=n.exec(e))!==null;)er(t.length),t.push(s[0]==="[]"?"":s[1]||s[0]);return t}function zl(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 tr(e){function t(n,s,r,o){er(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]=zl(r[i])),!l)}if(m.isFormData(e)&&m.isFunction(e.entries)){const n={};return m.forEachEntry(e,(s,r)=>{t(Wl(s),r,n,0)}),n}return null}const je=(e,t)=>e!=null&&m.hasOwnProp(e,t)?e[t]:void 0;function Xl(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 ct={transitional:Cn,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(tr(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 Lt(l?{"files[]":t}:t,u&&new u,a)}}return o||r?(n.setContentType("application/json",!1),Xl(t)):t}],transformResponse:[function(t){const n=je(this,"transitional")||ct.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:ie.classes.FormData,Blob:ie.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=>{ct.headers[e]={}});function Vt(e,t){const n=this||ct,s=t||n,r=fe.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 nr(e){return!!(e&&e.__CANCEL__)}let ut=class extends D{constructor(t,n,s){super(t??"canceled",D.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function sr(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 Jl(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Ql(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 f=o,h=0;for(;f!==r;)h+=n[f++],f=f%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const p=u&&c-u;return p?Math.round(h*1e3/p):void 0}}function Zl(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(),f=u-n;f>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-f)))},()=>r&&i(r)]}const Pt=(e,t,n=3)=>{let s=0;const r=Ql(50,250);return Zl(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 f={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(f)},n)},Wn=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},zn=e=>(...t)=>m.asap(()=>e(...t)),ea=ie.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ie.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,ta=ie.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 na(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sa(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}const ra=/^https?:(?!\/\/)/i,oa=/[\t\n\r]/g;function ia(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}function la(e){return ia(e).replace(oa,"")}function Xn(e,t){if(typeof e=="string"&&ra.test(la(e)))throw new D('Invalid URL: missing "//" after protocol',D.ERR_INVALID_URL,t)}function rr(e,t,n,s){Xn(t,s);let r=!na(t);return e&&(r||n===!1)?(Xn(e,s),sa(e,t)):t}const Jn=e=>e instanceof fe?{...e}:e;function Fe(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(u,f,h,p){return m.isPlainObject(u)&&m.isPlainObject(f)?m.merge.call({caseless:p},u,f):m.isPlainObject(f)?m.merge({},f):m.isArray(f)?f.slice():f}function r(u,f,h,p){if(m.isUndefined(f)){if(!m.isUndefined(u))return s(void 0,u,h,p)}else return s(u,f,h,p)}function o(u,f){if(!m.isUndefined(f))return s(void 0,f)}function i(u,f){if(m.isUndefined(f)){if(!m.isUndefined(u))return s(void 0,u)}else return s(void 0,f)}function l(u){const f=m.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!m.isUndefined(f))if(m.isPlainObject(f)){if(m.hasOwnProp(f,u))return f[u]}else return;const h=m.hasOwnProp(e,"transitional")?e.transitional:void 0;if(m.isPlainObject(h)&&m.hasOwnProp(h,u))return h[u]}function a(u,f,h){if(m.hasOwnProp(t,h))return s(u,f);if(m.hasOwnProp(e,h))return s(void 0,u)}const c={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:a,headers:(u,f,h)=>r(Jn(u),Jn(f),h,!0)};return m.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const h=m.hasOwnProp(c,f)?c[f]:r,p=m.hasOwnProp(e,f)?e[f]:void 0,S=m.hasOwnProp(t,f)?t[f]:void 0,A=h(p,S,f);m.isUndefined(A)&&h!==a||(n[f]=A)}),m.hasOwnProp(t,"validateStatus")&&m.isUndefined(t.validateStatus)&&l("validateStatusUndefinedResolves")===!1&&(m.hasOwnProp(e,"validateStatus")?n.validateStatus=s(void 0,e.validateStatus):delete n.validateStatus),n}const aa=["content-type","content-length"];function ca(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([s,r])=>{aa.includes(s.toLowerCase())&&e.set(s,r)})}const ua=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function or(e){const t=Fe({},e),n=h=>m.hasOwnProp(t,h)?t[h]: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"),f=n("url");if(t.headers=l=fe.from(l),t.url=Zs(rr(c,f,u,t),n("params"),n("paramsSerializer")),a){const h=m.getSafeProp(a,"username")||"",p=m.getSafeProp(a,"password")||"";l.set("Authorization","Basic "+btoa(h+":"+(p?ua(p):"")))}if(m.isFormData(s)&&(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv||m.isReactNative(s)?l.setContentType(void 0):m.isFunction(s.getHeaders)&&ca(l,s.getHeaders(),n("formDataHeaderPolicy"))),ie.hasStandardBrowserEnv&&(m.isFunction(r)&&(r=r(t)),r===!0||r==null&&ea(t.url))){const p=o&&i&&ta.read(i);p&&l.set(o,p)}return t}const da=typeof XMLHttpRequest<"u",fa=da&&function(e){return new Promise(function(n,s){const r=or(e);let o=r.data;const i=fe.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,f,h,p,S;function A(){p&&p(),S&&S(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let C=new XMLHttpRequest;C.open(r.method.toUpperCase(),r.url,!0),C.timeout=r.timeout;function E(){if(!C)return;const y=fe.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),P={data:!l||l==="text"||l==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:y,config:e,request:C};sr(function(g){n(g),A()},function(g){s(g),A()},P),C=null}"onloadend"in C?C.onloadend=E:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.startsWith("file:"))||setTimeout(E)},C.onabort=function(){C&&(s(new D("Request aborted",D.ECONNABORTED,e,C)),A(),C=null)},C.onerror=function(b){const P=b&&b.message?b.message:"Network Error",F=new D(P,D.ERR_NETWORK,e,C);F.event=b||null,s(F),A(),C=null},C.ontimeout=function(){let b=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const P=r.transitional||Cn;r.timeoutErrorMessage&&(b=r.timeoutErrorMessage),s(new D(b,P.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,C)),A(),C=null},o===void 0&&i.setContentType(null),"setRequestHeader"in C&&m.forEach(Ws(i),function(b,P){C.setRequestHeader(P,b)}),m.isUndefined(r.withCredentials)||(C.withCredentials=!!r.withCredentials),l&&l!=="json"&&(C.responseType=r.responseType),c&&([h,S]=Pt(c,!0),C.addEventListener("progress",h)),a&&C.upload&&([f,p]=Pt(a),C.upload.addEventListener("progress",f),C.upload.addEventListener("loadend",p)),(r.cancelToken||r.signal)&&(u=y=>{C&&(s(!y||y.type?new ut(null,e,C):y),C.abort(),A(),C=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const I=Jl(r.url);if(I&&!ie.protocols.includes(I)){s(new D("Unsupported protocol "+I+":",D.ERR_BAD_REQUEST,e));return}C.send(o||null)})},ha=(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 ut(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},ma=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},pa=async function*(e,t){for await(const n of Ea(e))yield*ma(n,t)},Ea=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()}},Qn=(e,t,n,s)=>{const r=pa(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 f=u.byteLength;if(n){let h=o+=f;n(h)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})},It=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Aa=(e,t,n)=>t+2<n&&It(e.charCodeAt(t+1))&&It(e.charCodeAt(t+2));function ya(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 p=0;p<l;p++)if(s.charCodeAt(p)===37&&p+2<l){const S=s.charCodeAt(p+1),A=s.charCodeAt(p+2);It(S)&&It(A)&&(i-=2,p+=2)}let a=0,c=l-1;const u=p=>p>=2&&s.charCodeAt(p-2)===37&&s.charCodeAt(p-1)===51&&(s.charCodeAt(p)===68||s.charCodeAt(p)===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 h=Math.floor(i/4)*3-(a||0);return h>0?h:0}let o=0;for(let i=0,l=s.length;i<l;i++){const a=s.charCodeAt(i);if(a===37&&Aa(s,i,l))o+=1,i+=2;else 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 bn="1.18.0",Zn=64*1024,{isFunction:Et}=m,Sa=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),es=e=>{if(!m.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},ts=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ta=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},Ca=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?Et(r):typeof fetch=="function",a=Et(o),c=Et(i);if(!l)return!1;const u=l&&Et(n),f=l&&(typeof s=="function"?(E=>I=>E.encode(I))(new s):async E=>new Uint8Array(await new o(E).arrayBuffer())),h=a&&u&&ts(()=>{let E=!1;const I=new o(ie.origin,{body:new n,method:"POST",get duplex(){return E=!0,"half"}}),y=I.headers.has("Content-Type");return I.body!=null&&I.body.cancel(),E&&!y}),p=c&&u&&ts(()=>m.isReadableStream(new i("").body)),S={stream:p&&(E=>E.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(E=>{!S[E]&&(S[E]=(I,y)=>{let b=I&&I[E];if(b)return b.call(I);throw new D(`Response type '${E}' is not supported`,D.ERR_NOT_SUPPORT,y)})});const A=async E=>{if(E==null)return 0;if(m.isBlob(E))return E.size;if(m.isSpecCompliantForm(E))return(await new o(ie.origin,{method:"POST",body:E}).arrayBuffer()).byteLength;if(m.isArrayBufferView(E)||m.isArrayBuffer(E))return E.byteLength;if(m.isURLSearchParams(E)&&(E=E+""),m.isString(E))return(await f(E)).byteLength},C=async(E,I)=>{const y=m.toFiniteNumber(E.getContentLength());return y??A(I)};return async E=>{let{url:I,method:y,data:b,signal:P,cancelToken:F,timeout:g,onDownloadProgress:v,onUploadProgress:L,responseType:U,headers:x,withCredentials:B="same-origin",fetchOptions:R,maxContentLength:O,maxBodyLength:j}=or(E);const $=m.isNumber(O)&&O>-1,H=m.isNumber(j)&&j>-1,J=Y=>m.hasOwnProp(E,Y)?E[Y]:void 0;let K=r||fetch;U=U?(U+"").toLowerCase():"text";let G=ha([P,F&&F.toAbortSignal()],g),V=null;const me=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let oe,pe=null;const ae=()=>new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,E,V);try{let Y;const Te=J("auth");if(Te){const M=m.getSafeProp(Te,"username")||"",Ee=m.getSafeProp(Te,"password")||"";Y={username:M,password:Ee}}if(Ta(I)){const M=new URL(I,ie.origin);if(!Y&&(M.username||M.password)){const Ee=es(M.username),_e=es(M.password);Y={username:Ee,password:_e}}(M.username||M.password)&&(M.username="",M.password="",I=M.href)}if(Y&&(x.delete("authorization"),x.set("Authorization","Basic "+btoa(Sa((Y.username||"")+":"+(Y.password||""))))),$&&typeof I=="string"&&I.startsWith("data:")&&ya(I)>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V);if(H&&y!=="get"&&y!=="head"){const M=await A(b);if(typeof M=="number"&&isFinite(M)&&(oe=M,M>j))throw ae()}const Re=H&&(m.isReadableStream(b)||m.isStream(b)),Ue=(M,Ee,_e)=>Qn(M,Zn,k=>{if(H&&k>j)throw pe=ae();Ee&&Ee(k)},_e);if(h&&y!=="get"&&y!=="head"&&(L||Re)){if(oe=oe??await C(x,b),oe!==0||Re){let M=new o(I,{method:"POST",body:b,duplex:"half"}),Ee;if(m.isFormData(b)&&(Ee=M.headers.get("content-type"))&&x.setContentType(Ee),M.body){const[_e,k]=L&&Wn(oe,Pt(zn(L)))||[];b=Ue(M.body,_e,k)}}}else if(Re&&!a&&u&&y!=="get"&&y!=="head")b=Ue(b);else if(Re&&a&&!h&&y!=="get"&&y!=="head")throw new D("Stream request bodies are not supported by the current fetch implementation",D.ERR_NOT_SUPPORT,E,V);m.isString(B)||(B=B?"include":"omit");const Xe=a&&"credentials"in o.prototype;if(m.isFormData(b)){const M=x.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&x.delete("content-type")}x.set("User-Agent","axios/"+bn,!1);const Je={...R,signal:G,method:y.toUpperCase(),headers:Ws(x.normalize()),body:b,duplex:"half",credentials:Xe?B:void 0};V=a&&new o(I,Je);let ce=await(a?K(V,R):K(I,Je));const Qe=fe.from(ce.headers);if($){const M=m.toFiniteNumber(Qe.getContentLength());if(M!=null&&M>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V)}const Ze=p&&(U==="stream"||U==="response");if(p&&ce.body&&(v||$||Ze&&me)){const M={};["status","statusText","headers"].forEach(Ae=>{M[Ae]=ce[Ae]});const Ee=m.toFiniteNumber(Qe.getContentLength()),[_e,k]=v&&Wn(Ee,Pt(zn(v),!0))||[];let X=0;const te=Ae=>{if($&&(X=Ae,X>O))throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V);_e&&_e(Ae)};ce=new i(Qn(ce.body,Zn,te,()=>{k&&k(),me&&me()}),M)}U=U||"text";let ge=await S[m.findKey(S,U)||"text"](ce,E);if($&&!p&&!Ze){let M;if(ge!=null&&(typeof ge.byteLength=="number"?M=ge.byteLength:typeof ge.size=="number"?M=ge.size:typeof ge=="string"&&(M=typeof s=="function"?new s().encode(ge).byteLength:ge.length)),typeof M=="number"&&M>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V)}return!Ze&&me&&me(),await new Promise((M,Ee)=>{sr(M,Ee,{data:ge,headers:fe.from(ce.headers),status:ce.status,statusText:ce.statusText,config:E,request:V})})}catch(Y){if(me&&me(),G&&G.aborted&&G.reason instanceof D){const Te=G.reason;throw Te.config=E,V&&(Te.request=V),Y!==Te&&(Te.cause=Y),Te}throw pe?(V&&!pe.request&&(pe.request=V),pe):Y instanceof D?(V&&!Y.request&&(Y.request=V),Y):Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,E,V,Y&&Y.response),{cause:Y.cause||Y}):D.from(Y,Y&&Y.code,E,V,Y&&Y.response)}}},ga=new Map,ir=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=ga;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:Ca(t)),u=c;return c};ir();const wn={http:Fl,xhr:fa,fetch:{get:ir}};m.forEach(wn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const ns=e=>`- ${e}`,ba=e=>m.isFunction(e)||e===null||e===!1;function wa(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,!ba(s)&&(r=wn[(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[Vn]=this[Vn]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=et(i);s[l]||(Nl(r,i),s[l]=!0)}return m.isArray(t)?t.forEach(o):o(t),this}};fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(fe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});m.freezeMethods(fe);const Dl="[REDACTED ****]";function vl(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 Ll(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 fe&&(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)&&vl(o))return s.pop(),o;i=Object.create(null);for(const[l,a]of Object.entries(o)){const c=n.has(l.toLowerCase())?Dl:r(a);m.isUndefined(c)||(i[l]=c)}}return s.pop(),i};return r(e)}let D=class zs extends Error{static from(t,n,s,r,o,i){const l=new zs(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?Ll(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 Fl=null,Xs=100;function rn(e){return m.isPlainObject(e)||m.isArray(e)}function Js(e){return m.endsWith(e,"[]")?e.slice(0,-2):e}function Ht(e,t,n){return e?e.concat(t).map(function(r,o){return r=Js(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function Ul(e){return m.isArray(e)&&!e.some(rn)}const jl=m.toFlatObject(m,{},null,function(t){return/^is[A-Z]/.test(t)});function Lt(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(I,y){return!m.isUndefined(y[I])});const s=n.metaTokens,r=n.visitor||S,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,a=n.maxDepth===void 0?Xs:n.maxDepth,c=l&&m.isSpecCompliantForm(t),u=[];if(!m.isFunction(r))throw new TypeError("visitor must be a function");function f(E){if(E===null)return"";if(m.isDate(E))return E.toISOString();if(m.isBoolean(E))return E.toString();if(!c&&m.isBlob(E))throw new D("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(E)||m.isTypedArray(E)?c&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function h(E){if(E>a)throw new D("Object is too deeply nested ("+E+" levels). Max depth: "+a,D.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(E,I){if(a===1/0)return JSON.stringify(E);const y=[];return JSON.stringify(E,function(_,F){if(!m.isObject(F))return F;for(;y.length&&y[y.length-1]!==this;)y.pop();return y.push(F),h(I+y.length-1),F})}function S(E,I,y){let b=E;if(m.isReactNative(t)&&m.isReactNativeBlob(E))return t.append(Ht(y,I,o),f(E)),!1;if(E&&!y&&typeof E=="object"){if(m.endsWith(I,"{}"))I=s?I:I.slice(0,-2),E=p(E,1);else if(m.isArray(E)&&Ul(E)||(m.isFileList(E)||m.endsWith(I,"[]"))&&(b=m.toArray(E)))return I=Js(I),b.forEach(function(F,g){!(m.isUndefined(F)||F===null)&&t.append(i===!0?Ht([I],g,o):i===null?I:I+"[]",f(F))}),!1}return rn(E)?!0:(t.append(Ht(y,I,o),f(E)),!1)}const A=Object.assign(jl,{defaultVisitor:S,convertValue:f,isVisitable:rn});function C(E,I,y=0){if(!m.isUndefined(E)){if(h(y),u.indexOf(E)!==-1)throw new Error("Circular reference detected in "+I.join("."));u.push(E),m.forEach(E,function(_,F){(!(m.isUndefined(_)||_===null)&&r.call(t,_,m.isString(F)?F.trim():F,I,A))===!0&&C(_,I?I.concat(F):[F],y+1)}),u.pop()}}if(!m.isObject(e))throw new TypeError("data must be an object");return C(e),t}function qn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(s){return t[s]})}function Tn(e,t){this._pairs=[],e&&Lt(e,this,t)}const Qs=Tn.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,qn)}:qn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Ml(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Zs(e,t,n){if(!t)return e;const s=m.isFunction(n)?{serialize:n}:n,r=m.getSafeProp(s,"encode")||Ml,o=m.getSafeProp(s,"serialize");let i;if(o?i=o(t,s):i=m.isURLSearchParams(t)?t.toString():new Tn(t,s).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Gn{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 Cn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},kl=typeof URLSearchParams<"u"?URLSearchParams:Tn,Bl=typeof FormData<"u"?FormData:null,$l=typeof Blob<"u"?Blob:null,Yl={isBrowser:!0,classes:{URLSearchParams:kl,FormData:Bl,Blob:$l},protocols:["http","https","file","blob","url","data"]},gn=typeof window<"u"&&typeof document<"u",on=typeof navigator=="object"&&navigator||void 0,Hl=gn&&(!on||["ReactNative","NativeScript","NS"].indexOf(on.product)<0),Vl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ql=gn&&window.location.href||"http://localhost",Gl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:gn,hasStandardBrowserEnv:Hl,hasStandardBrowserWebWorkerEnv:Vl,navigator:on,origin:ql},Symbol.toStringTag,{value:"Module"})),ie={...Gl,...Yl};function Kl(e,t){return Lt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}const Kn=Xs;function er(e){if(e>Kn)throw new D("FormData field is too deeply nested ("+e+" levels). Max depth: "+Kn,D.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Wl(e){const t=[],n=/\w+|\[(\w*)]/g;let s;for(;(s=n.exec(e))!==null;)er(t.length),t.push(s[0]==="[]"?"":s[1]||s[0]);return t}function zl(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 tr(e){function t(n,s,r,o){er(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]=zl(r[i])),!l)}if(m.isFormData(e)&&m.isFunction(e.entries)){const n={};return m.forEachEntry(e,(s,r)=>{t(Wl(s),r,n,0)}),n}return null}const je=(e,t)=>e!=null&&m.hasOwnProp(e,t)?e[t]:void 0;function Xl(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 ct={transitional:Cn,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(tr(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 Lt(l?{"files[]":t}:t,u&&new u,a)}}return o||r?(n.setContentType("application/json",!1),Xl(t)):t}],transformResponse:[function(t){const n=je(this,"transitional")||ct.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:ie.classes.FormData,Blob:ie.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=>{ct.headers[e]={}});function Vt(e,t){const n=this||ct,s=t||n,r=fe.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 nr(e){return!!(e&&e.__CANCEL__)}let ut=class extends D{constructor(t,n,s){super(t??"canceled",D.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function sr(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 Jl(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Ql(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 f=o,h=0;for(;f!==r;)h+=n[f++],f=f%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const p=u&&c-u;return p?Math.round(h*1e3/p):void 0}}function Zl(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(),f=u-n;f>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-f)))},()=>r&&i(r)]}const Pt=(e,t,n=3)=>{let s=0;const r=Ql(50,250);return Zl(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 f={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(f)},n)},Wn=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},zn=e=>(...t)=>m.asap(()=>e(...t)),ea=ie.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ie.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,ta=ie.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 na(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sa(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}const ra=/^https?:(?!\/\/)/i,oa=/[\t\n\r]/g;function ia(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}function la(e){return ia(e).replace(oa,"")}function Xn(e,t){if(typeof e=="string"&&ra.test(la(e)))throw new D('Invalid URL: missing "//" after protocol',D.ERR_INVALID_URL,t)}function rr(e,t,n,s){Xn(t,s);let r=!na(t);return e&&(r||n===!1)?(Xn(e,s),sa(e,t)):t}const Jn=e=>e instanceof fe?{...e}:e;function Fe(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(u,f,h,p){return m.isPlainObject(u)&&m.isPlainObject(f)?m.merge.call({caseless:p},u,f):m.isPlainObject(f)?m.merge({},f):m.isArray(f)?f.slice():f}function r(u,f,h,p){if(m.isUndefined(f)){if(!m.isUndefined(u))return s(void 0,u,h,p)}else return s(u,f,h,p)}function o(u,f){if(!m.isUndefined(f))return s(void 0,f)}function i(u,f){if(m.isUndefined(f)){if(!m.isUndefined(u))return s(void 0,u)}else return s(void 0,f)}function l(u){const f=m.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!m.isUndefined(f))if(m.isPlainObject(f)){if(m.hasOwnProp(f,u))return f[u]}else return;const h=m.hasOwnProp(e,"transitional")?e.transitional:void 0;if(m.isPlainObject(h)&&m.hasOwnProp(h,u))return h[u]}function a(u,f,h){if(m.hasOwnProp(t,h))return s(u,f);if(m.hasOwnProp(e,h))return s(void 0,u)}const c={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:a,headers:(u,f,h)=>r(Jn(u),Jn(f),h,!0)};return m.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const h=m.hasOwnProp(c,f)?c[f]:r,p=m.hasOwnProp(e,f)?e[f]:void 0,S=m.hasOwnProp(t,f)?t[f]:void 0,A=h(p,S,f);m.isUndefined(A)&&h!==a||(n[f]=A)}),m.hasOwnProp(t,"validateStatus")&&m.isUndefined(t.validateStatus)&&l("validateStatusUndefinedResolves")===!1&&(m.hasOwnProp(e,"validateStatus")?n.validateStatus=s(void 0,e.validateStatus):delete n.validateStatus),n}const aa=["content-type","content-length"];function ca(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([s,r])=>{aa.includes(s.toLowerCase())&&e.set(s,r)})}const ua=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function or(e){const t=Fe({},e),n=h=>m.hasOwnProp(t,h)?t[h]: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"),f=n("url");if(t.headers=l=fe.from(l),t.url=Zs(rr(c,f,u,t),n("params"),n("paramsSerializer")),a){const h=m.getSafeProp(a,"username")||"",p=m.getSafeProp(a,"password")||"";l.set("Authorization","Basic "+btoa(h+":"+(p?ua(p):"")))}if(m.isFormData(s)&&(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv||m.isReactNative(s)?l.setContentType(void 0):m.isFunction(s.getHeaders)&&ca(l,s.getHeaders(),n("formDataHeaderPolicy"))),ie.hasStandardBrowserEnv&&(m.isFunction(r)&&(r=r(t)),r===!0||r==null&&ea(t.url))){const p=o&&i&&ta.read(i);p&&l.set(o,p)}return t}const da=typeof XMLHttpRequest<"u",fa=da&&function(e){return new Promise(function(n,s){const r=or(e);let o=r.data;const i=fe.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,f,h,p,S;function A(){p&&p(),S&&S(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let C=new XMLHttpRequest;C.open(r.method.toUpperCase(),r.url,!0),C.timeout=r.timeout;function E(){if(!C)return;const y=fe.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:y,config:e,request:C};sr(function(g){n(g),A()},function(g){s(g),A()},_),C=null}"onloadend"in C?C.onloadend=E:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.startsWith("file:"))||setTimeout(E)},C.onabort=function(){C&&(s(new D("Request aborted",D.ECONNABORTED,e,C)),A(),C=null)},C.onerror=function(b){const _=b&&b.message?b.message:"Network Error",F=new D(_,D.ERR_NETWORK,e,C);F.event=b||null,s(F),A(),C=null},C.ontimeout=function(){let b=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const _=r.transitional||Cn;r.timeoutErrorMessage&&(b=r.timeoutErrorMessage),s(new D(b,_.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,C)),A(),C=null},o===void 0&&i.setContentType(null),"setRequestHeader"in C&&m.forEach(Ws(i),function(b,_){C.setRequestHeader(_,b)}),m.isUndefined(r.withCredentials)||(C.withCredentials=!!r.withCredentials),l&&l!=="json"&&(C.responseType=r.responseType),c&&([h,S]=Pt(c,!0),C.addEventListener("progress",h)),a&&C.upload&&([f,p]=Pt(a),C.upload.addEventListener("progress",f),C.upload.addEventListener("loadend",p)),(r.cancelToken||r.signal)&&(u=y=>{C&&(s(!y||y.type?new ut(null,e,C):y),C.abort(),A(),C=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const I=Jl(r.url);if(I&&!ie.protocols.includes(I)){s(new D("Unsupported protocol "+I+":",D.ERR_BAD_REQUEST,e));return}C.send(o||null)})},ha=(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 ut(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},ma=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},pa=async function*(e,t){for await(const n of Ea(e))yield*ma(n,t)},Ea=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()}},Qn=(e,t,n,s)=>{const r=pa(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 f=u.byteLength;if(n){let h=o+=f;n(h)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})},It=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Aa=(e,t,n)=>t+2<n&&It(e.charCodeAt(t+1))&&It(e.charCodeAt(t+2));function ya(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 p=0;p<l;p++)if(s.charCodeAt(p)===37&&p+2<l){const S=s.charCodeAt(p+1),A=s.charCodeAt(p+2);It(S)&&It(A)&&(i-=2,p+=2)}let a=0,c=l-1;const u=p=>p>=2&&s.charCodeAt(p-2)===37&&s.charCodeAt(p-1)===51&&(s.charCodeAt(p)===68||s.charCodeAt(p)===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 h=Math.floor(i/4)*3-(a||0);return h>0?h:0}let o=0;for(let i=0,l=s.length;i<l;i++){const a=s.charCodeAt(i);if(a===37&&Aa(s,i,l))o+=1,i+=2;else 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 bn="1.18.0",Zn=64*1024,{isFunction:Et}=m,Sa=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),es=e=>{if(!m.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},ts=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ta=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},Ca=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?Et(r):typeof fetch=="function",a=Et(o),c=Et(i);if(!l)return!1;const u=l&&Et(n),f=l&&(typeof s=="function"?(E=>I=>E.encode(I))(new s):async E=>new Uint8Array(await new o(E).arrayBuffer())),h=a&&u&&ts(()=>{let E=!1;const I=new o(ie.origin,{body:new n,method:"POST",get duplex(){return E=!0,"half"}}),y=I.headers.has("Content-Type");return I.body!=null&&I.body.cancel(),E&&!y}),p=c&&u&&ts(()=>m.isReadableStream(new i("").body)),S={stream:p&&(E=>E.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(E=>{!S[E]&&(S[E]=(I,y)=>{let b=I&&I[E];if(b)return b.call(I);throw new D(`Response type '${E}' is not supported`,D.ERR_NOT_SUPPORT,y)})});const A=async E=>{if(E==null)return 0;if(m.isBlob(E))return E.size;if(m.isSpecCompliantForm(E))return(await new o(ie.origin,{method:"POST",body:E}).arrayBuffer()).byteLength;if(m.isArrayBufferView(E)||m.isArrayBuffer(E))return E.byteLength;if(m.isURLSearchParams(E)&&(E=E+""),m.isString(E))return(await f(E)).byteLength},C=async(E,I)=>{const y=m.toFiniteNumber(E.getContentLength());return y??A(I)};return async E=>{let{url:I,method:y,data:b,signal:_,cancelToken:F,timeout:g,onDownloadProgress:v,onUploadProgress:L,responseType:U,headers:x,withCredentials:B="same-origin",fetchOptions:R,maxContentLength:O,maxBodyLength:j}=or(E);const $=m.isNumber(O)&&O>-1,H=m.isNumber(j)&&j>-1,J=Y=>m.hasOwnProp(E,Y)?E[Y]:void 0;let K=r||fetch;U=U?(U+"").toLowerCase():"text";let G=ha([_,F&&F.toAbortSignal()],g),V=null;const me=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let oe,pe=null;const ae=()=>new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,E,V);try{let Y;const Te=J("auth");if(Te){const M=m.getSafeProp(Te,"username")||"",Ee=m.getSafeProp(Te,"password")||"";Y={username:M,password:Ee}}if(Ta(I)){const M=new URL(I,ie.origin);if(!Y&&(M.username||M.password)){const Ee=es(M.username),_e=es(M.password);Y={username:Ee,password:_e}}(M.username||M.password)&&(M.username="",M.password="",I=M.href)}if(Y&&(x.delete("authorization"),x.set("Authorization","Basic "+btoa(Sa((Y.username||"")+":"+(Y.password||""))))),$&&typeof I=="string"&&I.startsWith("data:")&&ya(I)>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V);if(H&&y!=="get"&&y!=="head"){const M=await A(b);if(typeof M=="number"&&isFinite(M)&&(oe=M,M>j))throw ae()}const Re=H&&(m.isReadableStream(b)||m.isStream(b)),Ue=(M,Ee,_e)=>Qn(M,Zn,k=>{if(H&&k>j)throw pe=ae();Ee&&Ee(k)},_e);if(h&&y!=="get"&&y!=="head"&&(L||Re)){if(oe=oe??await C(x,b),oe!==0||Re){let M=new o(I,{method:"POST",body:b,duplex:"half"}),Ee;if(m.isFormData(b)&&(Ee=M.headers.get("content-type"))&&x.setContentType(Ee),M.body){const[_e,k]=L&&Wn(oe,Pt(zn(L)))||[];b=Ue(M.body,_e,k)}}}else if(Re&&!a&&u&&y!=="get"&&y!=="head")b=Ue(b);else if(Re&&a&&!h&&y!=="get"&&y!=="head")throw new D("Stream request bodies are not supported by the current fetch implementation",D.ERR_NOT_SUPPORT,E,V);m.isString(B)||(B=B?"include":"omit");const Xe=a&&"credentials"in o.prototype;if(m.isFormData(b)){const M=x.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&x.delete("content-type")}x.set("User-Agent","axios/"+bn,!1);const Je={...R,signal:G,method:y.toUpperCase(),headers:Ws(x.normalize()),body:b,duplex:"half",credentials:Xe?B:void 0};V=a&&new o(I,Je);let ce=await(a?K(V,R):K(I,Je));const Qe=fe.from(ce.headers);if($){const M=m.toFiniteNumber(Qe.getContentLength());if(M!=null&&M>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V)}const Ze=p&&(U==="stream"||U==="response");if(p&&ce.body&&(v||$||Ze&&me)){const M={};["status","statusText","headers"].forEach(Ae=>{M[Ae]=ce[Ae]});const Ee=m.toFiniteNumber(Qe.getContentLength()),[_e,k]=v&&Wn(Ee,Pt(zn(v),!0))||[];let X=0;const te=Ae=>{if($&&(X=Ae,X>O))throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V);_e&&_e(Ae)};ce=new i(Qn(ce.body,Zn,te,()=>{k&&k(),me&&me()}),M)}U=U||"text";let ge=await S[m.findKey(S,U)||"text"](ce,E);if($&&!p&&!Ze){let M;if(ge!=null&&(typeof ge.byteLength=="number"?M=ge.byteLength:typeof ge.size=="number"?M=ge.size:typeof ge=="string"&&(M=typeof s=="function"?new s().encode(ge).byteLength:ge.length)),typeof M=="number"&&M>O)throw new D("maxContentLength size of "+O+" exceeded",D.ERR_BAD_RESPONSE,E,V)}return!Ze&&me&&me(),await new Promise((M,Ee)=>{sr(M,Ee,{data:ge,headers:fe.from(ce.headers),status:ce.status,statusText:ce.statusText,config:E,request:V})})}catch(Y){if(me&&me(),G&&G.aborted&&G.reason instanceof D){const Te=G.reason;throw Te.config=E,V&&(Te.request=V),Y!==Te&&(Te.cause=Y),Te}throw pe?(V&&!pe.request&&(pe.request=V),pe):Y instanceof D?(V&&!Y.request&&(Y.request=V),Y):Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,E,V,Y&&Y.response),{cause:Y.cause||Y}):D.from(Y,Y&&Y.code,E,V,Y&&Y.response)}}},ga=new Map,ir=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=ga;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:Ca(t)),u=c;return c};ir();const wn={http:Fl,xhr:fa,fetch:{get:ir}};m.forEach(wn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const ns=e=>`- ${e}`,ba=e=>m.isFunction(e)||e===null||e===!1;function wa(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,!ba(s)&&(r=wn[(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(ns).join(`
5
5
  `):" "+ns(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 lr={getAdapter:wa,adapters:wn};function qt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ut(null,e)}function ss(e){return qt(e),e.headers=fe.from(e.headers),e.data=Vt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),lr.getAdapter(e.adapter||ct.adapter,e)(e).then(function(s){qt(e),e.response=s;try{s.data=Vt.call(e,e.transformResponse,s)}finally{delete e.response}return s.headers=fe.from(s.headers),s},function(s){if(!nr(s)&&(qt(e),s&&s.response)){e.response=s.response;try{s.response.data=Vt.call(e,e.transformResponse,s.response)}finally{delete e.response}s.response.headers=fe.from(s.response.headers)}return Promise.reject(s)})}const Ft={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ft[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const rs={};Ft.transitional=function(t,n,s){function r(o,i){return"[Axios v"+bn+"] 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&&!rs[i]&&(rs[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}};Ft.spelling=function(t){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function _a(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 gt={assertOptions:_a,validators:Ft},ue=gt.validators;let De=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Gn,response:new Gn}}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=Fe(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&gt.assertOptions(s,{silentJSONParsing:ue.transitional(ue.boolean),forcedJSONParsing:ue.transitional(ue.boolean),clarifyTimeoutError:ue.transitional(ue.boolean),legacyInterceptorReqResOrdering:ue.transitional(ue.boolean),advertiseZstdAcceptEncoding:ue.transitional(ue.boolean),validateStatusUndefinedResolves:ue.transitional(ue.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:gt.assertOptions(r,{encode:ue.function,serialize:ue.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),gt.assertOptions(n,{baseUrl:ue.spelling("baseURL"),withXsrfToken:ue.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"],S=>{delete o[S]}),n.headers=fe.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;a=a&&A.synchronous;const C=n.transitional||Cn;C&&C.legacyInterceptorReqResOrdering?l.unshift(A.fulfilled,A.rejected):l.push(A.fulfilled,A.rejected)});const c=[];this.interceptors.response.forEach(function(A){c.push(A.fulfilled,A.rejected)});let u,f=0,h;if(!a){const S=[ss.bind(this),void 0];for(S.unshift(...l),S.push(...c),h=S.length,u=Promise.resolve(n);f<h;)u=u.then(S[f++],S[f++]);return u}h=l.length;let p=n;for(;f<h;){const S=l[f++],A=l[f++];try{p=S(p)}catch(C){A.call(this,C);break}}try{u=ss.call(this,p)}catch(S){return Promise.reject(S)}for(f=0,h=c.length;f<h;)u=u.then(c[f++],c[f++]);return u}getUri(t){t=Fe(this.defaults,t);const n=rr(t.baseURL,t.url,t.allowAbsoluteUrls,t);return Zs(n,t.params,t.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(t){De.prototype[t]=function(n,s){return this.request(Fe(s||{},{method:t,url:n,data:s&&m.hasOwnProp(s,"data")?s.data:void 0}))}});m.forEach(["post","put","patch","query"],function(t){function n(s){return function(o,i,l){return this.request(Fe(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}De.prototype[t]=n(),t!=="query"&&(De.prototype[t+"Form"]=n(!0))});let Pa=class ar{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 ut(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 ar(function(r){t=r}),cancel:t}}};function Ia(e){return function(n){return e.apply(null,n)}}function xa(e){return m.isObject(e)&&e.isAxiosError===!0}const ln={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(ln).forEach(([e,t])=>{ln[t]=e});function cr(e){const t=new De(e),n=ks(De.prototype.request,t);return m.extend(n,De.prototype,t,{allOwnKeys:!0}),m.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return cr(Fe(e,r))},n}const Z=cr(ct);Z.Axios=De;Z.CanceledError=ut;Z.CancelToken=Pa;Z.isCancel=nr;Z.VERSION=bn;Z.toFormData=Lt;Z.AxiosError=D;Z.Cancel=Z.CanceledError;Z.all=function(t){return Promise.all(t)};Z.spread=Ia;Z.isAxiosError=xa;Z.mergeConfig=Fe;Z.AxiosHeaders=fe;Z.formToJSON=e=>tr(m.isHTMLForm(e)?new FormData(e):e);Z.getAdapter=lr.getAdapter;Z.HttpStatusCode=ln;Z.default=Z;const{Axios:Cf,AxiosError:gf,CanceledError:bf,isCancel:wf,CancelToken:_f,VERSION:Pf,all:If,Cancel:xf,isAxiosError:Of,spread:Rf,toFormData:Nf,AxiosHeaders:Df,HttpStatusCode:vf,formToJSON:Lf,getAdapter:Ff,mergeConfig:Uf,create:jf}=Z,de={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=>{}},os=Object.keys(de),ur=N.createContext(),dr=({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]=N.useState({onAction:e?.onAction||de.onAction,onChange:e?.onChange||de.onChange,onFormComplete:e?.onFormComplete||de.onFormComplete,onFormLoad:e?.onFormLoad||de.onFormLoad,onGetComponent:e?.onGetComponent||de.onGetComponent,onGetCYA:e?.onGetCYA||de.onGetCYA,onGetCYARows:e?.onGetCYARows||de.onGetCYARows,onGoingBack:e?.onGoingBack||de.onGoingBack,onPageChange:e?.onPageChange||de.onPageChange,onRequest:e?.onRequest||de.onRequest,onSubmit:e?.onSubmit||de.onSubmit,onValidate:e?.onValidate||de.onValidate,onCancel:e?.onCancel||de.onCancel}),r=(i,l)=>{os.includes(i)&&s(a=>({...a,[i]:l||de[i]}))},o=i=>{os.includes(i)&&s(l=>({...l,[i]:de[i]}))};return d.jsx(ur,{value:{hooks:n,addHook:r,removeHook:o},children:t})},Oe=()=>N.useContext(ur),Oa=()=>{const{hooks:e}=Oe(),[t,n]=N.useState({});return N.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},_n=N.createContext(),fr=({children:e=null})=>{const{hooks:t}=Oe(),[n,s]=N.useState([]),[r,o]=N.useState([]),i=h=>{h!==void 0&&o(p=>[...p,...h].filter(S=>!!S))},l=h=>{typeof h=="function"&&o(p=>p.filter(S=>!h(S)))},a=()=>{r.length&&o([])},c=h=>{h!==void 0&&s(p=>[...p,...h].filter(S=>!!S))},u=()=>{o([]),s([])},f={page:h=>{const p=w.Validate.page(h,r),S=t.onValidate(h,p);return s(S),S},pages:h=>{const p=h.map(A=>w.Validate.page(A,r)),S=h.flatMap((A,C)=>t.onValidate(A,p[C]));return s(S),S}};return d.jsx(_n,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:f},children:e})},Ge=()=>N.useContext(_n),Gt={},Kt={},Ra="idle",Na="fetching",hr="fetched",mr="error",Da=(e,t=!0)=>{const n=Oa(),s=N.useRef(Z.CancelToken.source()),[r,o]=N.useState(Ra),[i,l]=N.useState(null),[a,c]=N.useState(null),u=()=>{s.current&&s.current.cancel()};return N.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(Na);let h;if(t&&Gt[e])h=Gt[e];else{if(t&&Kt[e])throw Kt[e];h=(await n.get(e,{cancelToken:s.current.token}).catch(S=>{throw l(S),S})).data,t&&(Gt[e]=h)}c(h),o(hr)}catch(h){t&&(Kt[e]=h),l(h),c(null),o(mr)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},va="loading",bt="complete",La=e=>{const t=e.data;if(t&&!t.options||t?.url)return T.Utils.interpolateString(t.url,e.formData)},Fa=(e,t)=>{const n=La({...e,formData:t}),{status:s,data:r}=Da(n,e?.data?.useCache),[o,i]=N.useState([]),[l,a]=N.useState(va);return N.useEffect(()=>{n?s===hr?(r&&i(he.refData.toOptions(r.data||r,e.item)),a(bt)):s===mr&&(i([]),a(bt)):(e.data&&e.data.options&&i(he.refData.toOptions(e.data.options,e.item)),a(bt))},[e.id,s,r,n]),{data:o,status:l}},nt=(e,t)=>{const n=ee(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(T.FormGroup,{...n,onChange:null,children:t})},Pn=(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 Pn(e,u,n,s,r);const f=w.Validate.page(u);return s.onValidate(u,f)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},In=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Ke,{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(T.VisuallyHidden,{children:"No answer"}),Ua="Continue",an=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?z.DEFAULTS[e]:e,r=z.DEFAULTS[e.type];return s?d.jsx(T.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||Ua}):null},ja="hods-form-confirmation",Ma="Are you sure?",ka="Confirm",Ba=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=T.Utils.classBuilder(ja,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||Ma}),s,d.jsx(T.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||ka}),d.jsx(T.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},xn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===_.CONTAINER?xn(t):dt.editable(t)?t:null).filter(t=>!!t):[],$a=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?cn(r):(n.type===_.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===_.CONTAINER&&(r.data.options[i].nested[a]=cn(l))})}),r)})},cn=e=>{if(e){const t=$a(e);return{...e,components:t}}return e},Ya=(e,t)=>e.some(n=>dt.show(n,t)),Ha=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=xn(e);return n.length>0?Ya(n,t):!0},Ut={editableComponents:xn,setup:cn,show:Ha},Va=(e,t)=>e.some(n=>xe(n,t)),jt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=Ut.editableComponents(e);return n.length>0?Va(n,t):!0},qa=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!jt(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(f=>f.id===a)});return}const c=l.components.find(f=>f.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){Me(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},On=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(T.ButtonGroup,{children:e.map((n,s)=>d.jsx(an,{action:n,onAction:t},s))}),Ga=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?le.meetsOne(t.runWhen?.constraint,e.formData):!1},pr="hods-form__page",Rn=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=pr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:f})=>{const[h,p]=N.useState({}),{errors:S,validate:A}=Ge(),[C,E]=N.useState({}),[I,y]=N.useState(!1),b=N.useMemo(()=>Ga(e),[e]);N.useEffect(()=>{y(!0)},[]),N.useEffect(()=>{I&&b&&A.page(e)},[f,I]);const P=({target:x})=>{const B=e,{value:R}=x;R?(B.formData[x.name]=R,p(O=>({...O,[x.name]:R})),E(O=>({...O,[x.component]:x.label}))):(delete B.formData[x.name],p(O=>{const{[x.name]:j,...$}=O;return $}),E(O=>{const{[x.component]:j,...$}=O;return $})),typeof o=="function"&&o(e.formData)};N.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=S.length>0?"Error: "+x:x},[S]);const F=w.classBuilder(l,a,c),g=e;g.actions=g.actions?.map(x=>x.label?{...x,label:w.interpolateString(x.label,g.formData)}:x),g.formData=w.Operate.runPageOperations(g,{...g.formData,...h},s||P);const v=e.title?d.jsx(T.Heading,{size:e.titleSize,children:w.FormPage.getTitle(e.title,e.formData)}):d.jsx(T.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),L=e.components.filter(x=>w.Component.show(x,e.formData)).map((x,B)=>d.jsx(Ke,{component:x,onAction:R=>n(R,h,C),onChange:s||P,onTopLevelChange:r||P,value:e.formData[x.fieldId]||h[x.fieldId],formData:e.formData,pages:t,submitting:u},B));let U=null;return b&&S?.length>0?U=[{error:e?.customValidation?.[0]?.message}]:S?.length>0&&!b&&(U=S),d.jsxs("div",{className:F(),children:[U&&d.jsx(T.ErrorSummary,{errors:U,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:v}),L]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[v,L]}),d.jsx(On,{actions:e.actions?.filter(x=>w.Component.show(x,e.formData)),onAction:x=>n(x,h,C)})]},e.id)},is="hods-form-banner-strip",Er=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=w.classBuilder(is,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(T.Markup,{content:w.interpolateString(c,n)})},a)}return d.jsx(T.Tag,{classBlock:`${is}__tag`,classModifiers:i.classModifiers,text:w.interpolateString(i.text,n)},a)})})},Ka=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{}},Nn=({row:e})=>{const[t,n]=N.useState({});return N.useEffect(()=>{n(Ka(e))},[e,n]),e.action?d.jsxs(T.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(T.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},Ar=({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(Nn,{row:e})})]}),yr=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(T.SmallHeading,{children:e})}),wt=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=Bt(o,t);return t.type==="title"?d.jsx(yr,{title:t.key,classes:n}):d.jsx(Ar,{row:{key:i.key,value:d.jsx(In,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Wa="govuk-summary-card",za="govuk-summary-list",At="Item",yt="Change",ls="Delete",Xa="warning",Ja=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=T.Utils.classBuilder(Wa,i,n.className),c=T.Utils.classBuilder(za,[]);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:T.Utils.interpolateString(n.title||At,{...t,index:t.index+1})}),n.banners&&d.jsx(Er,{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(T.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||yt} ${n.title||At}`,{...t,index:t.index+1}),children:n.changeAction?.label||yt}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||yt} ${n.title||At}`,{...t,index:t.index+1}),children:n.changeAction?.label||yt})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||Xa,"aria-label":T.Utils.interpolateString(`${n.deleteAction?.label||ls} ${n.title||At}`,{...t,index:t.index+1}),children:n.deleteAction.label||ls})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const f=u.components.map(h=>w.Component.elevateNested([h],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(h=>{const S=h.columns.filter(A=>le.meetsAll(A,{...u.formData,...t})).flatMap(A=>A.fields||[]);return S.length?S.flatMap(A=>{const C=f.find(E=>E.fieldId===A);return C?wt(u,C,c,t,l):null}):null})})})})]})},Qa=({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(T.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||cs,"aria-label":w.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||as},e))}):d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||cs,"aria-label":w.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||as}),Za=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},Mt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Za(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},Sr=[_.ALERT,_.COLLECTION_SUMMARY,_.DETAILS,_.HEADING,_.HTML,_.INSET_TEXT],xt=(e,t)=>{if(!e||Sr.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?Ut.show(e,t):dt.show(e,t)},Tr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>Sr.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}`}})}),ec=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:Mt(!1,e,t)}],tc=(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:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),nc=(e,t,n,s,r)=>{const o={...He,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},Dn=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&xt(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=tc(t,o,l,a);return c=Tr(c),[nc(t,o,e.id,l,a),...We(e,c,o,s,r)??[]]}).filter(o=>!!o):ec(e,s),sc="hods-form-summary-card-details",Cr=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=w.classBuilder(sc,r),a=N.useMemo(()=>t.map(u=>e.childPages.find(f=>f.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,f,h)=>{let p=0;return u.flatMap((S,A)=>{let C=0;const E=S.fields?.flatMap(y=>f.filter(P=>P.fieldId===y).map(P=>{if(!P||!xe(P,{...h.formData,...s}))return null;if(P.type===_.CONTAINER){const F=We(h,P,s);return C+=1,d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:F.map(g=>{const v={...s,[g.fieldId]:s[P.fieldId]?.[g.fieldId]};return wt(h,{...g,label:g.key},l,v,i)})},y)}if(P.type===_.COLLECTION){const F=Dn({...h,formData:{...h.formData,...s}},P,s[P.id]);C+=1;let g=0;return d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:F.map(v=>{const L={...s,[v.fieldId]:s[P.fieldId]?.[v.fieldId]},U=wt(h,{...v,label:v.key},l,L,i);return v.type==="title"&&(g+=1,g>1)?d.jsx("div",{style:{marginTop:"40px"},children:U}):U})},y)}return C+=1,d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:wt(h,P,l,s,i)},y)})).filter(y=>!!y);return!(A===u.length-1)&&E.length!==0?(p+=2,[...E,d.jsx("div",{className:l("divider"),style:{"--column":p}},`divider${p}`)]):E}).filter(S=>!!S)};return e?.childPages?.filter(u=>w.FormPage.show(u,{...n,...s})).map(u=>{const f=w.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(h=>{if(h.show_when&&!w.Condition.meetsAll(h.show_when,{...n,...s}))return null;if(h.type==="childCollection"){const S=a.find(C=>C.collection.name===h.collectionName),A=s[h.collectionName.split(".").pop()]||[];return S&&A.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:h.title}),A.map(C=>d.jsx(Cr,{masterPage:S,childMasterPages:[],formData:{...n,...s,...C},entryData:C,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const p=h.columns.filter(S=>le.meetsAll(S,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:w.FormPage.getConditionalText(h.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":p.length-1},children:c(p,f,u)})]},h.title)})}).filter(u=>!!u)||null},rc="hods-form-summary-card",as="Change",oc="Delete",ic="Quick Edit",lc="Duplicate",ac="Full details",cs="secondary",us=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:f,hideDetails:h=!1})=>{const[p,S]=N.useState(!1),A=T.Utils.classBuilder(rc,s,n.className),C=N.useMemo(()=>n.quickEdit?qa(f,u,t):null,[f,n,u,t,p]),{addErrors:E,resetQuickEditErrors:I,clearTopLevelErrorsForCard:y,validate:b}=Ge(),{hooks:P}=Oe(),F=async(g,v)=>{if(g.type==="cancel"&&(S(L=>!L),I?.()),g.type==="save"&&typeof l=="function"){const L={...C.formData,...v,[`${a}ActiveId`]:t.id},U=b.page({...C,formData:L});if(U.length)return;let x;await P.onSubmit("quickEdit",L,()=>{},R=>{x=R}),x&&E(x);const B=U.concat(x);if(B.length===0||B.length===1&&B[0]===void 0){y();const R=w.CollectionPage.getData(a,u),{isDuplicate:O,...j}=R[t.index];R[t.index]={...j,...v},l({target:{name:a,value:R}}),S($=>!$)}}};return n.listView?d.jsx(Ja,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:f,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:A(),id:e,children:[d.jsxs("div",{className:A("header"),children:[d.jsxs("div",{className:A("header-content"),children:[n.banners&&d.jsx(Er,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:A("header-content-title"),children:w.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:A("header-content-detail"),children:w.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:A("header-actions"),children:[n.quickEdit&&d.jsx(T.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>S(g=>!g),classModifiers:"primary",disabled:p,name:"QuickEdit",autoFocus:n.focusOn,children:ic}),n.changeAction&&typeof r=="function"&&d.jsx(Qa,{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(T.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||oc}),n.duplicateAction&&typeof i=="function"&&d.jsx(T.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||lc})]})]}),p&&C&&d.jsx(Rn,{page:C,onAction:(g,v)=>F(g,v),className:A("editpage")}),d.jsx("div",{className:A("body"),children:!h&&d.jsx(T.Details,{summary:n.detailsTitle||ac,className:"details",children:d.jsx(Cr,{masterPage:f,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},cc=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=Oe(),o=t.filter(f=>f.entryId===e)||[],[i,l]=N.useState(null),a=()=>{l(null)},c=f=>{l(h=>(h??[]).concat(f))},u={page:f=>{const h=w.Validate.page(f),p=r.onValidate(f,h);return l(p),p}};return d.jsx(_n,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},ds="Add",uc=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=Oe(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:f,dequeueErrors:h}=Ge(),[p,S]=N.useState(null),A=N.useMemo(()=>w.CollectionPage.getData(e.collectionName,t)||[],[t]),C=Array.isArray(A)&&A.length>0?A.reduce((v,L)=>L.isDuplicate&&(!v||L.id>v.id)?L:v,null):null,E=N.useMemo(()=>{const v=e.collectionName.split(".");let L=w.CollectionPage.mergePages(o||[])||[];return v.reduce((U,x,B)=>{const R=B===0?`${U}${x}`:`${U}.${x}`;return B===v.length-1?L?.find(O=>O.collection?.name===R)||null:(L=L.find(O=>O.collection?.name===R)?.childPages||null,R)},"")},[o]),I=N.useMemo(()=>e.card.listView?E.childPages?.reduce((L,U)=>{const x=it(U.components,{...t,...p});return L.concat(x)},[])||[]:[],[E,t,p,e.card.listView]),y=()=>{u.length>0&&h(L=>L.raisedBy===e.id);const v=Pn(e,E,t,i);v.length>0&&f(v)};N.useEffect(()=>{Array.isArray(A)&&A.length>0&&y()},[A]);const b=(v,L)=>{if(typeof n=="function"){const U=[...A],x=A.findIndex(O=>O.id===L),{isDuplicate:B,...R}=A[x];U[x]={...R},n({type:St.SAVE_AND_NAVIGATE,page:v,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:L},{field:e.collectionName,value:U,isCollection:!0}]})}},P=v=>{w.CollectionPage.duplicateEntry(e.collectionName,t,v.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const L=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:L,value:w.CollectionPage.getData(L,t)}}),y())},F=()=>{if(!p)return;w.CollectionPage.removeEntry(e.collectionName,t,p.id);const v=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:v,value:w.CollectionPage.getData(v,t)}}),S(null),y()},g=v=>{const L=I.find(x=>x.fieldId===v);if(!L)return null;const U=Bt({...E,formData:{...t,...p}},L);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(In,{value:U.value,component:U.component,formData:U.formData})},v)};return d.jsxs("div",{id:e.fieldId,children:[p&&d.jsx(Ba,{id:`${e.fieldId}.confirmation`,message:w.interpolateString(e.confirmation?.message,{...p,index:p.index+1})||null,confirmLabel:w.interpolateString(e.confirmation?.label,p)||null,onConfirm:F,onCancel:()=>S(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(g)}):d.jsx(us,{id:`${e.fieldId}.confirmationChild`,entryData:p,config:e.card?{...e.card,quickEdit:null}:{},masterPage:E,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(an,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||ds,{documents:A}),page:e.addButton.page,type:St.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:A.map((v,L)=>{const U=l.filter(R=>R.entryId===v.id).length>0,x={...e.card,...v.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...U&&e.errorCard?e.errorCard:{},focusOn:C?.id===v.id},B=`${e.fieldId}.summaryCard${v.id}`;return d.jsx("li",{children:d.jsx(cc,{entryId:v.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const R=l.filter(O=>O.entryId!==v.id);c(),a(R)},children:d.jsx(us,{id:B,entryData:{...v,index:L},masterPage:E,config:x||{},onFullEdit:b,onDuplicate:P,onDelete:()=>S({...v,index:L}),onQuickEdit:R=>(y(),s(R)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:v.id===p?.id?["deleting-summary-card"]:[""],inError:l.filter(R=>R.entryId===v.id).length>0},B)})})})}),e.card.listView&&e.addButton&&d.jsx(an,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||ds,{documents:A}),page:e.addButton.page,type:St.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},dc="hods-form-collection",fc=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=N.useState(t),a=A=>{l(A),typeof s=="function"&&s({target:{name:e.fieldId,value:A}})},c=({target:A})=>{if(typeof s=="function")if(A.name===w.Meta.name)s({target:A});else{const C=i.findIndex(E=>E.id===A.name);a([...i.slice(0,C),A.value,...i.slice(C+1)])}},u=async()=>{a([...i,{id:Dt.v4()}])},f=async A=>{a(i.filter(C=>C.id!==A.id))},h=A=>A.initial&&!i.length?A.initial:A.add;N.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const A=i[i.length-1]?.id,E=document.getElementById(A)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');E&&E.length>0&&E[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),N.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const p={...He,...e.labels},S=w.classBuilder(dc,[],e.className);return d.jsxs("div",{className:S(),id:e.id,children:[e.label&&d.jsx(T.Label,{id:e.id,required:e.required,className:S("title"),children:e.label}),Array.isArray(i)&&i.map((A,C)=>{const E=`${e.full_path||e.fieldId}[${C}]`,I=(e.countOffset||0)+C+1,y=w.interpolateString(p.item,{...A,index:I}),b=w.interpolateString(p.remove,{...A,index:I}),P=e.disableAddAndRemove||C===0&&e.minimumEntries?"":e.removeLocation??"start",F=C!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${S("item")}`,style:F,children:[d.jsxs(T.Label,{id:A.id,required:!0,className:S("item-title"),children:[y,P==="start"&&d.jsx(T.Button,{onClick:()=>f(A),classModifiers:"secondary",children:b})]}),d.jsx(Un,{container:{id:A.id,fieldId:A.id,type:"container",required:e.required,full_path:E,components:e.item.map(g=>{const{firstOnlyLabel:v,...L}=g;let{hint:U}=g;e.restrictHint&&C>0&&(U=void 0);let{label:x}=g;return C===0&&(x=g.firstOnlyLabel??g.label),{...L,hint:U,readonly:!!(e?.readonly||g.readonly),label:w.interpolateString(x,{...A,index:I}),full_path:`${E}.${g.fieldId}`}})},value:A,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),P==="end"&&d.jsx(T.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(T.Button,{onClick:()=>f(A),classModifiers:"secondary",children:b})})]},A.id)}),!e.disableAddAndRemove&&d.jsx(T.ButtonGroup,{children:d.jsx(T.Button,{onClick:u,classModifiers:"secondary",children:h(p)})})]})},hc=(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},mc=(e,t)=>typeof e=="string"?!!T.Utils.interpolateString(e,t):!!e,Wt=(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}}},pc=[_.RADIOS,_.CHECKBOXES,_.DATE,_.TIME],Ec=e=>e.fieldset||pc.includes(e.type),Ke=({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}=Oe(),f=Ge(),{data:h,status:p}=Fa(e,n),[S,A]=N.useState([]);N.useEffect(()=>{p===bt&&A(h)},[e,h,p]);const C=({target:y})=>typeof o=="function"?(e.type===_.EMAIL&&(y.value=y.value.trim()),e.type===_.CHECKBOXES&&Array.isArray(y.value)&&y.value.forEach(b=>{b.children&&b.nested&&(delete b.children,delete b.nested)}),y=hc(y,e,h),e.type===_.SELECT&&y.value===""&&(y.value=null,y.label=null),o({target:y}),!0):!1;if(N.useEffect(()=>{const y=w.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&y&&typeof C=="function"&&C({target:{name:e.fieldId,value:y}})},[]),e.type===_.CONTAINER){let y=d.jsx(Un,{...c,container:e,wrap:s,onChange:C,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});return e.fieldset&&(y=nt(e,y)),e.additionalValidation&&(y=nt({...e,...Wt(e,f?.errors)},y)),y}if(e.type===_.COLLECTION)return d.jsx(fc,{...c,config:e,wrap:s,onChange:C,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});if(e.type===_.COLLECTION_SUMMARY)return nt({...e,...Wt(e,f?.errors)},d.jsx(uc,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const E=y=>{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(y,n,b,e.allowMultiple)}})},I=({target:y})=>{if(C({target:y})){if(e.type===_.FILE)E([y.value]);else if(e.type===_.MULTI_FILE){const b=y.value.map((P,F)=>({...P,indexInField:F}));E(b)}}};return w.Component.get({...c,...e,id:e.full_path||e.id,...Wt(e,f?.errors),fieldset:Ec(e),disabled:mc(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:S,value:t,onChange:I,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},Ac=[_.AUTOCOMPLETE,_.CALCULATION,_.CHECKBOXES,_.COLLECTION_SUMMARY,_.DATE,_.EMAIL,_.FILE,_.MULTI_FILE,_.PHONE_NUMBER,_.RADIOS,_.SELECT,_.TEXT,_.TEXT_AREA,_.TIME],gr=e=>Ac.includes(e?.type)||e?.isEditable||!1,yc="govuk-list",Sc="govuk-body",Tc=e=>{const t=ee(e),n=T.Utils.interpolateString(e.heading,e.formData),s=T.Utils.interpolateString(e.text,e.formData);return d.jsx(T.Alert,{...t,heading:n,children:s})},Cc=e=>{const t=ee(e),n=he.getAutocompleteSource(e);return d.jsx(T.Autocomplete,{...t,source:n})},gc=e=>{let t=[];he.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:br(e,s.nested)}:s);const n=ee(e);return d.jsx(T.Checkboxes,{...n,options:t})},bc=e=>{const t=he.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=ee(e,["formula"]);return d.jsx(T.TextInput,{...n,readonly:!0})},wc=e=>{const t=ee(e);return d.jsx(T.DateInput,{...t})},_c=e=>{const t=ee(e,["tagName"]),n=kt(e);return d.jsx(T.Details,{...t,children:n})},Pc=e=>{const t=ee(e);return d.jsx(T.FileUpload,{...t})},Ic=e=>{const t=ee(e);return d.jsx(T.MultiFileUpload,{...t})},xc=e=>{const t=ee(e);return d.jsx(T.Heading,{...t,children:e.content})},kt=e=>{const t=ee(e);return d.jsx(T.Markup,{...t})},Oc=e=>{const t=ee(e);return d.jsx(T.InsetText,{...t,children:e.content})},Rc=e=>{const t=ee(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=T.Utils.classBuilder(yc,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return kt({...t,className:r(),tagName:n,content:o,type:_.HTML})},Nc=e=>{const t=ee(e);return kt({className:Sc,...t,tagName:"p",type:_.HTML})},Dc=e=>{let t=[];he.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:br(e,s.nested)}:s);const n=ee(e);return d.jsx(T.Radios,{...n,options:t})},vc=e=>{const t=ee(e);return d.jsx(T.TextArea,{...t})},Lc=e=>{const t=ee(e);return d.jsx(T.TextInput,{...t})},Fc=e=>{const t=ee(e);return d.jsx(T.TimeInput,{...t})},Uc=e=>{let t=[];he.getOptions(e,s=>{t=s});const n=ee(e);return d.jsx(T.Select,{...n,options:t})},jc=e=>{const t=ee(e);return d.jsx(T.WarningText,{...t,children:e.content})},Mc=e=>{switch(e.type){case _.HTML:return kt(e);case _.HEADING:return xc(e);case _.INSET_TEXT:return Oc(e);case _.TEXT:case _.EMAIL:case _.PHONE_NUMBER:return Lc(e);case _.TEXT_AREA:return vc(e);case _.AUTOCOMPLETE:return Cc(e);case _.RADIOS:return Dc(e);case _.CHECKBOXES:return gc(e);case _.DATE:return wc(e);case _.TIME:return Fc(e);case _.FILE:return Pc(e);case _.MULTI_FILE:return Ic(e);case _.WARNING:return jc(e);case _.SELECT:return Uc(e);case _.DETAILS:return _c(e);case _.CALCULATION:return bc(e);case _.ALERT:return Tc(e);case _.PARAGRAPH:return Nc(e);case _.LIST:return Rc(e);default:return null}},kc=(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]||he.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:wr(n,!1)})):d.jsx(Ke,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},br=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!le.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:kc(e,s)},s.id));return n.length>0?n:null},wr=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=Mc(e);return s&&t&&gr(e)?nt(e,s):s},Bc=e=>e.defaultValue||e.defaultObjectValue,$c=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?W().format("DD-MM-YYYY"):n},Yc=(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},_r=(e,t)=>Bc(e)?e.type===_.DATE?$c(e):(e.defaultObjectValue?Yc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Hc={[_.COLLECTION]:[],[_.CONTAINER]:{}},Vc=(e,t)=>e&&(_r(e,t)||Hc[e.type])||"",dt={clean:ee,defaultValue:Vc,defaultValueFromConfig:_r,editable:gr,elevateNested:it,get:wr,setupContainerPaths:Tr,show:xe,wrap:nt},qc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&ot(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},Bt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],qc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:T.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:dt.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:Mt(t.readonly,e,n)}},We=(e,t,n,s,r)=>xt(t,{...e.formData,...n})?it(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>xt(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?We(e,i,{...l,...n},s,r):i.type===_.COLLECTION?Dn(e,i,l,s,r):Bt({...e,formData:n},i,s)}):null,Gc=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},fs=(e,t,n="text")=>{if(typeof e=="string")return T.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:Me(r.show_when,t));return typeof s=="string"?T.Utils.interpolateString(s,t):T.Utils.interpolateString(s[n],t)},Kc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Wc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return z.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return z.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),Kc(n)}}).filter(t=>!!t)},zc=e=>({type:_.HTML,tagName:"p",content:e}),Xc=(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?un(l,t):l)),r},un=(e,t)=>{if(e){const n=Xc(e,t);if(n)return n}return{...e}},Pr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return zc(o);let i;return o.type===_.CONTAINER&&(o.components=o.components.map(l=>l.use?un(l,t):l)),o.use?i=un(o,t):i={...o},n?he.refData.setupUrl(i,n):i}),r=Wc(e);return Ut.setup({...e,formData:n,components:s,actions:r})},Jc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...Pr(s,t,n),index:r})):[],Ir=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:jt(e,t),ft={applyConditionalProperties:Gc,getConditionalText:fs,get:Pr,getAll:Jc,getTitle:(e,t)=>fs(e,t,"title"),show:jt,showCYA:Ir},Qc=(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},Zc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},$t=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},eu=e=>typeof e=="number"&&e>=0,xr=(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 eu(o)?(e.shift(),xr(e,t[s][o],n)):null},ze=(e,t)=>{const n=e.split(".");return xr(n,t,t)},Or=(e,t,n,s=[],r={})=>{const o=ze(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=Dt.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},tu=(e,t)=>{const n=$t(e,t);return Or(e,t,n)},nu=e=>typeof e=="number"&&e>=0,Rr=(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 nu(o)?e.length===1?o:(e.shift(),Rr(e,t[s][o],n)):null},Nr=(e,t)=>{const n=e.split(".");return Rr(n,t,t)},su=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]}),ru=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},ou=(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},Dr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=su(s);return t[s.collection.name]=o,o}return ru(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&ou(s,t)?null:s).filter(s=>!!s)},iu=(e,t,n)=>{const s=ze(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},lu=e=>typeof e=="number"&&e>=0,vn=(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=Dt.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 lu(a)?(o=o[i][a],!1):!0})},Ot={addEntry:Zc,duplicateActiveEntry:tu,duplicateEntry:Or,getActiveId:$t,getActiveIndex:Nr,getData:ze,getErrorsForCollection:Pn,mergePages:Dr,removeEntry:iu,setData:vn},au=e=>typeof e=="number"&&e>=0,cu=(e,t,n,s,r,o)=>{const i=r?.label||He.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(h=>{const[p,S]=h;c[p]=S});const u=Ot.getData(e.collection.name,c),f=u?.findIndex(h=>h.id===t.id);return au(f)&&u.splice(f,1),c})},label:T.Utils.interpolateString(i,{...t,index:s})}}},uu=(e,t,n,s,r,o={})=>{const i=r?.label||He.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(f=>{const[h,p]=f;u[h]=p}),u};n(r.page?{pageId:r.page}:l,a)},label:T.Utils.interpolateString(i,{...t,index:s})}}},du=(e,t)=>t.show_when?Me(t.show_when,e):!0,fu=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),hu=(e,t,n,s,r)=>{const o={...He,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},mu=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:T.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},pu=(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"}}),Eu=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>du(r,i)).map(i=>i.type==="remove"?cu(e,t,n,s,i,o):i.type==="change"?uu(e,t,n,s,i,o):null).filter(i=>!!i),vr=(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)},Au=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Lr(c,n,s,t,i));else if(c.collection.route&&(c=Qc(c,c.collection.route)||c),Ir(c,{...c.formData,...t})){const u=vr(c,n,i);if(c.collection.heading){const p=c.collection.heading.changeLink?u:null,S=mu(c.collection.heading,c.id,r,p,t);l=l.concat(S)}const f=fu(c,t,r,o),h=We({...c,formData:{...c.formData,...t}},f,{...c.formData,...t},u,s);l=l.concat(h)}}),l},Lr=(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 h=e.collection.collectionHeading?.changeLinkPage?vr({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(pu(e,o,e.collection.collectionHeading,h))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Me(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Me(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((p,S)=>(c=S,p.id===l))]),i.forEach(h=>{if(!h)return;r={...r,[`${o}ActiveId`]:h.id};const p=c+1,S=e.collection?.actionPosition||"top",A=`${e.collection.name}[${c}]`,C=Eu(e,h,t,p,s,r);if(!u){const E=hu(e,h,e.id,p,A);a=a.concat(E)}S==="top"&&(a=a.concat(C)),a=a.concat(Au(e.childPages,h,t,n,p,A,r)),S==="bottom"&&(a=a.concat(C)),c+=1}),a.filter(h=>!!h)},yu=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Ke,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,Su=(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?yu(t[o]):null})}),firstComponentIndex:n}},Tu=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=Su(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:Mt(!1,e,s)},insertAt:o}},Cu=(e,t,n=null)=>{if(ft.showCYA(e,e.formData)){if(e.collection)return Lr(e,t,n,e.formData);const r=it(e.components,e.formData).filter(o=>xt(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 We(e,o,e.formData[o.fieldId],t,n);case _.COLLECTION:return Dn(e,o,e.formData[o.fieldId],t,n);default:return Bt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=Tu(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[]},gu={getRows:Cu,getCYARowsForContainer:We},Fr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},Ur=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=Fr(e.format,s[e.fieldId]))},jr=(e,t,n)=>{e.forEach(s=>Ur(s,t,n))},Mr=(e,t,n)=>{jr(e.components,t,n)},bu=(e,t,n)=>{e.forEach(s=>Mr(s,t,n))},wu=(e,t,n)=>{const s={...t};return jr(e.components,s,n),bu(e.pages,s,n),s},_u={component:Ur,data:Fr,form:wu,page:Mr},Pu=(e,t,n,s)=>{if(e===ne.HUB&&t){if(t.format===Se.CYA)return Se.CYA;if(t.components)return ft.get(t,n,s)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return Se.TASK},Iu={get:Pu},Ln="meta",Fn="documents",dn=e=>e?.[Ln]?.[Fn]||[],xu=(e,t,n,s)=>{const r=s?dn(t):dn(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Ln]:void 0,[Fn]:r}},Ou={setForField:xu,get:dn,name:Fn},Ru={documents:Ou,name:Ln},Nu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return!!se(t,n)}return!1},zt=(e,t)=>{if(e?.value)return e.value;const n=T.Utils.interpolateString(e?.field,t);return se(t,n)},Du=(e,t)=>{if(!e||!t)return null;const n=T.Utils.interpolateString(e.target,t),s=se(t,n),r=zt(e,t),o=zt(e.cutoff,t),i=zt(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},vu=(e,t,n)=>{let s;if(e?.field){const r=T.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}})},Lu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return se(t,n)||null}return e?.value||null},Fu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},Uu=(e,t)=>{if(e?.condition){const n=e,s=T.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},ju=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=T.Utils.interpolateString(s,t),o=se(t,r);return o?(n=o,!0):!1}),n||(e.fallback?T.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},Mu=(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=Nr(l,t);s+=`${l}[${a}]`}else s+=i});const r=T.Utils.interpolateString(s,t);return se(t,r)?.length||0},ku=(e,t)=>{const n=T.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},Bu={checkValueIsTruthy:Nu,getIndexOfMatchingValueIn:Du,doesContainValue:ku,persistValueInFormData:vu,setValueInFormData:Lu,deleteValueInFormData:Fu,getLength:Mu,getFirstOf:ju},$u=(e,t,n)=>{const s=Bu[e.function];if(typeof s=="function")return s(e,t,n)},Yu=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(Uu(s.run_when,t)){const r=$u(s,t,n);if(s.output){const o=T.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");Fs(t,o,r)}}}),t),Hu={runPageOperations:Yu},Vu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),qu=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},Gu=e=>/^-?\d+$/.test(e),Rt=e=>Gu(e)?e.padStart(2,"0"):"",Pe=e=>{const[t,n,s]=e.split("-");return`${Rt(t)}-${Rt(n)}-${s}`},kr=e=>{const[t,n]=e.split(":");return`${Rt(t)}:${Rt(n)}`},be="DD-MM-YYYY";W.extend(Ye);const Ku=(e,t)=>{const n=t.date?W(Pe(t.date),be):W().add(t.value,t.unit);return W(Pe(e),be).isAfter(n)};W.extend(Ye);const Wu=(e,t)=>{const n=t.date?W(Pe(t.date),be):W().add(t.value,t.unit);return W(Pe(e),be).isBefore(n)};W.extend(Ye);const zu=(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||rt(s,e[n.fieldId],e[n.fieldId])||rt(r,e[n.fieldId],e[n.fieldId]))return!0;const l=Pe(e[n.fieldId]?.[t.date]),a=kr(e[n.fieldId]?.[t.time]);return W(`${l} ${a}`,`${be} HH:mm`).isBefore(W())};W.extend(Ye);W.extend(pn);const Xu=(e,t)=>{const n=W(Pe(e),be).isBefore(W()),s=W(Pe(e),be).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};W.extend(Ye);W.extend(pn);const Ju=(e,t)=>W(Pe(e),be).isAfter(W())?!0:!!t?.todayAllowed&&W(Pe(e),be).isToday(),Qu=(e,t)=>e?e.length>t.value:!0,Zu=(e,t)=>e?e.length<t.value:!0,ed=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},td=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},nd=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,sd=(e,t)=>e?t.array.includes(e):!0,rd=(e,t,n,s)=>{if(!e||!s)return!0;const r=$t(t.collectionPath,s);return!ze(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)},od=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),id=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,ld=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,ad=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!ld.test(t)}return!1},cd=(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,ud={conditionallyPermittedChange:Vu,conditionallyRequired:qu,mustBeAfter:Ku,mustBeBefore:Wu,mustBeEarlierDateTime:zu,mustBeGreaterThan:ed,mustBeInTheFuture:Ju,mustBeInThePast:Xu,mustBeLessThan:td,mustBeLongerThan:Qu,mustBeNumbersOnly:nd,mustBeOneOf:sd,mustBeShorterThan:Zu,mustBeUniqueInCollection:rd,mustEnterAtLeastOne:od,mustHaveLessThanDecimalPlaces:id,mustNotContainSql:ad,mustSelectOnlyOne:cd},dd=(e,t,n,s)=>{const r=ud[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Br=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=dd(t,r,e,n))}),s}},Nt=(e,t,n)=>{if(!e)return[];const s=n||t,r=Br(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;it(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(rt({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},fd=(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(f=>({...f,message:T.Utils.interpolateString(o===0&&f.firstOnlyMessage?f.firstOnlyMessage:f.message,{index:i})}))),u})};s.push(Nt(a,r,n))}),s.filter(r=>!!r).flat()};W.extend(Ye);W.extend(pn);W.extend(ro);const hd=(e,t)=>e==="02"?W().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,$r=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Pe(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=hd(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 W(t,be).format(be)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},md=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,pd=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,Yr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&(md.test(e)||pd.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`}},Ed="Invalid files must be deleted",Hr=(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 Ed}},Vr=(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"}},qr=(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`}},Gr=(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=kr(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}},Ad=(e,t)=>e?.type==="or"?le.meetsOne(e.conditions,t):le.meetsAll(e.conditions,t),rt=(e,t,n)=>{const s=n||t;if(!xe(e,{...s,...t}))return;if(e.type===_.CONTAINER)return Nt(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===_.COLLECTION_SUMMARY&&(l=ze(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!Ad(e.requiredOverrideConditions,s))&&(r=qr(l,e.label,e.custom_errors)),!r){switch(e.type){case _.COLLECTION:return fd(e,l,s);case _.EMAIL:r=Yr(l,e.label,e.custom_errors);break;case _.DATE:case _.TIME:{const a=e.type===_.DATE?$r: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&&ot(n[e.id],c)&&(a=a.concat(Nt({components:c.nested},n)))}),a.length>0)return a;break}case _.MULTI_FILE:r=Hr(l,e.custom_errors);break;case _.TEXT_AREA:r=Gr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=Vr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Br(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}},yd=(e,t=[])=>{let n=e.formData;if(e.collection){const s=Ot.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...Ot.getData(e.collection.name,e.formData)?.[s]})}return jt(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!xe(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(rt(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:T.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},Sd={component:rt,container:Nt,email:Yr,date:$r,multifile:Hr,page:yd,regex:Vr,required:qr,textarea:Gr,time:Kr},w={CheckYourAnswers:gu,CollectionPage:Ot,Component:dt,Condition:le,Container:Ut,Data:he,Format:_u,FormPage:ft,Hub:Iu,Meta:Ru,Operate:Hu,Validate:Sd,...T.Utils},Td="hods-form-container",Un=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:f})=>{if(typeof s=="function")if(f.name===w.Meta.name)s({target:f});else{const h={...t,[f.name]:f.value};s({target:{name:e.fieldId,value:h}})}},a=f=>{const h=`${e.full_path||e.fieldId}.${f.fieldId}`;return f.type===_.CONTAINER?w.Container.show({...f,full_path:h},n):w.Component.show({...f,full_path:h},{...n,...se(n,e.full_path)})},c=w.classBuilder(Td,[],e.className),u=T.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(T.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((f,h)=>{const p=f.type===_.FILE?{}:"",S=t?t[f.fieldId]:p,A=`${e.full_path||e.fieldId}.${f.fieldId}`;return d.jsx(Ke,{...i,component:{...f,full_path:A,readonly:!!(e.readonly||f.readonly)},formData:n,value:S||p,wrap:r,onChange:l,onTopLevelChange:o},h)})]})},Cd=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{}},hs=({group:e})=>{const[t,n]=N.useState({});return N.useEffect(()=>{n(Cd(e))},[e,n]),e?.action?d.jsxs(T.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},gd=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(T.SmallHeading,{children:e}),t==="m"&&d.jsx(T.MediumHeading,{children:e})]}),bd=({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(T.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(T.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Nn,{row:{action:e.action}})})]}),wd="govuk-summary-list",fn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=wd,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=T.Utils.classBuilder(r,o,i),u=T.Utils.cleanHtmlAttributes(a);let f=null;if(s){const h=e.filter(p=>!!p.action);f=h?.length?h[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(h=>{const p=`${h.pageId}_${h.full_path||h.fieldId}`;return h.type==="title"?d.jsx(yr,{title:h.key,classes:c},p):h.type==="heading"?d.jsx(gd,{title:h.key,size:h.size||"s",classes:c},p):h.type==="headingWithAction"?d.jsx(bd,{row:h,classes:c,noChangeAction:t},p):h.type==="action"?t?null:d.jsx("div",{children:d.jsx(hs,{group:h})},`${p}-actions`):d.jsx(Ar,{row:h,classes:c,showAction:!t},p)}).filter(h=>!!h),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(hs,{group:f})})]})})},_d="hods-check-your-answers",Pd="Check your answers",ms=9,Id=({title:e=Pd,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:f,groups:h,sections:p=[],type:S,hideBlankRows:A=!1,optionalFieldPlaceholder:C})=>{const[E,I]=N.useState([]),[y,b]=N.useState([]),{errors:P}=Ge(),{hooks:F}=Oe();N.useEffect(()=>{const O=(H,J)=>w.CheckYourAnswers.getRows(H,o,F.onGetCYARows).map((G,V)=>({...G,value:d.jsx(In,{value:G.value,component:G.component,formData:H.formData,placeholder:C},`${J}_${V}`)})),$=w.CollectionPage.mergePages(n).map((H,J)=>{const K=O(H,J);return K?.length?{...H,rows:K}:null}).filter(H=>!!H);I($)},[n,o,I]);const g=i?0:ms,v=O=>O===E.length-1;N.useEffect(()=>{(()=>{const j=Array.isArray(h)?h.map($=>$.pageId):[];b(j)})()},[b,h]);const L=F.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:f,groups:h,errors:P,sections:p,type:S});if(L)return L;const U=O=>y.includes(O),x=O=>h?.find(j=>j.pageId===O),B=(O,j)=>{if(!O.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(T.SmallHeading,{children:w.FormPage.getTitle(O.title,O.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:w.FormPage.getTitle(O.title,O.formData)})]});const $=Mt(!1,O,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(T.SmallHeading,{children:w.FormPage.getTitle(O.title,O.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:w.FormPage.getTitle(O.title,O.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Nn,{row:{action:$}})})]})},R=()=>Array.from(new Set(P.map(j=>j.id))).map(j=>P.find($=>$.id===j));return d.jsxs("div",{className:_d,children:[e&&!a&&d.jsx(T.Heading,{size:t,children:e},"heading"),P&&P.length>0&&d.jsx(T.ErrorSummary,{errors:R()}),S===ne.TASK_CYA&&E.length>0&&p&&p.map(O=>O.tasks.filter(j=>j.state!==q.TYPES.SKIPPED).map((j,$)=>{const H=E.filter(J=>j.pages.some(K=>K===J.name));return d.jsxs(N.Fragment,{children:[d.jsx(T.MediumHeading,{children:H.length>0&&(j.displayName||j.name)}),H.map((J,K)=>{const G=U(J.id)||u,V=!i&&J.title&&!U(J.id);return d.jsxs(N.Fragment,{children:[V&&B(J,"s"),d.jsx(fn,{rows:J.rows,classModifiers:c,noChangeAction:G,noGroupAction:f,isGroup:U(J.id)})]},K)})]},$)})),S!==ne.TASK_CYA&&E&&E.map((O,j,$)=>{const H=!A||O.collection?O.rows:O.rows.filter(oe=>oe?.value?.props?.value);if(H.length===0)return null;const J=!i&&O.title&&!U(O.id),K=v(j)||U($[j].id)||$.length>j+1&&U($[j+1].id)?ms:g,G=U(O.id)?x(O.id):void 0,V=`govuk-!-margin-bottom-${K}`,me=U(O.id)||u;return d.jsxs(N.Fragment,{children:[J&&B(O,"m"),G&&d.jsx("div",{className:"group-title",children:d.jsx(T.MediumHeading,{children:G.title||w.FormPage.getTitle(O.title,O.formData)})}),d.jsx(fn,{className:V,rows:H,classModifiers:c,noChangeAction:me,noGroupAction:f,isGroup:U(O.id)})]},j)}),!l&&d.jsx(On,{actions:s?.filter(O=>w.Component.show(O,n[n.length-1].formData)),onAction:O=>r(O)})]})},xd=pr,Od=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=xd,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=N.useState({});let f=w.CollectionPage.getData(e.collection.name,e.formData)||[];const h=e.collection.name.split(".").pop();let p=w.CollectionPage.getActiveIndex(e.collection.name,e.formData);const S=e,A=({target:P})=>{w.CollectionPage.setData(S.collection.name,P.value,e.formData),f=P.value;const F=e.collection.name.split(".").shift();u(g=>({...g,[F]:w.CollectionPage.getData(F,e.formData)}))},C=({target:P})=>{S.formData[P.name]=P.value,u(F=>({...F,[P.name]:P.value}))},E=P=>{A({target:{value:P}}),typeof n=="function"&&n(e.formData)},I=P=>{p=f.length,C({target:{name:`${h}ActiveId`,value:P}})},y=P=>{s(P,c,{})},b=({target:P})=>{if(p===null){const F=Dt.v4();I(F),E([...f,{id:F,[P.name]:P.value}])}else(!Array.isArray(P.value)||(Array.isArray(P.value)&&P.value.length)>0)&&E([...f.slice(0,p),{...f[p],[P.name]:P.value},...f.slice(p+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(Rn,{page:{...e,formData:{...e.formData,...f[p],[`${h}ActiveIndex`]:p,[`${h}NumberedIndex`]:typeof p=="number"?p+1:null},components:e.components.map(P=>({...P,pageCollection:{...e.collection}}))},pages:t,onAction:y,onWrapperChange:b,onTopLevelChange:C,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},Rd="hods-task-list",Nd=({state:e=q.TYPES.CANNOT_START_YET})=>{const t=T.Utils.classBuilder(Rd,void 0,void 0),n=q.DETAILS[e]||q.DETAILS.cannotStartYet;return d.jsx(T.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Dd="hods-task-list",vd=({task:e,onClick:t})=>{const n=T.Utils.classBuilder(Dd,void 0,void 0),[s,r]=N.useState(e.state!==q.TYPES.CANNOT_START_YET),[o,i]=N.useState(e.state);N.useEffect(()=>{r(e.state!==q.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(T.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(Nd,{state:o})]})},Ld="hods-task-list",Fd="Incomplete form",Ud=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=Fd,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=Ld,classModifiers:u=[],className:f="",formData:h={},annotations:p=[],...S})=>{const A=T.Utils.classBuilder(c,u,f),C=T.Utils.cleanHtmlAttributes(S),[E,I]=i.filter(g=>!g.skipped).reduce((g,v)=>[g[0]+(v.tasks?.filter(L=>L.state===q.TYPES.COMPLETE).length??0),g[1]+(v.tasks?.filter(L=>L.state!==q.TYPES.SKIPPED).length??0)],[0,0]),y=`${e}Notes`,{title:b,text:P}=s&&s||{},F=g=>{typeof a=="function"&&a(g)};return d.jsxs("div",{...C,id:e,className:A(),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}`})]}),p.length>0&&p.map(g=>d.jsxs("div",{className:A("annotation"),children:[d.jsx("p",{className:`${A("annotation-key")} govuk-body`,children:T.Utils.interpolateString(g.key,h)}),d.jsx("p",{className:`${A("annotation-value")} govuk-body`,children:T.Utils.interpolateString(g.value,h)})]},g.key)),o&&I!==E&&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 ${E} of ${I} sections`}),b&&P&&xe(s,h)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:T.Utils.interpolateString(b,h)})}),d.jsx(T.TextArea,{id:y,fieldId:y,readOnly:!0,value:T.Utils.interpolateString(P,h)})]}),i.filter(g=>!g.skipped).map((g,v)=>d.jsxs(N.Fragment,{children:[d.jsxs("h2",{className:A("section"),children:[i.length>1?`${v+1}. `:" ",g.name]}),g.label&&d.jsx(T.Hint,{children:g.label}),d.jsx("ol",{className:A("items"),children:g.tasks.filter(L=>L.state!==q.TYPES.SKIPPED).map(L=>d.jsx(vd,{task:L,onClick:F},`${g.name}-${L.name}`))})]},`${g.name}`))]})},Wr=(e,t)=>e?.page||t,jd=(e,t,n)=>{const s=Wr(e.action,e.pageId);s!==t&&n(s)},Md=(e,t,n,s=void 0)=>{const r=Wr(e,t);r!==t&&n(r,s)},kd=(e,t)=>{t(e)},Ce={cyaAction:jd,navigate:Md,submissionError:kd},Bd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,$d=(e,t)=>t(e).length===0,Yd=["radios","checkboxes"],Hd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Vd(e,t){const n=[];return e?.data?.options?.forEach(s=>{!ot(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const zr=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!Yd.includes(s.type))return;Vd(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Hd(t.collection.name,t.formData),...n};const s=ze(t.collection.name,n);if(s){const r=$t(t.collection.name,n),o=s.map(i=>i.id===r?zr(i,{...t,collection:void 0}):i);vn(t.collection.name,o,n)}}return n},qd=(e,t,n)=>{if(e===re.HUB&&n===Se.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}}},Xr=(e,t,n)=>{if(e)return e===re.HUB?n===Se.CYA||n===Se.TASK?void 0:n:t.find(s=>s.id===e)},Gd=(e,t,n)=>({pageId:e,cya:qd(e,t,n),page:Xr(e,t,n)}),ps=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Kd=(e,t,n)=>e.page?.type===re.PARTIAL_CYA?ps(n||t,e.pageId):n||t,Es=(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=>{ft.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||re.HUB},Jr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!ft.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Wd=(e,t,n)=>Jr(e,t,n)||re.CYA,zd=e=>e.length>0?e[0].id:void 0,hn=(e,t,n,s,r)=>{if(s){if(s.type===z.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===z.TYPES.SAVE_AND_RETURN)return e===ne.HUB?re.HUB:void 0}switch(e){case ne.HUB:return Es(s);case ne.CYA:return Wd(t,n,r);case ne.FORM_WITH_TASK:case ne.TASK:return Es(s,n,t,r,e);case ne.WIZARD:return Jr(t,n,r);default:return zd(t)}},Xd=(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===z.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:hn(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 f=u.pages[u.pages.length-1];(f===n||f.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===z.TYPES.SAVE_AND_RETURN?{page:n}:{page:hn(e,t,n,s,r)}},Jd=({complete:e,currentPage:t},n=q.TYPES.NOT_STARTED)=>e?q.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?q.TYPES.IN_PROGRESS:n,Qd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===q.TYPES.SKIPPED?s:s&&o?.complete},!0),Qr=(e,t)=>{const n=e[t-1].state;return n===q.TYPES.COMPLETE?!0:n===q.TYPES.SKIPPED?t-1===0?!0:Qr(e,t-1):!1},Zd=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return Jd(s[e.name],e.state);if(r)return e.depends_on&&!Qd(s,e.depends_on,e.ignoreSkipped)?q.TYPES.CANNOT_START_YET:q.TYPES.NOT_STARTED;let i=o;return t&&(i=Qr(n,t)),i?q.TYPES.NOT_STARTED:q.TYPES.CANNOT_START_YET},ef=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==q.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Zd(l,i,r,t,n,s)}),r},Zr=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===q.TYPES.COMPLETE?!0:n===q.TYPES.SKIPPED?t-1===0?!0:Zr(e,t-1):!1},tf=(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:q.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:q.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===q.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:q.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||Zr(r,l);a.tasks=ef(a,o,n,c)}),r},nf=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},$e=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)$e(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]]},eo=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},jn=(e,t)=>{const n=eo(e);return n?`${n}.${t}`:t},sf=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)}},rf=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},of=(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},tt=(e,t)=>e.show_when?e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t):!0,to=(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},lf=(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)}},mn=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):mn(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]):mn(e[t])})},no=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},af=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;$e(e,t),no(n,r=>{const o=jn(t,r.fieldId);s[o]>1?s[o]-=1:$e(e,o)})}},cf=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&lf(r,n,s),r.preserveInPayload)return;$e(n,r.fieldId),no(r,o=>{const i=jn(r.fieldId,o.fieldId);e.has(i)||$e(n,i)})}})},As=e=>Array.isArray(e)?e:[e],uf=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,f)=>{u.fieldId&&(f=f?`${f}.${u.fieldId}`:u.fieldId,o[f]=(o[f]||0)+1,u.path=f,c.show_when&&(u.show_when=u.show_when?[...As(c.show_when),...As(u.show_when)]:c.show_when),nf(f,u,r),u.components?u.components.forEach(h=>{a(c,h,f)}):u?.data?.options&&u?.data?.options?.forEach(h=>{if(h.nested){const p=!ot(se(s,f),h),S=h.show_when;h.nested.forEach(A=>{p&&i.push(jn(f,A.fieldId)),S&&(A.show_when=S),a(c,A,eo(f))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const f=to(u,t,n);a(c,f,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:$e(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},df=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=rf(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},ff=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(h=>{const p=of(h,t);if(p)p.forEach(S=>{a.has(S)||i(a,S,u)});else{const S=/([a-zA-Z_$][\w$]*)\[\d+\]/,A=h.match(S);if(A){const C=A[1],E=s.get(C);E&&E.childPages?.forEach(I=>{if(I.show_when){const y=JSON.stringify(I.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=Fe(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&gt.assertOptions(s,{silentJSONParsing:ue.transitional(ue.boolean),forcedJSONParsing:ue.transitional(ue.boolean),clarifyTimeoutError:ue.transitional(ue.boolean),legacyInterceptorReqResOrdering:ue.transitional(ue.boolean),advertiseZstdAcceptEncoding:ue.transitional(ue.boolean),validateStatusUndefinedResolves:ue.transitional(ue.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:gt.assertOptions(r,{encode:ue.function,serialize:ue.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),gt.assertOptions(n,{baseUrl:ue.spelling("baseURL"),withXsrfToken:ue.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"],S=>{delete o[S]}),n.headers=fe.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;a=a&&A.synchronous;const C=n.transitional||Cn;C&&C.legacyInterceptorReqResOrdering?l.unshift(A.fulfilled,A.rejected):l.push(A.fulfilled,A.rejected)});const c=[];this.interceptors.response.forEach(function(A){c.push(A.fulfilled,A.rejected)});let u,f=0,h;if(!a){const S=[ss.bind(this),void 0];for(S.unshift(...l),S.push(...c),h=S.length,u=Promise.resolve(n);f<h;)u=u.then(S[f++],S[f++]);return u}h=l.length;let p=n;for(;f<h;){const S=l[f++],A=l[f++];try{p=S(p)}catch(C){A.call(this,C);break}}try{u=ss.call(this,p)}catch(S){return Promise.reject(S)}for(f=0,h=c.length;f<h;)u=u.then(c[f++],c[f++]);return u}getUri(t){t=Fe(this.defaults,t);const n=rr(t.baseURL,t.url,t.allowAbsoluteUrls,t);return Zs(n,t.params,t.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(t){De.prototype[t]=function(n,s){return this.request(Fe(s||{},{method:t,url:n,data:s&&m.hasOwnProp(s,"data")?s.data:void 0}))}});m.forEach(["post","put","patch","query"],function(t){function n(s){return function(o,i,l){return this.request(Fe(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}De.prototype[t]=n(),t!=="query"&&(De.prototype[t+"Form"]=n(!0))});let Pa=class ar{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 ut(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 ar(function(r){t=r}),cancel:t}}};function Ia(e){return function(n){return e.apply(null,n)}}function xa(e){return m.isObject(e)&&e.isAxiosError===!0}const ln={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(ln).forEach(([e,t])=>{ln[t]=e});function cr(e){const t=new De(e),n=ks(De.prototype.request,t);return m.extend(n,De.prototype,t,{allOwnKeys:!0}),m.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return cr(Fe(e,r))},n}const Z=cr(ct);Z.Axios=De;Z.CanceledError=ut;Z.CancelToken=Pa;Z.isCancel=nr;Z.VERSION=bn;Z.toFormData=Lt;Z.AxiosError=D;Z.Cancel=Z.CanceledError;Z.all=function(t){return Promise.all(t)};Z.spread=Ia;Z.isAxiosError=xa;Z.mergeConfig=Fe;Z.AxiosHeaders=fe;Z.formToJSON=e=>tr(m.isHTMLForm(e)?new FormData(e):e);Z.getAdapter=lr.getAdapter;Z.HttpStatusCode=ln;Z.default=Z;const{Axios:Cf,AxiosError:gf,CanceledError:bf,isCancel:wf,CancelToken:_f,VERSION:Pf,all:If,Cancel:xf,isAxiosError:Of,spread:Rf,toFormData:Nf,AxiosHeaders:Df,HttpStatusCode:vf,formToJSON:Lf,getAdapter:Ff,mergeConfig:Uf,create:jf}=Z,de={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=>{}},os=Object.keys(de),ur=N.createContext(),dr=({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]=N.useState({onAction:e?.onAction||de.onAction,onChange:e?.onChange||de.onChange,onFormComplete:e?.onFormComplete||de.onFormComplete,onFormLoad:e?.onFormLoad||de.onFormLoad,onGetComponent:e?.onGetComponent||de.onGetComponent,onGetCYA:e?.onGetCYA||de.onGetCYA,onGetCYARows:e?.onGetCYARows||de.onGetCYARows,onGoingBack:e?.onGoingBack||de.onGoingBack,onPageChange:e?.onPageChange||de.onPageChange,onRequest:e?.onRequest||de.onRequest,onSubmit:e?.onSubmit||de.onSubmit,onValidate:e?.onValidate||de.onValidate,onCancel:e?.onCancel||de.onCancel}),r=(i,l)=>{os.includes(i)&&s(a=>({...a,[i]:l||de[i]}))},o=i=>{os.includes(i)&&s(l=>({...l,[i]:de[i]}))};return d.jsx(ur,{value:{hooks:n,addHook:r,removeHook:o},children:t})},Oe=()=>N.useContext(ur),Oa=()=>{const{hooks:e}=Oe(),[t,n]=N.useState({});return N.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},_n=N.createContext(),fr=({children:e=null})=>{const{hooks:t}=Oe(),[n,s]=N.useState([]),[r,o]=N.useState([]),i=h=>{h!==void 0&&o(p=>[...p,...h].filter(S=>!!S))},l=h=>{typeof h=="function"&&o(p=>p.filter(S=>!h(S)))},a=()=>{r.length&&o([])},c=h=>{h!==void 0&&s(p=>[...p,...h].filter(S=>!!S))},u=()=>{o([]),s([])},f={page:h=>{const p=w.Validate.page(h,r),S=t.onValidate(h,p);return s(S),S},pages:h=>{const p=h.map(A=>w.Validate.page(A,r)),S=h.flatMap((A,C)=>t.onValidate(A,p[C]));return s(S),S}};return d.jsx(_n,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:f},children:e})},Ge=()=>N.useContext(_n),Gt={},Kt={},Ra="idle",Na="fetching",hr="fetched",mr="error",Da=(e,t=!0)=>{const n=Oa(),s=N.useRef(Z.CancelToken.source()),[r,o]=N.useState(Ra),[i,l]=N.useState(null),[a,c]=N.useState(null),u=()=>{s.current&&s.current.cancel()};return N.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(Na);let h;if(t&&Gt[e])h=Gt[e];else{if(t&&Kt[e])throw Kt[e];h=(await n.get(e,{cancelToken:s.current.token}).catch(S=>{throw l(S),S})).data,t&&(Gt[e]=h)}c(h),o(hr)}catch(h){t&&(Kt[e]=h),l(h),c(null),o(mr)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},va="loading",bt="complete",La=e=>{const t=e.data;if(t&&!t.options||t?.url)return T.Utils.interpolateString(t.url,e.formData)},Fa=(e,t)=>{const n=La({...e,formData:t}),{status:s,data:r}=Da(n,e?.data?.useCache),[o,i]=N.useState([]),[l,a]=N.useState(va);return N.useEffect(()=>{n?s===hr?(r&&i(he.refData.toOptions(r.data||r,e.item)),a(bt)):s===mr&&(i([]),a(bt)):(e.data&&e.data.options&&i(he.refData.toOptions(e.data.options,e.item)),a(bt))},[e.id,s,r,n]),{data:o,status:l}},nt=(e,t)=>{const n=ee(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(T.FormGroup,{...n,onChange:null,children:t})},Pn=(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 Pn(e,u,n,s,r);const f=w.Validate.page(u);return s.onValidate(u,f)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},In=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Ke,{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(T.VisuallyHidden,{children:"No answer"}),Ua="Continue",an=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?z.DEFAULTS[e]:e,r=z.DEFAULTS[e.type];return s?d.jsx(T.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||Ua}):null},ja="hods-form-confirmation",Ma="Are you sure?",ka="Confirm",Ba=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=T.Utils.classBuilder(ja,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||Ma}),s,d.jsx(T.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||ka}),d.jsx(T.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},xn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===P.CONTAINER?xn(t):dt.editable(t)?t:null).filter(t=>!!t):[],$a=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===P.CONTAINER?cn(r):(n.type===P.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===P.CONTAINER&&(r.data.options[i].nested[a]=cn(l))})}),r)})},cn=e=>{if(e){const t=$a(e);return{...e,components:t}}return e},Ya=(e,t)=>e.some(n=>dt.show(n,t)),Ha=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=xn(e);return n.length>0?Ya(n,t):!0},Ut={editableComponents:xn,setup:cn,show:Ha},Va=(e,t)=>e.some(n=>xe(n,t)),jt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=Ut.editableComponents(e);return n.length>0?Va(n,t):!0},qa=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!jt(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(f=>f.id===a)});return}const c=l.components.find(f=>f.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){Me(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},On=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(T.ButtonGroup,{children:e.map((n,s)=>d.jsx(an,{action:n,onAction:t},s))}),Ga=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?le.meetsOne(t.runWhen?.constraint,e.formData):!1},pr="hods-form__page",Rn=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=pr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:f})=>{const[h,p]=N.useState({}),{errors:S,validate:A}=Ge(),[C,E]=N.useState({}),[I,y]=N.useState(!1),b=N.useMemo(()=>Ga(e),[e]);N.useEffect(()=>{y(!0)},[]),N.useEffect(()=>{I&&b&&A.page(e)},[f,I]);const _=({target:x})=>{const B=e,{value:R}=x;R?(B.formData[x.name]=R,p(O=>({...O,[x.name]:R})),E(O=>({...O,[x.component]:x.label}))):(delete B.formData[x.name],p(O=>{const{[x.name]:j,...$}=O;return $}),E(O=>{const{[x.component]:j,...$}=O;return $})),typeof o=="function"&&o(e.formData)};N.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=S.length>0?"Error: "+x:x},[S]);const F=w.classBuilder(l,a,c),g=e;g.actions=g.actions?.map(x=>x.label?{...x,label:w.interpolateString(x.label,g.formData)}:x),g.formData=w.Operate.runPageOperations(g,{...g.formData,...h},s||_);const v=e.title?d.jsx(T.Heading,{size:e.titleSize,children:w.FormPage.getTitle(e.title,e.formData)}):d.jsx(T.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),L=e.components.filter(x=>w.Component.show(x,e.formData)).map((x,B)=>d.jsx(Ke,{component:x,onAction:R=>n(R,h,C),onChange:s||_,onTopLevelChange:r||_,value:e.formData[x.fieldId]||h[x.fieldId],formData:e.formData,pages:t,submitting:u},B));let U=null;return b&&S?.length>0?U=[{error:e?.customValidation?.[0]?.message}]:S?.length>0&&!b&&(U=S),d.jsxs("div",{className:F(),children:[U&&d.jsx(T.ErrorSummary,{errors:U,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:v}),L]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[v,L]}),d.jsx(On,{actions:e.actions?.filter(x=>w.Component.show(x,e.formData)),onAction:x=>n(x,h,C)})]},e.id)},is="hods-form-banner-strip",Er=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=w.classBuilder(is,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(T.Markup,{content:w.interpolateString(c,n)})},a)}return d.jsx(T.Tag,{classBlock:`${is}__tag`,classModifiers:i.classModifiers,text:w.interpolateString(i.text,n)},a)})})},Ka=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{}},Nn=({row:e})=>{const[t,n]=N.useState({});return N.useEffect(()=>{n(Ka(e))},[e,n]),e.action?d.jsxs(T.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(T.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},Ar=({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(Nn,{row:e})})]}),yr=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(T.SmallHeading,{children:e})}),wt=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=Bt(o,t);return t.type==="title"?d.jsx(yr,{title:t.key,classes:n}):d.jsx(Ar,{row:{key:i.key,value:d.jsx(In,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Wa="govuk-summary-card",za="govuk-summary-list",At="Item",yt="Change",ls="Delete",Xa="warning",Ja=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=T.Utils.classBuilder(Wa,i,n.className),c=T.Utils.classBuilder(za,[]);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:T.Utils.interpolateString(n.title||At,{...t,index:t.index+1})}),n.banners&&d.jsx(Er,{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(T.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||yt} ${n.title||At}`,{...t,index:t.index+1}),children:n.changeAction?.label||yt}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||yt} ${n.title||At}`,{...t,index:t.index+1}),children:n.changeAction?.label||yt})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||Xa,"aria-label":T.Utils.interpolateString(`${n.deleteAction?.label||ls} ${n.title||At}`,{...t,index:t.index+1}),children:n.deleteAction.label||ls})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const f=u.components.map(h=>w.Component.elevateNested([h],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(h=>{const S=h.columns.filter(A=>le.meetsAll(A,{...u.formData,...t})).flatMap(A=>A.fields||[]);return S.length?S.flatMap(A=>{const C=f.find(E=>E.fieldId===A);return C?wt(u,C,c,t,l):null}):null})})})})]})},Qa=({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(T.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||cs,"aria-label":w.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||as},e))}):d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||cs,"aria-label":w.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||as}),Za=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},Mt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Za(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},Sr=[P.ALERT,P.COLLECTION_SUMMARY,P.DETAILS,P.HEADING,P.HTML,P.INSET_TEXT],xt=(e,t)=>{if(!e||Sr.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===P.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===P.CONTAINER?Ut.show(e,t):dt.show(e,t)},Tr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>Sr.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}`}})}),ec=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:Mt(!1,e,t)}],tc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:P.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),nc=(e,t,n,s,r)=>{const o={...He,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},Dn=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&xt(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=tc(t,o,l,a);return c=Tr(c),[nc(t,o,e.id,l,a),...We(e,c,o,s,r)??[]]}).filter(o=>!!o):ec(e,s),sc="hods-form-summary-card-details",Cr=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=w.classBuilder(sc,r),a=N.useMemo(()=>t.map(u=>e.childPages.find(f=>f.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,f,h)=>{let p=0;return u.flatMap((S,A)=>{let C=0;const E=S.fields?.flatMap(y=>f.filter(_=>_.fieldId===y).map(_=>{if(!_||!xe(_,{...h.formData,...s}))return null;if(_.type===P.CONTAINER){const F=We(h,_,s);return C+=1,d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:F.map(g=>{const v={...s,[g.fieldId]:s[_.fieldId]?.[g.fieldId]};return wt(h,{...g,label:g.key},l,v,i)})},y)}if(_.type===P.COLLECTION){const F=Dn({...h,formData:{...h.formData,...s}},_,s[_.id]);C+=1;let g=0;return d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:F.map(v=>{const L={...s,[v.fieldId]:s[_.fieldId]?.[v.fieldId]},U=wt(h,{...v,label:v.key},l,L,i);return v.type==="title"&&(g+=1,g>1)?d.jsx("div",{style:{marginTop:"40px"},children:U}):U})},y)}return C+=1,d.jsx("div",{className:l("field"),style:{"--column":p+1,"--row":C},role:"list",children:wt(h,_,l,s,i)},y)})).filter(y=>!!y);return!(A===u.length-1)&&E.length!==0?(p+=2,[...E,d.jsx("div",{className:l("divider"),style:{"--column":p}},`divider${p}`)]):E}).filter(S=>!!S)};return e?.childPages?.filter(u=>w.FormPage.show(u,{...n,...s})).map(u=>{const f=w.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(h=>{if(h.show_when&&!w.Condition.meetsAll(h.show_when,{...n,...s}))return null;if(h.type==="childCollection"){const S=a.find(C=>C.collection.name===h.collectionName),A=s[h.collectionName.split(".").pop()]||[];return S&&A.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:h.title}),A.map(C=>d.jsx(Cr,{masterPage:S,childMasterPages:[],formData:{...n,...s,...C},entryData:C,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const p=h.columns.filter(S=>le.meetsAll(S,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:w.FormPage.getConditionalText(h.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":p.length-1},children:c(p,f,u)})]},h.title)})}).filter(u=>!!u)||null},rc="hods-form-summary-card",as="Change",oc="Delete",ic="Quick Edit",lc="Duplicate",ac="Full details",cs="secondary",us=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:f,hideDetails:h=!1})=>{const[p,S]=N.useState(!1),A=T.Utils.classBuilder(rc,s,n.className),C=N.useMemo(()=>n.quickEdit?qa(f,u,t):null,[f,n,u,t,p]),{addErrors:E,resetQuickEditErrors:I,clearTopLevelErrorsForCard:y,validate:b}=Ge(),{hooks:_}=Oe(),F=async(g,v)=>{if(g.type==="cancel"&&(S(L=>!L),I?.()),g.type==="save"&&typeof l=="function"){const L={...C.formData,...v,[`${a}ActiveId`]:t.id},U=b.page({...C,formData:L});if(U.length)return;let x;await _.onSubmit("quickEdit",L,()=>{},R=>{x=R}),x&&E(x);const B=U.concat(x);if(B.length===0||B.length===1&&B[0]===void 0){y();const R=w.CollectionPage.getData(a,u),{isDuplicate:O,...j}=R[t.index];R[t.index]={...j,...v},l({target:{name:a,value:R}}),S($=>!$)}}};return n.listView?d.jsx(Ja,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:f,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:A(),id:e,children:[d.jsxs("div",{className:A("header"),children:[d.jsxs("div",{className:A("header-content"),children:[n.banners&&d.jsx(Er,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:A("header-content-title"),children:w.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:A("header-content-detail"),children:w.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:A("header-actions"),children:[n.quickEdit&&d.jsx(T.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>S(g=>!g),classModifiers:"primary",disabled:p,name:"QuickEdit",autoFocus:n.focusOn,children:ic}),n.changeAction&&typeof r=="function"&&d.jsx(Qa,{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(T.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||oc}),n.duplicateAction&&typeof i=="function"&&d.jsx(T.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||lc})]})]}),p&&C&&d.jsx(Rn,{page:C,onAction:(g,v)=>F(g,v),className:A("editpage")}),d.jsx("div",{className:A("body"),children:!h&&d.jsx(T.Details,{summary:n.detailsTitle||ac,className:"details",children:d.jsx(Cr,{masterPage:f,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},cc=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=Oe(),o=t.filter(f=>f.entryId===e)||[],[i,l]=N.useState(null),a=()=>{l(null)},c=f=>{l(h=>(h??[]).concat(f))},u={page:f=>{const h=w.Validate.page(f),p=r.onValidate(f,h);return l(p),p}};return d.jsx(_n,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},ds="Add",uc=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=Oe(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:f,dequeueErrors:h}=Ge(),[p,S]=N.useState(null),A=N.useMemo(()=>w.CollectionPage.getData(e.collectionName,t)||[],[t]),C=Array.isArray(A)&&A.length>0?A.reduce((v,L)=>L.isDuplicate&&(!v||L.id>v.id)?L:v,null):null,E=N.useMemo(()=>{const v=e.collectionName.split(".");let L=w.CollectionPage.mergePages(o||[])||[];return v.reduce((U,x,B)=>{const R=B===0?`${U}${x}`:`${U}.${x}`;return B===v.length-1?L?.find(O=>O.collection?.name===R)||null:(L=L.find(O=>O.collection?.name===R)?.childPages||null,R)},"")},[o]),I=N.useMemo(()=>e.card.listView?E.childPages?.reduce((L,U)=>{const x=it(U.components,{...t,...p});return L.concat(x)},[])||[]:[],[E,t,p,e.card.listView]),y=()=>{u.length>0&&h(L=>L.raisedBy===e.id);const v=Pn(e,E,t,i);v.length>0&&f(v)};N.useEffect(()=>{Array.isArray(A)&&A.length>0&&y()},[A]);const b=(v,L)=>{if(typeof n=="function"){const U=[...A],x=A.findIndex(O=>O.id===L),{isDuplicate:B,...R}=A[x];U[x]={...R},n({type:St.SAVE_AND_NAVIGATE,page:v,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:L},{field:e.collectionName,value:U,isCollection:!0}]})}},_=v=>{w.CollectionPage.duplicateEntry(e.collectionName,t,v.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const L=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:L,value:w.CollectionPage.getData(L,t)}}),y())},F=()=>{if(!p)return;w.CollectionPage.removeEntry(e.collectionName,t,p.id);const v=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:v,value:w.CollectionPage.getData(v,t)}}),S(null),y()},g=v=>{const L=I.find(x=>x.fieldId===v);if(!L)return null;const U=Bt({...E,formData:{...t,...p}},L);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(In,{value:U.value,component:U.component,formData:U.formData})},v)};return d.jsxs("div",{id:e.fieldId,children:[p&&d.jsx(Ba,{id:`${e.fieldId}.confirmation`,message:w.interpolateString(e.confirmation?.message,{...p,index:p.index+1})||null,confirmLabel:w.interpolateString(e.confirmation?.label,p)||null,onConfirm:F,onCancel:()=>S(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(g)}):d.jsx(us,{id:`${e.fieldId}.confirmationChild`,entryData:p,config:e.card?{...e.card,quickEdit:null}:{},masterPage:E,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(an,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||ds,{documents:A}),page:e.addButton.page,type:St.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:A.map((v,L)=>{const U=l.filter(R=>R.entryId===v.id).length>0,x={...e.card,...v.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...U&&e.errorCard?e.errorCard:{},focusOn:C?.id===v.id},B=`${e.fieldId}.summaryCard${v.id}`;return d.jsx("li",{children:d.jsx(cc,{entryId:v.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const R=l.filter(O=>O.entryId!==v.id);c(),a(R)},children:d.jsx(us,{id:B,entryData:{...v,index:L},masterPage:E,config:x||{},onFullEdit:b,onDuplicate:_,onDelete:()=>S({...v,index:L}),onQuickEdit:R=>(y(),s(R)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:v.id===p?.id?["deleting-summary-card"]:[""],inError:l.filter(R=>R.entryId===v.id).length>0},B)})})})}),e.card.listView&&e.addButton&&d.jsx(an,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||ds,{documents:A}),page:e.addButton.page,type:St.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},dc="hods-form-collection",fc=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=N.useState(t),a=A=>{l(A),typeof s=="function"&&s({target:{name:e.fieldId,value:A}})},c=({target:A})=>{if(typeof s=="function")if(A.name===w.Meta.name)s({target:A});else{const C=i.findIndex(E=>E.id===A.name);a([...i.slice(0,C),A.value,...i.slice(C+1)])}},u=async()=>{a([...i,{id:Dt.v4()}])},f=async A=>{a(i.filter(C=>C.id!==A.id))},h=A=>A.initial&&!i.length?A.initial:A.add;N.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const A=i[i.length-1]?.id,E=document.getElementById(A)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');E&&E.length>0&&E[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),N.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const p={...He,...e.labels},S=w.classBuilder(dc,[],e.className);return d.jsxs("div",{className:S(),id:e.id,children:[e.label&&d.jsx(T.Label,{id:e.id,required:e.required,className:S("title"),children:e.label}),Array.isArray(i)&&i.map((A,C)=>{const E=`${e.full_path||e.fieldId}[${C}]`,I=(e.countOffset||0)+C+1,y=w.interpolateString(p.item,{...A,index:I}),b=w.interpolateString(p.remove,{...A,index:I}),_=e.disableAddAndRemove||C===0&&e.minimumEntries?"":e.removeLocation??"start",F=C!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${S("item")}`,style:F,children:[d.jsxs(T.Label,{id:A.id,required:!0,className:S("item-title"),children:[y,_==="start"&&d.jsx(T.Button,{onClick:()=>f(A),classModifiers:"secondary",children:b})]}),d.jsx(Un,{container:{id:A.id,fieldId:A.id,type:"container",required:e.required,full_path:E,components:e.item.map(g=>{const{firstOnlyLabel:v,...L}=g;let{hint:U}=g;e.restrictHint&&C>0&&(U=void 0);let{label:x}=g;return C===0&&(x=g.firstOnlyLabel??g.label),{...L,hint:U,readonly:!!(e?.readonly||g.readonly),label:w.interpolateString(x,{...A,index:I}),full_path:`${E}.${g.fieldId}`}})},value:A,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),_==="end"&&d.jsx(T.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(T.Button,{onClick:()=>f(A),classModifiers:"secondary",children:b})})]},A.id)}),!e.disableAddAndRemove&&d.jsx(T.ButtonGroup,{children:d.jsx(T.Button,{onClick:u,classModifiers:"secondary",children:h(p)})})]})},hc=(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},mc=(e,t)=>typeof e=="string"?!!T.Utils.interpolateString(e,t):!!e,Wt=(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}}},pc=[P.RADIOS,P.CHECKBOXES,P.DATE,P.TIME],Ec=e=>e.fieldset||pc.includes(e.type),Ke=({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}=Oe(),f=Ge(),{data:h,status:p}=Fa(e,n),[S,A]=N.useState([]);N.useEffect(()=>{p===bt&&A(h)},[e,h,p]);const C=({target:y})=>typeof o=="function"?(e.type===P.EMAIL&&(y.value=y.value.trim()),e.type===P.CHECKBOXES&&Array.isArray(y.value)&&y.value.forEach(b=>{b.children&&b.nested&&(delete b.children,delete b.nested)}),y=hc(y,e,h),e.type===P.SELECT&&y.value===""&&(y.value=null,y.label=null),o({target:y}),!0):!1;if(N.useEffect(()=>{const y=w.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&y&&typeof C=="function"&&C({target:{name:e.fieldId,value:y}})},[]),e.type===P.CONTAINER){let y=d.jsx(Un,{...c,container:e,wrap:s,onChange:C,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});return e.fieldset&&(y=nt(e,y)),e.additionalValidation&&(y=nt({...e,...Wt(e,f?.errors)},y)),y}if(e.type===P.COLLECTION)return d.jsx(fc,{...c,config:e,wrap:s,onChange:C,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});if(e.type===P.COLLECTION_SUMMARY)return nt({...e,...Wt(e,f?.errors)},d.jsx(uc,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const E=y=>{let b=e.full_path||e.fieldId;if(e.pageCollection){const _=w.CollectionPage.getActiveIndex(e.pageCollection.name,n);b=`${`${e.pageCollection.name}[${_}]`}.${b}`}i({target:{name:w.Meta.name,value:w.Meta.documents.setForField(y,n,b,e.allowMultiple)}})},I=({target:y})=>{if(C({target:y})){if(e.type===P.FILE)E([y.value]);else if(e.type===P.MULTI_FILE){const b=y.value.map((_,F)=>({..._,indexInField:F}));E(b)}}};return w.Component.get({...c,...e,id:e.full_path||e.id,...Wt(e,f?.errors),fieldset:Ec(e),disabled:mc(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:S,value:t,onChange:I,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},Ac=[P.AUTOCOMPLETE,P.CALCULATION,P.CHECKBOXES,P.COLLECTION_SUMMARY,P.DATE,P.EMAIL,P.FILE,P.MULTI_FILE,P.PHONE_NUMBER,P.RADIOS,P.SELECT,P.TEXT,P.TEXT_AREA,P.TIME],gr=e=>Ac.includes(e?.type)||e?.isEditable||!1,yc="govuk-list",Sc="govuk-body",Tc=e=>{const t=ee(e),n=T.Utils.interpolateString(e.heading,e.formData),s=T.Utils.interpolateString(e.text,e.formData);return d.jsx(T.Alert,{...t,heading:n,children:s})},Cc=e=>{const t=ee(e),n=he.getAutocompleteSource(e);return d.jsx(T.Autocomplete,{...t,source:n})},gc=e=>{let t=[];he.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:br(e,s.nested)}:s);const n=ee(e);return d.jsx(T.Checkboxes,{...n,options:t})},bc=e=>{const t=he.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=ee(e,["formula"]);return d.jsx(T.TextInput,{...n,readonly:!0})},wc=e=>{const t=ee(e);return d.jsx(T.DateInput,{...t})},_c=e=>{const t=ee(e,["tagName"]),n=kt(e);return d.jsx(T.Details,{...t,children:n})},Pc=e=>{const t=ee(e);return d.jsx(T.FileUpload,{...t})},Ic=e=>{const t=ee(e);return d.jsx(T.MultiFileUpload,{...t})},xc=e=>{const t=ee(e);return d.jsx(T.Heading,{...t,children:e.content})},kt=e=>{const t=ee(e);return d.jsx(T.Markup,{...t})},Oc=e=>{const t=ee(e);return d.jsx(T.InsetText,{...t,children:e.content})},Rc=e=>{const t=ee(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=T.Utils.classBuilder(yc,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return kt({...t,className:r(),tagName:n,content:o,type:P.HTML})},Nc=e=>{const t=ee(e);return kt({className:Sc,...t,tagName:"p",type:P.HTML})},Dc=e=>{let t=[];he.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:br(e,s.nested)}:s);const n=ee(e);return d.jsx(T.Radios,{...n,options:t})},vc=e=>{const t=ee(e);return d.jsx(T.TextArea,{...t})},Lc=e=>{const t=ee(e);return d.jsx(T.TextInput,{...t})},Fc=e=>{const t=ee(e);return d.jsx(T.TimeInput,{...t})},Uc=e=>{let t=[];he.getOptions(e,s=>{t=s});const n=ee(e);return d.jsx(T.Select,{...n,options:t})},jc=e=>{const t=ee(e);return d.jsx(T.WarningText,{...t,children:e.content})},Mc=e=>{switch(e.type){case P.HTML:return kt(e);case P.HEADING:return xc(e);case P.INSET_TEXT:return Oc(e);case P.TEXT:case P.EMAIL:case P.PHONE_NUMBER:return Lc(e);case P.TEXT_AREA:return vc(e);case P.AUTOCOMPLETE:return Cc(e);case P.RADIOS:return Dc(e);case P.CHECKBOXES:return gc(e);case P.DATE:return wc(e);case P.TIME:return Fc(e);case P.FILE:return Pc(e);case P.MULTI_FILE:return Ic(e);case P.WARNING:return jc(e);case P.SELECT:return Uc(e);case P.DETAILS:return _c(e);case P.CALCULATION:return bc(e);case P.ALERT:return Tc(e);case P.PARAGRAPH:return Nc(e);case P.LIST:return Rc(e);default:return null}},kc=(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]||he.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:wr(n,!1)})):d.jsx(Ke,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},br=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!le.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:kc(e,s)},s.id));return n.length>0?n:null},wr=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=Mc(e);return s&&t&&gr(e)?nt(e,s):s},Bc=e=>e.defaultValue||e.defaultObjectValue,$c=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?W().format("DD-MM-YYYY"):n},Yc=(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},_r=(e,t)=>Bc(e)?e.type===P.DATE?$c(e):(e.defaultObjectValue?Yc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Hc={[P.COLLECTION]:[],[P.CONTAINER]:{}},Vc=(e,t)=>e&&(_r(e,t)||Hc[e.type])||"",dt={clean:ee,defaultValue:Vc,defaultValueFromConfig:_r,editable:gr,elevateNested:it,get:wr,setupContainerPaths:Tr,show:xe,wrap:nt},qc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&ot(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},Bt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],qc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:T.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:dt.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:Mt(t.readonly,e,n)}},We=(e,t,n,s,r)=>xt(t,{...e.formData,...n})?it(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>xt(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===P.CONTAINER?We(e,i,{...l,...n},s,r):i.type===P.COLLECTION?Dn(e,i,l,s,r):Bt({...e,formData:n},i,s)}):null,Gc=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},fs=(e,t,n="text")=>{if(typeof e=="string")return T.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:Me(r.show_when,t));return typeof s=="string"?T.Utils.interpolateString(s,t):T.Utils.interpolateString(s[n],t)},Kc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Wc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return z.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return z.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),Kc(n)}}).filter(t=>!!t)},zc=e=>({type:P.HTML,tagName:"p",content:e}),Xc=(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?un(l,t):l)),r},un=(e,t)=>{if(e){const n=Xc(e,t);if(n)return n}return{...e}},Pr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return zc(o);let i;return o.type===P.CONTAINER&&(o.components=o.components.map(l=>l.use?un(l,t):l)),o.use?i=un(o,t):i={...o},n?he.refData.setupUrl(i,n):i}),r=Wc(e);return Ut.setup({...e,formData:n,components:s,actions:r})},Jc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...Pr(s,t,n),index:r})):[],Ir=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:jt(e,t),ft={applyConditionalProperties:Gc,getConditionalText:fs,get:Pr,getAll:Jc,getTitle:(e,t)=>fs(e,t,"title"),show:jt,showCYA:Ir},Qc=(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},Zc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},$t=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},eu=e=>typeof e=="number"&&e>=0,xr=(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 eu(o)?(e.shift(),xr(e,t[s][o],n)):null},ze=(e,t)=>{const n=e.split(".");return xr(n,t,t)},Or=(e,t,n,s=[],r={})=>{const o=ze(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=Dt.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},tu=(e,t)=>{const n=$t(e,t);return Or(e,t,n)},nu=e=>typeof e=="number"&&e>=0,Rr=(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 nu(o)?e.length===1?o:(e.shift(),Rr(e,t[s][o],n)):null},Nr=(e,t)=>{const n=e.split(".");return Rr(n,t,t)},su=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]}),ru=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},ou=(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},Dr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=su(s);return t[s.collection.name]=o,o}return ru(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&ou(s,t)?null:s).filter(s=>!!s)},iu=(e,t,n)=>{const s=ze(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},lu=e=>typeof e=="number"&&e>=0,vn=(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=Dt.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 lu(a)?(o=o[i][a],!1):!0})},Ot={addEntry:Zc,duplicateActiveEntry:tu,duplicateEntry:Or,getActiveId:$t,getActiveIndex:Nr,getData:ze,getErrorsForCollection:Pn,mergePages:Dr,removeEntry:iu,setData:vn},au=e=>typeof e=="number"&&e>=0,cu=(e,t,n,s,r,o)=>{const i=r?.label||He.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(h=>{const[p,S]=h;c[p]=S});const u=Ot.getData(e.collection.name,c),f=u?.findIndex(h=>h.id===t.id);return au(f)&&u.splice(f,1),c})},label:T.Utils.interpolateString(i,{...t,index:s})}}},uu=(e,t,n,s,r,o={})=>{const i=r?.label||He.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(f=>{const[h,p]=f;u[h]=p}),u};n(r.page?{pageId:r.page}:l,a)},label:T.Utils.interpolateString(i,{...t,index:s})}}},du=(e,t)=>t.show_when?Me(t.show_when,e):!0,fu=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:P.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),hu=(e,t,n,s,r)=>{const o={...He,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},mu=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:T.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},pu=(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"}}),Eu=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>du(r,i)).map(i=>i.type==="remove"?cu(e,t,n,s,i,o):i.type==="change"?uu(e,t,n,s,i,o):null).filter(i=>!!i),vr=(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)},Au=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Lr(c,n,s,t,i));else if(c.collection.route&&(c=Qc(c,c.collection.route)||c),Ir(c,{...c.formData,...t})){const u=vr(c,n,i);if(c.collection.heading){const p=c.collection.heading.changeLink?u:null,S=mu(c.collection.heading,c.id,r,p,t);l=l.concat(S)}const f=fu(c,t,r,o),h=We({...c,formData:{...c.formData,...t}},f,{...c.formData,...t},u,s);l=l.concat(h)}}),l},Lr=(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 h=e.collection.collectionHeading?.changeLinkPage?vr({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(pu(e,o,e.collection.collectionHeading,h))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Me(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Me(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((p,S)=>(c=S,p.id===l))]),i.forEach(h=>{if(!h)return;r={...r,[`${o}ActiveId`]:h.id};const p=c+1,S=e.collection?.actionPosition||"top",A=`${e.collection.name}[${c}]`,C=Eu(e,h,t,p,s,r);if(!u){const E=hu(e,h,e.id,p,A);a=a.concat(E)}S==="top"&&(a=a.concat(C)),a=a.concat(Au(e.childPages,h,t,n,p,A,r)),S==="bottom"&&(a=a.concat(C)),c+=1}),a.filter(h=>!!h)},yu=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Ke,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,Su=(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?yu(t[o]):null})}),firstComponentIndex:n}},Tu=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=Su(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:Mt(!1,e,s)},insertAt:o}},Cu=(e,t,n=null)=>{if(ft.showCYA(e,e.formData)){if(e.collection)return Lr(e,t,n,e.formData);const r=it(e.components,e.formData).filter(o=>xt(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case P.CONTAINER:return We(e,o,e.formData[o.fieldId],t,n);case P.COLLECTION:return Dn(e,o,e.formData[o.fieldId],t,n);default:return Bt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=Tu(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[]},gu={getRows:Cu,getCYARowsForContainer:We},Fr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},Ur=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=Fr(e.format,s[e.fieldId]))},jr=(e,t,n)=>{e.forEach(s=>Ur(s,t,n))},Mr=(e,t,n)=>{jr(e.components,t,n)},bu=(e,t,n)=>{e.forEach(s=>Mr(s,t,n))},wu=(e,t,n)=>{const s={...t};return jr(e.components,s,n),bu(e.pages,s,n),s},_u={component:Ur,data:Fr,form:wu,page:Mr},Pu=(e,t,n,s)=>{if(e===ne.HUB&&t){if(t.format===Se.CYA)return Se.CYA;if(t.components)return ft.get(t,n,s)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return Se.TASK},Iu={get:Pu},Ln="meta",Fn="documents",dn=e=>e?.[Ln]?.[Fn]||[],xu=(e,t,n,s)=>{const r=s?dn(t):dn(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Ln]:void 0,[Fn]:r}},Ou={setForField:xu,get:dn,name:Fn},Ru={documents:Ou,name:Ln},Nu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return!!se(t,n)}return!1},zt=(e,t)=>{if(e?.value)return e.value;const n=T.Utils.interpolateString(e?.field,t);return se(t,n)},Du=(e,t)=>{if(!e||!t)return null;const n=T.Utils.interpolateString(e.target,t),s=se(t,n),r=zt(e,t),o=zt(e.cutoff,t),i=zt(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},vu=(e,t,n)=>{let s;if(e?.field){const r=T.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}})},Lu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return se(t,n)||null}return e?.value||null},Fu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},Uu=(e,t)=>{if(e?.condition){const n=e,s=T.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},ju=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=T.Utils.interpolateString(s,t),o=se(t,r);return o?(n=o,!0):!1}),n||(e.fallback?T.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},Mu=(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=Nr(l,t);s+=`${l}[${a}]`}else s+=i});const r=T.Utils.interpolateString(s,t);return se(t,r)?.length||0},ku=(e,t)=>{const n=T.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},Bu={checkValueIsTruthy:Nu,getIndexOfMatchingValueIn:Du,doesContainValue:ku,persistValueInFormData:vu,setValueInFormData:Lu,deleteValueInFormData:Fu,getLength:Mu,getFirstOf:ju},$u=(e,t,n)=>{const s=Bu[e.function];if(typeof s=="function")return s(e,t,n)},Yu=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(Uu(s.run_when,t)){const r=$u(s,t,n);if(s.output){const o=T.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");Fs(t,o,r)}}}),t),Hu={runPageOperations:Yu},Vu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),qu=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},Gu=e=>/^-?\d+$/.test(e),Rt=e=>Gu(e)?e.padStart(2,"0"):"",Pe=e=>{const[t,n,s]=e.split("-");return`${Rt(t)}-${Rt(n)}-${s}`},kr=e=>{const[t,n]=e.split(":");return`${Rt(t)}:${Rt(n)}`},be="DD-MM-YYYY";W.extend(Ye);const Ku=(e,t)=>{const n=t.date?W(Pe(t.date),be):W().add(t.value,t.unit);return W(Pe(e),be).isAfter(n)};W.extend(Ye);const Wu=(e,t)=>{const n=t.date?W(Pe(t.date),be):W().add(t.value,t.unit);return W(Pe(e),be).isBefore(n)};W.extend(Ye);const zu=(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||rt(s,e[n.fieldId],e[n.fieldId])||rt(r,e[n.fieldId],e[n.fieldId]))return!0;const l=Pe(e[n.fieldId]?.[t.date]),a=kr(e[n.fieldId]?.[t.time]);return W(`${l} ${a}`,`${be} HH:mm`).isBefore(W())};W.extend(Ye);W.extend(pn);const Xu=(e,t)=>{const n=W(Pe(e),be).isBefore(W()),s=W(Pe(e),be).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};W.extend(Ye);W.extend(pn);const Ju=(e,t)=>W(Pe(e),be).isAfter(W())?!0:!!t?.todayAllowed&&W(Pe(e),be).isToday(),Qu=(e,t)=>e?e.length>t.value:!0,Zu=(e,t)=>e?e.length<t.value:!0,ed=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},td=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},nd=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,sd=(e,t)=>e?t.array.includes(e):!0,rd=(e,t,n,s)=>{if(!e||!s)return!0;const r=$t(t.collectionPath,s);return!ze(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)},od=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),id=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,ld=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,ad=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!ld.test(t)}return!1},cd=(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,ud={conditionallyPermittedChange:Vu,conditionallyRequired:qu,mustBeAfter:Ku,mustBeBefore:Wu,mustBeEarlierDateTime:zu,mustBeGreaterThan:ed,mustBeInTheFuture:Ju,mustBeInThePast:Xu,mustBeLessThan:td,mustBeLongerThan:Qu,mustBeNumbersOnly:nd,mustBeOneOf:sd,mustBeShorterThan:Zu,mustBeUniqueInCollection:rd,mustEnterAtLeastOne:od,mustHaveLessThanDecimalPlaces:id,mustNotContainSql:ad,mustSelectOnlyOne:cd},dd=(e,t,n,s)=>{const r=ud[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Br=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=dd(t,r,e,n))}),s}},Nt=(e,t,n)=>{if(!e)return[];const s=n||t,r=Br(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;it(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(rt({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},fd=(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(f=>({...f,message:T.Utils.interpolateString(o===0&&f.firstOnlyMessage?f.firstOnlyMessage:f.message,{index:i})}))),u})};s.push(Nt(a,r,n))}),s.filter(r=>!!r).flat()};W.extend(Ye);W.extend(pn);W.extend(ro);const hd=(e,t)=>e==="02"?W().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,$r=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Pe(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=hd(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 W(t,be).format(be)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},md=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,pd=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,Yr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&(md.test(e)||pd.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`}},Ed="Invalid files must be deleted",Hr=(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 Ed}},Vr=(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"}},qr=(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`}},Gr=(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=kr(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}},Ad=(e,t)=>e?.type==="or"?le.meetsOne(e.conditions,t):le.meetsAll(e.conditions,t),rt=(e,t,n)=>{const s=n||t;if(!xe(e,{...s,...t}))return;if(e.type===P.CONTAINER)return Nt(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===P.COLLECTION_SUMMARY&&(l=ze(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!Ad(e.requiredOverrideConditions,s))&&(r=qr(l,e.label,e.custom_errors)),!r){switch(e.type){case P.COLLECTION:return fd(e,l,s);case P.EMAIL:r=Yr(l,e.label,e.custom_errors);break;case P.DATE:case P.TIME:{const a=e.type===P.DATE?$r:Kr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case P.CHECKBOXES:case P.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&ot(n[e.id],c)&&(a=a.concat(Nt({components:c.nested},n)))}),a.length>0)return a;break}case P.MULTI_FILE:r=Hr(l,e.custom_errors);break;case P.TEXT_AREA:r=Gr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=Vr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Br(e,l,n),e.type===P.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},yd=(e,t=[])=>{let n=e.formData;if(e.collection){const s=Ot.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...Ot.getData(e.collection.name,e.formData)?.[s]})}return jt(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!xe(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(rt(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:T.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},Sd={component:rt,container:Nt,email:Yr,date:$r,multifile:Hr,page:yd,regex:Vr,required:qr,textarea:Gr,time:Kr},w={CheckYourAnswers:gu,CollectionPage:Ot,Component:dt,Condition:le,Container:Ut,Data:he,Format:_u,FormPage:ft,Hub:Iu,Meta:Ru,Operate:Hu,Validate:Sd,...T.Utils},Td="hods-form-container",Un=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:f})=>{if(typeof s=="function")if(f.name===w.Meta.name)s({target:f});else{const h={...t,[f.name]:f.value};s({target:{name:e.fieldId,value:h}})}},a=f=>{const h=`${e.full_path||e.fieldId}.${f.fieldId}`;return f.type===P.CONTAINER?w.Container.show({...f,full_path:h},n):w.Component.show({...f,full_path:h},{...n,...se(n,e.full_path)})},c=w.classBuilder(Td,[],e.className),u=T.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(T.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((f,h)=>{const p=f.type===P.FILE?{}:"",S=t?t[f.fieldId]:p,A=`${e.full_path||e.fieldId}.${f.fieldId}`;return d.jsx(Ke,{...i,component:{...f,full_path:A,readonly:!!(e.readonly||f.readonly)},formData:n,value:S||p,wrap:r,onChange:l,onTopLevelChange:o},h)})]})},Cd=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{}},hs=({group:e})=>{const[t,n]=N.useState({});return N.useEffect(()=>{n(Cd(e))},[e,n]),e?.action?d.jsxs(T.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},gd=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(T.SmallHeading,{children:e}),t==="m"&&d.jsx(T.MediumHeading,{children:e})]}),bd=({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(T.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(T.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Nn,{row:{action:e.action}})})]}),wd="govuk-summary-list",fn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=wd,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=T.Utils.classBuilder(r,o,i),u=T.Utils.cleanHtmlAttributes(a);let f=null;if(s){const h=e.filter(p=>!!p.action);f=h?.length?h[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(h=>{const p=`${h.pageId}_${h.full_path||h.fieldId}`;return h.type==="title"?d.jsx(yr,{title:h.key,classes:c},p):h.type==="heading"?d.jsx(gd,{title:h.key,size:h.size||"s",classes:c},p):h.type==="headingWithAction"?d.jsx(bd,{row:h,classes:c,noChangeAction:t},p):h.type==="action"?t?null:d.jsx("div",{children:d.jsx(hs,{group:h})},`${p}-actions`):d.jsx(Ar,{row:h,classes:c,showAction:!t},p)}).filter(h=>!!h),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(hs,{group:f})})]})})},_d="hods-check-your-answers",Pd="Check your answers",ms=9,Id=({title:e=Pd,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:f,groups:h,sections:p=[],type:S,hideBlankRows:A=!1,optionalFieldPlaceholder:C})=>{const[E,I]=N.useState([]),[y,b]=N.useState([]),{errors:_}=Ge(),{hooks:F}=Oe();N.useEffect(()=>{const O=(H,J)=>w.CheckYourAnswers.getRows(H,o,F.onGetCYARows).map((G,V)=>({...G,value:d.jsx(In,{value:G.value,component:G.component,formData:H.formData,placeholder:C},`${J}_${V}`)})),$=w.CollectionPage.mergePages(n).map((H,J)=>{const K=O(H,J);return K?.length?{...H,rows:K}:null}).filter(H=>!!H);I($)},[n,o,I]);const g=i?0:ms,v=O=>O===E.length-1;N.useEffect(()=>{(()=>{const j=Array.isArray(h)?h.map($=>$.pageId):[];b(j)})()},[b,h]);const L=F.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:f,groups:h,errors:_,sections:p,type:S});if(L)return L;const U=O=>y.includes(O),x=O=>h?.find(j=>j.pageId===O),B=(O,j)=>{if(!O.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(T.SmallHeading,{children:w.FormPage.getTitle(O.title,O.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:w.FormPage.getTitle(O.title,O.formData)})]});const $=Mt(!1,O,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(T.SmallHeading,{children:w.FormPage.getTitle(O.title,O.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:w.FormPage.getTitle(O.title,O.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Nn,{row:{action:$}})})]})},R=()=>Array.from(new Set(_.map(j=>j.id))).map(j=>_.find($=>$.id===j));return d.jsxs("div",{className:_d,children:[e&&!a&&d.jsx(T.Heading,{size:t,children:e},"heading"),_&&_.length>0&&d.jsx(T.ErrorSummary,{errors:R()}),S===ne.TASK_CYA&&E.length>0&&p&&p.map(O=>O.tasks.filter(j=>j.state!==q.TYPES.SKIPPED).map((j,$)=>{const H=E.filter(J=>j.pages.some(K=>K===J.name));return d.jsxs(N.Fragment,{children:[d.jsx(T.MediumHeading,{children:H.length>0&&(j.displayName||j.name)}),H.map((J,K)=>{const G=U(J.id)||u,V=!i&&J.title&&!U(J.id);return d.jsxs(N.Fragment,{children:[V&&B(J,"s"),d.jsx(fn,{rows:J.rows,classModifiers:c,noChangeAction:G,noGroupAction:f,isGroup:U(J.id)})]},K)})]},$)})),S!==ne.TASK_CYA&&E&&E.map((O,j,$)=>{const H=!A||O.collection?O.rows:O.rows.filter(oe=>oe?.value?.props?.value);if(H.length===0)return null;const J=!i&&O.title&&!U(O.id),K=v(j)||U($[j].id)||$.length>j+1&&U($[j+1].id)?ms:g,G=U(O.id)?x(O.id):void 0,V=`govuk-!-margin-bottom-${K}`,me=U(O.id)||u;return d.jsxs(N.Fragment,{children:[J&&B(O,"m"),G&&d.jsx("div",{className:"group-title",children:d.jsx(T.MediumHeading,{children:G.title||w.FormPage.getTitle(O.title,O.formData)})}),d.jsx(fn,{className:V,rows:H,classModifiers:c,noChangeAction:me,noGroupAction:f,isGroup:U(O.id)})]},j)}),!l&&d.jsx(On,{actions:s?.filter(O=>w.Component.show(O,n[n.length-1].formData)),onAction:O=>r(O)})]})},xd=pr,Od=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=xd,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=N.useState({});let f=w.CollectionPage.getData(e.collection.name,e.formData)||[];const h=e.collection.name.split(".").pop();let p=w.CollectionPage.getActiveIndex(e.collection.name,e.formData);const S=e,A=({target:_})=>{w.CollectionPage.setData(S.collection.name,_.value,e.formData),f=_.value;const F=e.collection.name.split(".").shift();u(g=>({...g,[F]:w.CollectionPage.getData(F,e.formData)}))},C=({target:_})=>{S.formData[_.name]=_.value,u(F=>({...F,[_.name]:_.value}))},E=_=>{A({target:{value:_}}),typeof n=="function"&&n(e.formData)},I=_=>{p=f.length,C({target:{name:`${h}ActiveId`,value:_}})},y=_=>{s(_,c,{})},b=({target:_})=>{if(p===null){const F=Dt.v4();I(F),E([...f,{id:F,[_.name]:_.value}])}else(!Array.isArray(_.value)||Array.isArray(_.value)&&_.value.length>0||Array.isArray(_.value)&&_.value.length===0&&_.name)&&E([...f.slice(0,p),{...f[p],[_.name]:_.value},...f.slice(p+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(Rn,{page:{...e,formData:{...e.formData,...f[p],[`${h}ActiveIndex`]:p,[`${h}NumberedIndex`]:typeof p=="number"?p+1:null},components:e.components.map(_=>({..._,pageCollection:{...e.collection}}))},pages:t,onAction:y,onWrapperChange:b,onTopLevelChange:C,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},Rd="hods-task-list",Nd=({state:e=q.TYPES.CANNOT_START_YET})=>{const t=T.Utils.classBuilder(Rd,void 0,void 0),n=q.DETAILS[e]||q.DETAILS.cannotStartYet;return d.jsx(T.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Dd="hods-task-list",vd=({task:e,onClick:t})=>{const n=T.Utils.classBuilder(Dd,void 0,void 0),[s,r]=N.useState(e.state!==q.TYPES.CANNOT_START_YET),[o,i]=N.useState(e.state);N.useEffect(()=>{r(e.state!==q.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(T.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(Nd,{state:o})]})},Ld="hods-task-list",Fd="Incomplete form",Ud=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=Fd,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=Ld,classModifiers:u=[],className:f="",formData:h={},annotations:p=[],...S})=>{const A=T.Utils.classBuilder(c,u,f),C=T.Utils.cleanHtmlAttributes(S),[E,I]=i.filter(g=>!g.skipped).reduce((g,v)=>[g[0]+(v.tasks?.filter(L=>L.state===q.TYPES.COMPLETE).length??0),g[1]+(v.tasks?.filter(L=>L.state!==q.TYPES.SKIPPED).length??0)],[0,0]),y=`${e}Notes`,{title:b,text:_}=s&&s||{},F=g=>{typeof a=="function"&&a(g)};return d.jsxs("div",{...C,id:e,className:A(),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}`})]}),p.length>0&&p.map(g=>d.jsxs("div",{className:A("annotation"),children:[d.jsx("p",{className:`${A("annotation-key")} govuk-body`,children:T.Utils.interpolateString(g.key,h)}),d.jsx("p",{className:`${A("annotation-value")} govuk-body`,children:T.Utils.interpolateString(g.value,h)})]},g.key)),o&&I!==E&&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 ${E} of ${I} sections`}),b&&_&&xe(s,h)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:T.Utils.interpolateString(b,h)})}),d.jsx(T.TextArea,{id:y,fieldId:y,readOnly:!0,value:T.Utils.interpolateString(_,h)})]}),i.filter(g=>!g.skipped).map((g,v)=>d.jsxs(N.Fragment,{children:[d.jsxs("h2",{className:A("section"),children:[i.length>1?`${v+1}. `:" ",g.name]}),g.label&&d.jsx(T.Hint,{children:g.label}),d.jsx("ol",{className:A("items"),children:g.tasks.filter(L=>L.state!==q.TYPES.SKIPPED).map(L=>d.jsx(vd,{task:L,onClick:F},`${g.name}-${L.name}`))})]},`${g.name}`))]})},Wr=(e,t)=>e?.page||t,jd=(e,t,n)=>{const s=Wr(e.action,e.pageId);s!==t&&n(s)},Md=(e,t,n,s=void 0)=>{const r=Wr(e,t);r!==t&&n(r,s)},kd=(e,t)=>{t(e)},Ce={cyaAction:jd,navigate:Md,submissionError:kd},Bd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,$d=(e,t)=>t(e).length===0,Yd=["radios","checkboxes"],Hd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Vd(e,t){const n=[];return e?.data?.options?.forEach(s=>{!ot(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const zr=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!Yd.includes(s.type))return;Vd(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Hd(t.collection.name,t.formData),...n};const s=ze(t.collection.name,n);if(s){const r=$t(t.collection.name,n),o=s.map(i=>i.id===r?zr(i,{...t,collection:void 0}):i);vn(t.collection.name,o,n)}}return n},qd=(e,t,n)=>{if(e===re.HUB&&n===Se.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}}},Xr=(e,t,n)=>{if(e)return e===re.HUB?n===Se.CYA||n===Se.TASK?void 0:n:t.find(s=>s.id===e)},Gd=(e,t,n)=>({pageId:e,cya:qd(e,t,n),page:Xr(e,t,n)}),ps=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Kd=(e,t,n)=>e.page?.type===re.PARTIAL_CYA?ps(n||t,e.pageId):n||t,Es=(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=>{ft.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||re.HUB},Jr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!ft.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Wd=(e,t,n)=>Jr(e,t,n)||re.CYA,zd=e=>e.length>0?e[0].id:void 0,hn=(e,t,n,s,r)=>{if(s){if(s.type===z.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===z.TYPES.SAVE_AND_RETURN)return e===ne.HUB?re.HUB:void 0}switch(e){case ne.HUB:return Es(s);case ne.CYA:return Wd(t,n,r);case ne.FORM_WITH_TASK:case ne.TASK:return Es(s,n,t,r,e);case ne.WIZARD:return Jr(t,n,r);default:return zd(t)}},Xd=(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===z.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:hn(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 f=u.pages[u.pages.length-1];(f===n||f.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===z.TYPES.SAVE_AND_RETURN?{page:n}:{page:hn(e,t,n,s,r)}},Jd=({complete:e,currentPage:t},n=q.TYPES.NOT_STARTED)=>e?q.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?q.TYPES.IN_PROGRESS:n,Qd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===q.TYPES.SKIPPED?s:s&&o?.complete},!0),Qr=(e,t)=>{const n=e[t-1].state;return n===q.TYPES.COMPLETE?!0:n===q.TYPES.SKIPPED?t-1===0?!0:Qr(e,t-1):!1},Zd=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return Jd(s[e.name],e.state);if(r)return e.depends_on&&!Qd(s,e.depends_on,e.ignoreSkipped)?q.TYPES.CANNOT_START_YET:q.TYPES.NOT_STARTED;let i=o;return t&&(i=Qr(n,t)),i?q.TYPES.NOT_STARTED:q.TYPES.CANNOT_START_YET},ef=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==q.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Zd(l,i,r,t,n,s)}),r},Zr=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===q.TYPES.COMPLETE?!0:n===q.TYPES.SKIPPED?t-1===0?!0:Zr(e,t-1):!1},tf=(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:q.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:q.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===q.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:q.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||Zr(r,l);a.tasks=ef(a,o,n,c)}),r},nf=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},$e=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)$e(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]]},eo=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},jn=(e,t)=>{const n=eo(e);return n?`${n}.${t}`:t},sf=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)}},rf=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},of=(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},tt=(e,t)=>e.show_when?e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t):!0,to=(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},lf=(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)}},mn=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):mn(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]):mn(e[t])})},no=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},af=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;$e(e,t),no(n,r=>{const o=jn(t,r.fieldId);s[o]>1?s[o]-=1:$e(e,o)})}},cf=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&lf(r,n,s),r.preserveInPayload)return;$e(n,r.fieldId),no(r,o=>{const i=jn(r.fieldId,o.fieldId);e.has(i)||$e(n,i)})}})},As=e=>Array.isArray(e)?e:[e],uf=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,f)=>{u.fieldId&&(f=f?`${f}.${u.fieldId}`:u.fieldId,o[f]=(o[f]||0)+1,u.path=f,c.show_when&&(u.show_when=u.show_when?[...As(c.show_when),...As(u.show_when)]:c.show_when),nf(f,u,r),u.components?u.components.forEach(h=>{a(c,h,f)}):u?.data?.options&&u?.data?.options?.forEach(h=>{if(h.nested){const p=!ot(se(s,f),h),S=h.show_when;h.nested.forEach(A=>{p&&i.push(jn(f,A.fieldId)),S&&(A.show_when=S),a(c,A,eo(f))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const f=to(u,t,n);a(c,f,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:$e(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},df=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=rf(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},ff=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(h=>{const p=of(h,t);if(p)p.forEach(S=>{a.has(S)||i(a,S,u)});else{const S=/([a-zA-Z_$][\w$]*)\[\d+\]/,A=h.match(S);if(A){const C=A[1],E=s.get(C);E&&E.childPages?.forEach(I=>{if(I.show_when){const y=JSON.stringify(I.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 ${h}, and the chained show_when is ${y}.
12
- The form will need to be changed to break this chained dependency`;throw new Error(b)}})}}}),tt(c,o)||af(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(f=>{l.has(f)||i(l,f,e)})})},hf=(e,t,n,s)=>{e?.forEach((r,o)=>{tt(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(f=>{const h=tt(f,a);f.components?.forEach(p=>{const S=to(p,n,s);if(!S.fieldId)return;const A=tt(p,a);h&&A&&tt(S,a)?c.add(S.fieldId):u.set(S.id,S)})}),cf(c,u,l,t)}),i&&sf(i)})},mf=(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=Dr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=uf(o,s,r,n),c=df(i);return ff(c,i,l,a,t,n),hf(a,n,s,r),mn(n),n},Q={canActionProceed:Bd,canCYASubmit:$d,cleanHiddenNestedData:zr,getFormState:Gd,getRelevantPages:Kd,getNextPageId:hn,getPage:Xr,getSubmissionStatus:Xd,getUpdatedSectionStates:tf,clearOutUncompletedRoutes:mf},pf=(e,t,n,s,r,o,i,l,a,c,u,f,h,p,S,A,C,E)=>{if(t.type===z.TYPES.SUBMIT&&p!==Se.TASK){if(e("submit"),Q.canCYASubmit(n,s.pages)&&!C){E(!0);const I=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),y={pages:n,components:o};Q.clearOutUncompletedRoutes(r,y,I),I.formStatus=Q.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),f.onSubmit(t.type,I,()=>{f.onFormComplete(),E(!1)},b=>{E(!1),Ce.submissionError(b,h)})}}else{const y=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Q.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===z.TYPES.SAVE_AND_CONTINUE&&p===Se.TASK&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{E(!1),S(re.HUB)},P=>{E(!1),Ce.submissionError(P,h)})}if(t.type===z.TYPES.SUBMIT&&p===Se.TASK&&(e("submit"),y)){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),P={pages:n,components:o};Q.clearOutUncompletedRoutes(r,P,b),b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{f.onFormComplete(),E(!1)},F=>{E(!1),Ce.submissionError(F,h)})}if(t.type===z.TYPES.SAVE_AND_NAVIGATE&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{E(!1),S(t.page)},P=>{E(!1),Ce.submissionError(P,h)})}if(t.type===z.TYPES.SAVE_AND_RETURN&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!1),l(b),f.onSubmit(t.type,b,()=>{a===ne.TASK?S(void 0):S(re.HUB),E(!1)},P=>{E(!1),Ce.submissionError(P,h)})}if(t.type===z.TYPES.NAVIGATE&&(S(Q.getNextPageId(a,n,c,t,A.page?.formData)),E(!1)),t.type===z.TYPES.CANCEL){const b=w.Format.form({pages:n,components:o},{...i},Ie.CANCEL);f.onCancel(b),E(!1)}}},ys=(e,t,n,s,r,o,i,l,a,c,u,f,h,p,S,A,C,E,I,y,b,P)=>{const F={...r},g=o,v=s.onAction(g.page.formData,t,r,e.customAction);g.page.formData=v.formData;let L=v.patch;if(g.page.formData={...g.page.formData,...L},e.type===z.TYPES.CANCEL){s.onCancel(g.page.formData),b(!1);return}if(Q.canActionProceed(e,g.page,i.page,P)&&(!y||e.ignoreSubmittingFlag))if(L=Q.cleanHiddenNestedData(L,g.page),b(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?vn(x.field,x.value,o.page.formData):w.Data.setDataItem(o.page.formData,x.field,x.value)}),g.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===z.TYPES.NAVIGATE)Ce.navigate(e,h,l),b(!1);else{let U=K=>l(Q.getNextPageId(a,u,h,e,K)),x,B;e.collection&&(x=e.collection,B=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let R,O;switch(x&&(R=g.page.formData[x],R&&R.length>0&&g.page.formData[`${x}ActiveId`]&&(O=R.findIndex(K=>K.id===g.page.formData[`${x}ActiveId`]))),e.type){case z.TYPES.SUBMIT:p("submit");break;case z.TYPES.SAVE_AND_NAVIGATE:const K={...S};R&&R.length>0&&e.resetActiveId&&(g.page.formData[`${x}ActiveId`]=R[0].id),R&&R.length>0&&!e.resetActiveId&&(O!==void 0&&O+1<g.page.formData[x].length&&(g.page.formData[B]="Yes"),O!==void 0&&O+1===g.page.formData[x].length&&g.page.formData[B]&&(g.page.formData[B]="No")),U=()=>Ce.navigate(e,h,l,K);break;case z.TYPES.COLLECTION_ADD:if(O===void 0||R.length===0||O+1===g.page.formData[x].length?w.CollectionPage.addEntry(e.collection,g.page.formData):g.page.formData[`${e.collection}ActiveId`]=R[O+1].id,g.page.formData[`${e.collection}`]&&g.page.formData[`${e.collection}`].length>0){const oe=g.page.formData[`${e.collection}`].length-1;Object.keys(g.page.formData[`${e.collection}`][oe]).filter(ae=>ae in g.page.formData&&ae!=="id").forEach(ae=>delete g.page.formData[ae])}U=()=>Ce.navigate(e,h,l);break;case z.TYPES.COLLECTION_DUPLICATE:w.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(U=()=>Ce.navigate(e,h,l));break;case z.TYPES.COLLECTION_REMOVE:const G=e.targetId||g.page.formData[`${e.collection.split(".").pop()}ActiveId`],V=w.CollectionPage.removeEntry(e.collection,o.page.formData,G);e.recordRemoval&&(g.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...V});const me=g.page.formData.id;V!==null&&Object.keys(V).filter(pe=>pe in g.page.formData).forEach(pe=>delete g.page.formData[pe]),Object.assign(g.page.formData,R[R.length-1]),g.page.formData.id=me,R.length>0?g.page.formData[`${e.collection}ActiveId`]=R[R.length-1].id:(delete g.page.formData[`${e.collection}ActiveId`],delete g.page.formData[e.collection]),U=()=>Ce.navigate(e,h,l);break}w.Data.deleteValues(r,o.page.formData);const j=w.Format.form({pages:u,components:f},{...r,...t,...o.page.formData},Ie.SUBMIT);j.formStatus=Q.getSubmissionStatus(a,u,h,e,j,S,!0,C?.sections),L&&A(j);const $={pages:u,components:f};e.type===z.TYPES.SUBMIT&&Q.clearOutUncompletedRoutes(c,$,j);let H,J;a===ne.HUB&&Object.keys(n).length>0&&(H=Object.keys(n)[0],J=Object.values(n)[0]),s.onSubmit(e.type,j,K=>{const G={...j,...K};E({data:G}),U(G),b(!1)},(K,G=!0)=>{Ce.submissionError(K,I),G&&A({...F}),b(!1)},H,J,h)}},Ss=(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===q.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===q.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)}},so=({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:f=Ef,classModifiers:h=[],className:p="",hide_title:S,summaryListClassModifiers:A=[],noChangeAction:C=!1,newPageId:E="",viewOnly:I=!0,hideBlankRows:y=!1})=>d.jsx(dr,{overrides:u,children:d.jsx(fr,{children:d.jsx(Af,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:f,classModifiers:h,className:p,hashLink:c,hide_title:S,summaryListClassModifiers:A,noChangeAction:C,newPageId:E,viewOnly:I,hideBlankRows:y})})}),Ef="hods-form",Af=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:f,hashLink:h,hide_title:p,summaryListClassModifiers:S,noChangeAction:A,newPageId:C,viewOnly:E,hideBlankRows:I})=>{const[y,b]=N.useState({}),[P,F]=N.useState(),[g,v]=N.useState([]),[L,U]=N.useState(void 0),[x,B]=N.useState(Q.getNextPageId(n,o,null,null,a)),[R,O]=N.useState(Q.getFormState(x,g,L)),[j,$]=N.useState({}),[H,J]=N.useState({}),[K,G]=N.useState("load"),[V,me]=N.useState(!1),[oe,pe]=N.useState(!1),{hooks:ae}=Oe(),{addErrors:Y,clearErrors:Te,errors:Re,validate:Ue}=Ge();window.onpopstate=k=>{if(!document.location.hash&&(k.state&&k.state.fullPages!==void 0&&$(X=>({...X,fullPages:k.state?.fullPages})),Te(),me(!0),ae.onGoingBack(k.state?k.state:null,R.page?.formData),r&&g&&y&&R.page?.formData&&K===void 0)){const X=w.Format.form({pages:g,components:r},{...y,...R.page.formData},Ie.SUBMIT);if(X?.formStatus?.taskPage){const te=X.formStatus.tasks;Object.keys(te).forEach(Ae=>{const Mn=te[Ae];Mn.currentPage&&!Mn.complete&&delete te[Ae].currentPage}),delete X.formStatus.taskPage}b(X)}},N.useEffect(()=>{r&&o&&a&&(K==="load"||E)&&(b(w.Data.setupForm(o,r,a)),a.formStatus?.page&&B(a.formStatus.page))},[r,o,a,b,K,E]),N.useEffect(()=>{v(w.FormPage.getAll(o,r,{...y}))},[r,o,y,v]),N.useEffect(()=>{B(k=>k||Q.getNextPageId(n,g))},[n,g,B]),N.useEffect(()=>{U(w.Hub.get(n,i,r,{...y}))},[n,i,y,r,U]),N.useEffect(()=>{n===ne.HUB&&V&&y&&R.page?.formData&&(R.page.formData={...y}),me(!1),O(Q.getFormState(x,g,L))},[g,L,x,O,n,V,y,R.page]),N.useEffect(()=>{G(void 0),ae.onFormLoad(k=>{$(k)})},[ae]),N.useEffect(()=>{J(i)},[i]),N.useEffect(()=>{P?.data&&(b(P.data),F(void 0))},[P,b,F]);const Xe=i?.sections,Je=i?.nonSequential;N.useEffect(()=>{const k=j.fullPages;if(k&&(k.forEach(X=>{const te=X;te&&(te.formData=y)}),$(X=>({...X,fullPages:k}))),Xe){const X=y?.formStatus?.tasks||{},te=Q.getUpdatedSectionStates(Xe,X,Je,y);J(Ae=>({...Ae,sections:[...te]}))}},[j.fullPages,y,Xe,Je]);const ce=(k,X={})=>{Te(),B(k),ae.onPageChange(k,X)};N.useEffect(()=>{C!==void 0&&B(C)},[C]);const Qe=k=>{ae.onChange(k)},Ze=(k,X)=>{if(typeof X=="function"){const te=X({...y});te&&b(te)}R.page?.type===re.PARTIAL_CYA&&!l.disableTaskSwitch&&H.sections.every(te=>te.tasks.every(Ae=>Ae.pages.includes(k.pageId)&&Ae.name!==j.name?(Ss(Ae,g,$,H,y,ce),!1):!0)),k&&Ce.cyaAction(k,x,ce)},ge=w.classBuilder(c,u,f);if(L===Se.TASK){const k=l;k.actions=[z.TYPES.SAVE_AND_CONTINUE,z.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:M,nonSequential:Ee,..._e}=H;return d.jsxs("div",{className:ge(),children:[e&&!p&&x===re.HUB&&d.jsx(T.Heading,{size:t,children:e}),R.cya&&d.jsx(Id,{pages:Q.getRelevantPages(R,g,j.fullPages),...l,...R.page?.type===re.PARTIAL_CYA&&{actions:R.page.actions?.filter(k=>w.Component.show(k,y))},...R.cya,onAction:k=>{pf(G,k,g,Ue,s,r,y,b,n,x,j,ae,Y,L,ce,R,oe,pe)},onRowAction:Ze,summaryListClassModifiers:S,hide_title:p,noChangeAction:R.cya.hideChangeActions??A,noGroupAction:R.cya.hideGroupActions??!1,sections:typeof H<"u"?H.sections:[],type:n,hideBlankRows:I}),L===Se.TASK&&R.pageId===re.HUB&&d.jsx(Ud,{..._e,refNumber:y.businessKey,onTaskAction:k=>{Ss(k,g,$,H,y,ce)},annotations:H?.taskListAnnotations||[],formData:y}),R.page&&!R.cya&&!R.page.collection&&d.jsx(Rn,{page:R.page,pages:[...g],onAction:(k,X,te)=>{ys(k,X,te,ae,y,R,Ue,ce,n,s,g,r,x,G,j,b,H,F,Y,oe,pe,Re)},onChange:Qe,hashLink:h,classModifiers:R.page.classModifiers,className:R.page.className,submitting:oe,pageId:x}),R.page&&!R.cya&&R.page.collection&&d.jsx(Od,{page:R.page,pages:g,onCollectionChange:Qe,onAction:(k,X,te)=>{ys(k,X,te,ae,y,R,Ue,ce,n,s,g,r,x,G,j,b,H,F,Y,oe,pe,Re)},hashLink:h,classModifiers:R.page.classModifiers,className:R.page.className,submitting:oe})]})};exports.Container=Un;exports.FormComponent=Ke;exports.FormRenderer=so;exports.FormTypes=ne;exports.HooksContextProvider=dr;exports.HubFormats=Se;exports.Models=Wo;exports.PageActions=On;exports.SummaryList=fn;exports.Utils=w;exports.ValidationContextProvider=fr;exports.default=so;
12
+ The form will need to be changed to break this chained dependency`;throw new Error(b)}})}}}),tt(c,o)||af(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(f=>{l.has(f)||i(l,f,e)})})},hf=(e,t,n,s)=>{e?.forEach((r,o)=>{tt(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(f=>{const h=tt(f,a);f.components?.forEach(p=>{const S=to(p,n,s);if(!S.fieldId)return;const A=tt(p,a);h&&A&&tt(S,a)?c.add(S.fieldId):u.set(S.id,S)})}),cf(c,u,l,t)}),i&&sf(i)})},mf=(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=Dr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=uf(o,s,r,n),c=df(i);return ff(c,i,l,a,t,n),hf(a,n,s,r),mn(n),n},Q={canActionProceed:Bd,canCYASubmit:$d,cleanHiddenNestedData:zr,getFormState:Gd,getRelevantPages:Kd,getNextPageId:hn,getPage:Xr,getSubmissionStatus:Xd,getUpdatedSectionStates:tf,clearOutUncompletedRoutes:mf},pf=(e,t,n,s,r,o,i,l,a,c,u,f,h,p,S,A,C,E)=>{if(t.type===z.TYPES.SUBMIT&&p!==Se.TASK){if(e("submit"),Q.canCYASubmit(n,s.pages)&&!C){E(!0);const I=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),y={pages:n,components:o};Q.clearOutUncompletedRoutes(r,y,I),I.formStatus=Q.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),f.onSubmit(t.type,I,()=>{f.onFormComplete(),E(!1)},b=>{E(!1),Ce.submissionError(b,h)})}}else{const y=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Q.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===z.TYPES.SAVE_AND_CONTINUE&&p===Se.TASK&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{E(!1),S(re.HUB)},_=>{E(!1),Ce.submissionError(_,h)})}if(t.type===z.TYPES.SUBMIT&&p===Se.TASK&&(e("submit"),y)){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),_={pages:n,components:o};Q.clearOutUncompletedRoutes(r,_,b),b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{f.onFormComplete(),E(!1)},F=>{E(!1),Ce.submissionError(F,h)})}if(t.type===z.TYPES.SAVE_AND_NAVIGATE&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),f.onSubmit(t.type,b,()=>{E(!1),S(t.page)},_=>{E(!1),Ce.submissionError(_,h)})}if(t.type===z.TYPES.SAVE_AND_RETURN&&y){const b=w.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!1),l(b),f.onSubmit(t.type,b,()=>{a===ne.TASK?S(void 0):S(re.HUB),E(!1)},_=>{E(!1),Ce.submissionError(_,h)})}if(t.type===z.TYPES.NAVIGATE&&(S(Q.getNextPageId(a,n,c,t,A.page?.formData)),E(!1)),t.type===z.TYPES.CANCEL){const b=w.Format.form({pages:n,components:o},{...i},Ie.CANCEL);f.onCancel(b),E(!1)}}},ys=(e,t,n,s,r,o,i,l,a,c,u,f,h,p,S,A,C,E,I,y,b,_)=>{const F={...r},g=o,v=s.onAction(g.page.formData,t,r,e.customAction);g.page.formData=v.formData;let L=v.patch;if(g.page.formData={...g.page.formData,...L},e.type===z.TYPES.CANCEL){s.onCancel(g.page.formData),b(!1);return}if(Q.canActionProceed(e,g.page,i.page,_)&&(!y||e.ignoreSubmittingFlag))if(L=Q.cleanHiddenNestedData(L,g.page),b(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?vn(x.field,x.value,o.page.formData):w.Data.setDataItem(o.page.formData,x.field,x.value)}),g.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===z.TYPES.NAVIGATE)Ce.navigate(e,h,l),b(!1);else{let U=K=>l(Q.getNextPageId(a,u,h,e,K)),x,B;e.collection&&(x=e.collection,B=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let R,O;switch(x&&(R=g.page.formData[x],R&&R.length>0&&g.page.formData[`${x}ActiveId`]&&(O=R.findIndex(K=>K.id===g.page.formData[`${x}ActiveId`]))),e.type){case z.TYPES.SUBMIT:p("submit");break;case z.TYPES.SAVE_AND_NAVIGATE:const K={...S};R&&R.length>0&&e.resetActiveId&&(g.page.formData[`${x}ActiveId`]=R[0].id),R&&R.length>0&&!e.resetActiveId&&(O!==void 0&&O+1<g.page.formData[x].length&&(g.page.formData[B]="Yes"),O!==void 0&&O+1===g.page.formData[x].length&&g.page.formData[B]&&(g.page.formData[B]="No")),U=()=>Ce.navigate(e,h,l,K);break;case z.TYPES.COLLECTION_ADD:if(O===void 0||R.length===0||O+1===g.page.formData[x].length?w.CollectionPage.addEntry(e.collection,g.page.formData):g.page.formData[`${e.collection}ActiveId`]=R[O+1].id,g.page.formData[`${e.collection}`]&&g.page.formData[`${e.collection}`].length>0){const oe=g.page.formData[`${e.collection}`].length-1;Object.keys(g.page.formData[`${e.collection}`][oe]).filter(ae=>ae in g.page.formData&&ae!=="id").forEach(ae=>delete g.page.formData[ae])}U=()=>Ce.navigate(e,h,l);break;case z.TYPES.COLLECTION_DUPLICATE:w.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(U=()=>Ce.navigate(e,h,l));break;case z.TYPES.COLLECTION_REMOVE:const G=e.targetId||g.page.formData[`${e.collection.split(".").pop()}ActiveId`],V=w.CollectionPage.removeEntry(e.collection,o.page.formData,G);e.recordRemoval&&(g.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...V});const me=g.page.formData.id;V!==null&&Object.keys(V).filter(pe=>pe in g.page.formData).forEach(pe=>delete g.page.formData[pe]),Object.assign(g.page.formData,R[R.length-1]),g.page.formData.id=me,R.length>0?g.page.formData[`${e.collection}ActiveId`]=R[R.length-1].id:(delete g.page.formData[`${e.collection}ActiveId`],delete g.page.formData[e.collection]),U=()=>Ce.navigate(e,h,l);break}w.Data.deleteValues(r,o.page.formData);const j=w.Format.form({pages:u,components:f},{...r,...t,...o.page.formData},Ie.SUBMIT);j.formStatus=Q.getSubmissionStatus(a,u,h,e,j,S,!0,C?.sections),L&&A(j);const $={pages:u,components:f};e.type===z.TYPES.SUBMIT&&Q.clearOutUncompletedRoutes(c,$,j);let H,J;a===ne.HUB&&Object.keys(n).length>0&&(H=Object.keys(n)[0],J=Object.values(n)[0]),s.onSubmit(e.type,j,K=>{const G={...j,...K};E({data:G}),U(G),b(!1)},(K,G=!0)=>{Ce.submissionError(K,I),G&&A({...F}),b(!1)},H,J,h)}},Ss=(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===q.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===q.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)}},so=({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:f=Ef,classModifiers:h=[],className:p="",hide_title:S,summaryListClassModifiers:A=[],noChangeAction:C=!1,newPageId:E="",viewOnly:I=!0,hideBlankRows:y=!1})=>d.jsx(dr,{overrides:u,children:d.jsx(fr,{children:d.jsx(Af,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:f,classModifiers:h,className:p,hashLink:c,hide_title:S,summaryListClassModifiers:A,noChangeAction:C,newPageId:E,viewOnly:I,hideBlankRows:y})})}),Ef="hods-form",Af=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:f,hashLink:h,hide_title:p,summaryListClassModifiers:S,noChangeAction:A,newPageId:C,viewOnly:E,hideBlankRows:I})=>{const[y,b]=N.useState({}),[_,F]=N.useState(),[g,v]=N.useState([]),[L,U]=N.useState(void 0),[x,B]=N.useState(Q.getNextPageId(n,o,null,null,a)),[R,O]=N.useState(Q.getFormState(x,g,L)),[j,$]=N.useState({}),[H,J]=N.useState({}),[K,G]=N.useState("load"),[V,me]=N.useState(!1),[oe,pe]=N.useState(!1),{hooks:ae}=Oe(),{addErrors:Y,clearErrors:Te,errors:Re,validate:Ue}=Ge();window.onpopstate=k=>{if(!document.location.hash&&(k.state&&k.state.fullPages!==void 0&&$(X=>({...X,fullPages:k.state?.fullPages})),Te(),me(!0),ae.onGoingBack(k.state?k.state:null,R.page?.formData),r&&g&&y&&R.page?.formData&&K===void 0)){const X=w.Format.form({pages:g,components:r},{...y,...R.page.formData},Ie.SUBMIT);if(X?.formStatus?.taskPage){const te=X.formStatus.tasks;Object.keys(te).forEach(Ae=>{const Mn=te[Ae];Mn.currentPage&&!Mn.complete&&delete te[Ae].currentPage}),delete X.formStatus.taskPage}b(X)}},N.useEffect(()=>{r&&o&&a&&(K==="load"||E)&&(b(w.Data.setupForm(o,r,a)),a.formStatus?.page&&B(a.formStatus.page))},[r,o,a,b,K,E]),N.useEffect(()=>{v(w.FormPage.getAll(o,r,{...y}))},[r,o,y,v]),N.useEffect(()=>{B(k=>k||Q.getNextPageId(n,g))},[n,g,B]),N.useEffect(()=>{U(w.Hub.get(n,i,r,{...y}))},[n,i,y,r,U]),N.useEffect(()=>{n===ne.HUB&&V&&y&&R.page?.formData&&(R.page.formData={...y}),me(!1),O(Q.getFormState(x,g,L))},[g,L,x,O,n,V,y,R.page]),N.useEffect(()=>{G(void 0),ae.onFormLoad(k=>{$(k)})},[ae]),N.useEffect(()=>{J(i)},[i]),N.useEffect(()=>{_?.data&&(b(_.data),F(void 0))},[_,b,F]);const Xe=i?.sections,Je=i?.nonSequential;N.useEffect(()=>{const k=j.fullPages;if(k&&(k.forEach(X=>{const te=X;te&&(te.formData=y)}),$(X=>({...X,fullPages:k}))),Xe){const X=y?.formStatus?.tasks||{},te=Q.getUpdatedSectionStates(Xe,X,Je,y);J(Ae=>({...Ae,sections:[...te]}))}},[j.fullPages,y,Xe,Je]);const ce=(k,X={})=>{Te(),B(k),ae.onPageChange(k,X)};N.useEffect(()=>{C!==void 0&&B(C)},[C]);const Qe=k=>{ae.onChange(k)},Ze=(k,X)=>{if(typeof X=="function"){const te=X({...y});te&&b(te)}R.page?.type===re.PARTIAL_CYA&&!l.disableTaskSwitch&&H.sections.every(te=>te.tasks.every(Ae=>Ae.pages.includes(k.pageId)&&Ae.name!==j.name?(Ss(Ae,g,$,H,y,ce),!1):!0)),k&&Ce.cyaAction(k,x,ce)},ge=w.classBuilder(c,u,f);if(L===Se.TASK){const k=l;k.actions=[z.TYPES.SAVE_AND_CONTINUE,z.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:M,nonSequential:Ee,..._e}=H;return d.jsxs("div",{className:ge(),children:[e&&!p&&x===re.HUB&&d.jsx(T.Heading,{size:t,children:e}),R.cya&&d.jsx(Id,{pages:Q.getRelevantPages(R,g,j.fullPages),...l,...R.page?.type===re.PARTIAL_CYA&&{actions:R.page.actions?.filter(k=>w.Component.show(k,y))},...R.cya,onAction:k=>{pf(G,k,g,Ue,s,r,y,b,n,x,j,ae,Y,L,ce,R,oe,pe)},onRowAction:Ze,summaryListClassModifiers:S,hide_title:p,noChangeAction:R.cya.hideChangeActions??A,noGroupAction:R.cya.hideGroupActions??!1,sections:typeof H<"u"?H.sections:[],type:n,hideBlankRows:I}),L===Se.TASK&&R.pageId===re.HUB&&d.jsx(Ud,{..._e,refNumber:y.businessKey,onTaskAction:k=>{Ss(k,g,$,H,y,ce)},annotations:H?.taskListAnnotations||[],formData:y}),R.page&&!R.cya&&!R.page.collection&&d.jsx(Rn,{page:R.page,pages:[...g],onAction:(k,X,te)=>{ys(k,X,te,ae,y,R,Ue,ce,n,s,g,r,x,G,j,b,H,F,Y,oe,pe,Re)},onChange:Qe,hashLink:h,classModifiers:R.page.classModifiers,className:R.page.className,submitting:oe,pageId:x}),R.page&&!R.cya&&R.page.collection&&d.jsx(Od,{page:R.page,pages:g,onCollectionChange:Qe,onAction:(k,X,te)=>{ys(k,X,te,ae,y,R,Ue,ce,n,s,g,r,x,G,j,b,H,F,Y,oe,pe,Re)},hashLink:h,classModifiers:R.page.classModifiers,className:R.page.className,submitting:oe})]})};exports.Container=Un;exports.FormComponent=Ke;exports.FormRenderer=so;exports.FormTypes=ne;exports.HooksContextProvider=dr;exports.HubFormats=Se;exports.Models=Wo;exports.PageActions=On;exports.SummaryList=fn;exports.Utils=w;exports.ValidationContextProvider=fr;exports.default=so;