@ukhomeoffice/cop-react-form-renderer 8.0.1 → 8.0.2
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 +7 -7
- package/dist/index.js +3031 -2776
- package/package.json +17 -9
- package/dist/setupTests.d.ts +0 -14
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"),O=require("react"),mt=require("uuid"),q=require("dayjs"),Re=require("dayjs/plugin/customParseFormat"),tn=require("dayjs/plugin/isToday"),Wr=require("dayjs/plugin/isLeapYear"),ve={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},zr="alert",Jr="autocomplete",Xr="calculation",Qr="checkboxes",Zr="collection",eo="collection-summary",to="container",no="date",so="details",ro="email",oo="file",io="heading",lo="html",ao="inset-text",co="list",uo="multifile",fo="paragraph",ho="phone-number",mo="radios",po="select",Eo="text",Ao="textarea",yo="time",To="warning",b={ALERT:zr,AUTOCOMPLETE:Jr,CALCULATION:Xr,CHECKBOXES:Qr,COLLECTION:Zr,COLLECTION_SUMMARY:eo,CONTAINER:to,DATE:no,DETAILS:so,EMAIL:ro,FILE:oo,HEADING:io,HTML:lo,INSET_TEXT:ao,LIST:co,MULTI_FILE:uo,PARAGRAPH:fo,PHONE_NUMBER:ho,RADIOS:mo,SELECT:po,TEXT:Eo,TEXT_AREA:Ao,TIME:yo,WARNING:To},So="blur",Co="submit",go="cancel",Te={BLUR:So,SUBMIT:Co,CANCEL:go},bo="cya",wo="hub",Io="partial-cya",te={CYA:bo,HUB:wo,PARTIAL_CYA:Io},_o="cya",Po="form",xo="form-with-task-list",No="hub-and-spoke",Oo="task-list",Ro="task-list-cya",vo="wizard",Z={CYA:_o,FORM:Po,FORM_WITH_TASK:xo,HUB:No,TASK:Oo,TASK_CYA:Ro,WIZARD:vo},Lo="CYA",Do="TASK",he={CYA:Lo,TASK:Do},Ut="cancel",cs="collectionAdd",us="collectionDuplicate",ds="collectionRemove",fs="navigate",Mt="saveAndContinue",kt="saveAndNavigate",$t="saveAndReturn",Bt="submit",st={CANCEL:Ut,COLLECTION_ADD:cs,COLLECTION_DUPLICATE:us,COLLECTION_REMOVE:ds,NAVIGATE:fs,SAVE_AND_CONTINUE:Mt,SAVE_AND_NAVIGATE:kt,SAVE_AND_RETURN:$t,SUBMIT:Bt},Fo={[Ut]:{type:Ut,validate:!1,label:"Cancel",classModifiers:"secondary"},[cs]:void 0,[us]:void 0,[ds]:void 0,[fs]:void 0,[Mt]:{type:Mt,validate:!0,label:"Save and continue"},[kt]:{type:kt,validate:!0,label:"Save and continue"},[$t]:{type:$t,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Bt]:{type:Bt,validate:!0}},G={TYPES:st,DEFAULTS:Fo},hs="complete",ms="inProgress",ps="notStarted",Es="cannotStartYet",As="skipped",jo={COMPLETE:hs,IN_PROGRESS:ms,NOT_STARTED:ps,CANNOT_START_YET:Es,SKIPPED:As},Uo={[hs]:{label:"Completed",colour:"dark-blue"},[ms]:{label:"In Progress",colour:"white"},[ps]:{label:"Not Started",colour:"dark-grey"},[Es]:{label:"Cannot Start Yet",colour:"dark-grey"},[As]:{label:"Skipped",colour:"dark-grey"}},B={TYPES:jo,DETAILS:Uo},Mo={CollectionLabels:ve,ComponentTypes:b,EventTypes:Te,FormPages:te,FormTypes:Z,HubFormats:he,PageAction:G,TaskStates:B},ys=e=>{try{const t=ko(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},ko=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return Xe(e,(n,s)=>n*s);case"divide":return Xe(e,(n,s)=>n/s);case"plus":return Xe(e,(n,s)=>n+s);case"minus":return Xe(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},Xe=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return $o(n.map(s=>Bo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},$o=(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},Bo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=Yo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ys({...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")},Yo=(e,t)=>T.Utils.interpolateString("${"+e+"}",t),Ho=(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 le.getSource(t,n)}return e.value},Qe=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},nn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Ho(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=Qe(t),o=Qe(s);return r!=null&&o!=null&&r<o}case">":{const r=Qe(t),o=Qe(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},Vo=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=le.getDataPath(s.field,n);return{...s,field:r}})}},qo=e=>Array.isArray(e)||!!(e.field&&e.op),Ts=e=>e&&!qo(e)?Vo(e):e,Ss=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ss(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=le.getSource(t,i);return nn(o,l,t)};return n==="and"?s.every(r):s.some(r)},xe=(e,t)=>{const n=Ts(e);return n?Ss(n,t):!0},Go=(e,t)=>{const n=Ts(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=le.getSource(t,r.field);return nn(r,o,t)}):!0},se={meetsOne:Go,meetsAll:xe,met:nn},Ko=(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},Ze=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?se.meetsOne(n,e.formData):se.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),Wo=(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},Cs=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Wo(e,e?.data?.collection);return t(Ze(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Ko(e.options,e.data.options);return t(Ze(e,n))}if(e.options)return t(Ze(e,e.options));if(e.data&&e.data.options)return t(Ze(e,e.data.options))}return t([])},zo=6e3,Jo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},xn=e=>e===0,gs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),Xo=(e,t)=>{let n=0;return e.synonyms.some(r=>gs(r,t))&&(n=4),n},Qo=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return gs(i,n)})&&(s=5),s},Zo=(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=Jo(i,r)),xn(o)&&e.synonyms&&(o=Xo(e,t)),xn(o)&&s.item?.extraFieldsToSearch&&(o=Qo(s,e,t)),{score:o,label:r,option:e}},ei=(e,t,n)=>(s,r)=>{const o=Zo(r,e,t,n);return o.score>0&&s.push(o),s},ti=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),ni=e=>{let t=[];Cs(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(ei(o,n,e),[]).sort(ti).slice(0,zo).map(l=>l.option);r(i)}},Ie=".",sn="/",bs=`${Ie}${Ie}`,Nn=`${Ie}${sn}`,Yt=e=>e.join(Ie),Ht=(e,t=Ie)=>e.split(t),si=e=>e===bs,ri=e=>[Ie,bs].indexOf(e)>-1,oi=e=>e&&e.indexOf(Ie)===0,ii=e=>e.indexOf(Nn)===0?e:`${Nn}${e}`,li=(e,t)=>{const n=ii(t),s=Ht(n,sn).filter(si).length+1,r=e?Ht(e):[];return s>=r.length?"":Yt(r.slice(0,-s))},ai=(e,t)=>{const n=Ht(t,sn).filter(s=>!ri(s));return e?`${e}.${Yt(n)}`:Yt(n)},ci=(e,t)=>oi(e)?ai(li(t,e),e):e,ui=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},di=e=>e.includes("["),fi=e=>e.replace("]","").split("["),ee=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&di(s)){const[r,o]=fi(s);return ui(n[r],o)}return n?n[s]:void 0},e)},hi=(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}},mi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...hi(n,t)}):[],pi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},ws=(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},Is=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=ee(n,e.source.field))},Ei=(e,t)=>{e.forEach(n=>Is(n,t))},Ai=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Is(s,t))})},yi=(e,t,n)=>{const s={...n};return Ei(t,s),Ai(e,s),s},Ti=(e,t)=>({...e,components:_s(e.components,t)}),Si=(e,t)=>({...e,item:_s(e.item,t)}),_s=(e,t)=>e.map(n=>Ps(n,t)),Ps=(e,t)=>{if(e){if(e.type===b.CONTAINER)return Ti(e,t);if(e.type===b.COLLECTION)return Si(e,t);if(e.type===b.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},le={applyFormula:ys,getAutocompleteSource:ni,getDataPath:ci,getOptions:Cs,getSource:ee,refData:{setupUrl:Ps,toOptions:mi},deleteValues:pi,setDataItem:ws,setupForm:yi},Ye=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ce=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t),He=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ce(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||le.getSource(t,s.full_path);Array.isArray(r.nested)&&Ye(o,r)&&Ce(r,t)&&(n=n.concat(r.nested))})}),n},On=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],Q=(e,t)=>{const n=Array.isArray(t)?[...On,...t]:On;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function xs(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ci}=Object.prototype,{getPrototypeOf:rn}=Object,{iterator:pt,toStringTag:Ns}=Symbol,Et=(e=>t=>{const n=Ci.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ae=e=>(e=e.toLowerCase(),t=>Et(t)===e),At=e=>t=>typeof t===e,{isArray:Le}=Array,Ne=At("undefined");function Ve(e){return e!==null&&!Ne(e)&&e.constructor!==null&&!Ne(e.constructor)&&ce(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Os=Ae("ArrayBuffer");function gi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Os(e.buffer),t}const bi=At("string"),ce=At("function"),Rs=At("number"),qe=e=>e!==null&&typeof e=="object",wi=e=>e===!0||e===!1,rt=e=>{if(Et(e)!=="object")return!1;const t=rn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ns in e)&&!(pt in e)},Ii=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_i=Ae("Date"),Pi=Ae("File"),xi=e=>!!(e&&typeof e.uri<"u"),Ni=e=>e&&typeof e.getParts<"u",Oi=Ae("Blob"),Ri=Ae("FileList"),vi=e=>qe(e)&&ce(e.pipe);function Li(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rn=Li(),vn=typeof Rn.FormData<"u"?Rn.FormData:void 0,Di=e=>{let t;return e&&(vn&&e instanceof vn||ce(e.append)&&((t=Et(e))==="formdata"||t==="object"&&ce(e.toString)&&e.toString()==="[object FormData]"))},Fi=Ae("URLSearchParams"),[ji,Ui,Mi,ki]=["ReadableStream","Request","Response","Headers"].map(Ae),$i=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ge(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 vs(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 be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ls=e=>!Ne(e)&&e!==be;function Vt(){const{caseless:e,skipUndefined:t}=Ls(this)&&this||{},n={},s=(r,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&vs(n,o)||o;rt(n[i])&&rt(r)?n[i]=Vt(n[i],r):rt(r)?n[i]=Vt({},r):Le(r)?n[i]=r.slice():(!t||!Ne(r))&&(n[i]=r)};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Ge(arguments[r],s);return n}const Bi=(e,t,n,{allOwnKeys:s}={})=>(Ge(t,(r,o)=>{n&&ce(r)?Object.defineProperty(e,o,{value:xs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),Yi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Vi=(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&&rn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},qi=(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},Gi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Rs(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ki=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&rn(Uint8Array)),Wi=(e,t)=>{const s=(e&&e[pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},zi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Ji=Ae("HTMLFormElement"),Xi=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),Ln=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Qi=Ae("RegExp"),Ds=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};Ge(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},Zi=e=>{Ds(e,(t,n)=>{if(ce(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(ce(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+"'")})}})},el=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},tl=()=>{},nl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sl(e){return!!(e&&ce(e.append)&&e[Ns]==="FormData"&&e[pt])}const rl=e=>{const t=new Array(10),n=(s,r)=>{if(qe(s)){if(t.indexOf(s)>=0)return;if(Ve(s))return s;if(!("toJSON"in s)){t[r]=s;const o=Le(s)?[]:{};return Ge(s,(i,l)=>{const a=n(i,r+1);!Ne(a)&&(o[l]=a)}),t[r]=void 0,o}}return s};return n(e,0)},ol=Ae("AsyncFunction"),il=e=>e&&(qe(e)||ce(e))&&ce(e.then)&&ce(e.catch),Fs=((e,t)=>e?setImmediate:t?((n,s)=>(be.addEventListener("message",({source:r,data:o})=>{r===be&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),be.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ce(be.postMessage)),ll=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Fs,al=e=>e!=null&&ce(e[pt]),E={isArray:Le,isArrayBuffer:Os,isBuffer:Ve,isFormData:Di,isArrayBufferView:gi,isString:bi,isNumber:Rs,isBoolean:wi,isObject:qe,isPlainObject:rt,isEmptyObject:Ii,isReadableStream:ji,isRequest:Ui,isResponse:Mi,isHeaders:ki,isUndefined:Ne,isDate:_i,isFile:Pi,isReactNativeBlob:xi,isReactNative:Ni,isBlob:Oi,isRegExp:Qi,isFunction:ce,isStream:vi,isURLSearchParams:Fi,isTypedArray:Ki,isFileList:Ri,forEach:Ge,merge:Vt,extend:Bi,trim:$i,stripBOM:Yi,inherits:Hi,toFlatObject:Vi,kindOf:Et,kindOfTest:Ae,endsWith:qi,toArray:Gi,forEachEntry:Wi,matchAll:zi,isHTMLForm:Ji,hasOwnProperty:Ln,hasOwnProp:Ln,reduceDescriptors:Ds,freezeMethods:Zi,toObjectSet:el,toCamelCase:Xi,noop:tl,toFiniteNumber:nl,findKey:vs,global:be,isContextDefined:Ls,isSpecCompliantForm:sl,toJSONObject:rl,isAsyncFn:ol,isThenable:il,setImmediate:Fs,asap:ll,isIterable:al};let F=class js extends Error{static from(t,n,s,r,o,i){const l=new js(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",{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(){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:E.toJSONObject(this.config),code:this.code,status:this.status}}};F.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";F.ERR_BAD_OPTION="ERR_BAD_OPTION";F.ECONNABORTED="ECONNABORTED";F.ETIMEDOUT="ETIMEDOUT";F.ERR_NETWORK="ERR_NETWORK";F.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";F.ERR_DEPRECATED="ERR_DEPRECATED";F.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";F.ERR_BAD_REQUEST="ERR_BAD_REQUEST";F.ERR_CANCELED="ERR_CANCELED";F.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";F.ERR_INVALID_URL="ERR_INVALID_URL";const cl=null;function qt(e){return E.isPlainObject(e)||E.isArray(e)}function Us(e){return E.endsWith(e,"[]")?e.slice(0,-2):e}function Nt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Us(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function ul(e){return E.isArray(e)&&!e.some(qt)}const dl=E.toFlatObject(E,{},null,function(t){return/^is[A-Z]/.test(t)});function yt(e,t,n){if(!E.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=E.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,A){return!E.isUndefined(A[p])});const s=n.metaTokens,r=n.visitor||u,o=n.dots,i=n.indexes,a=(n.Blob||typeof Blob<"u"&&Blob)&&E.isSpecCompliantForm(t);if(!E.isFunction(r))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(E.isDate(h))return h.toISOString();if(E.isBoolean(h))return h.toString();if(!a&&E.isBlob(h))throw new F("Blob is not supported. Use a Buffer instead.");return E.isArrayBuffer(h)||E.isTypedArray(h)?a&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,p,A){let w=h;if(E.isReactNative(t)&&E.isReactNativeBlob(h))return t.append(Nt(A,p,o),c(h)),!1;if(h&&!A&&typeof h=="object"){if(E.endsWith(p,"{}"))p=s?p:p.slice(0,-2),h=JSON.stringify(h);else if(E.isArray(h)&&ul(h)||(E.isFileList(h)||E.endsWith(p,"[]"))&&(w=E.toArray(h)))return p=Us(p),w.forEach(function(C,I){!(E.isUndefined(C)||C===null)&&t.append(i===!0?Nt([p],I,o):i===null?p:p+"[]",c(C))}),!1}return qt(h)?!0:(t.append(Nt(A,p,o),c(h)),!1)}const m=[],f=Object.assign(dl,{defaultVisitor:u,convertValue:c,isVisitable:qt});function y(h,p){if(!E.isUndefined(h)){if(m.indexOf(h)!==-1)throw Error("Circular reference detected in "+p.join("."));m.push(h),E.forEach(h,function(w,L){(!(E.isUndefined(w)||w===null)&&r.call(t,w,E.isString(L)?L.trim():L,p,f))===!0&&y(w,p?p.concat(L):[L])}),m.pop()}}if(!E.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Dn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function on(e,t){this._pairs=[],e&&yt(e,this,t)}const Ms=on.prototype;Ms.append=function(t,n){this._pairs.push([t,n])};Ms.toString=function(t){const n=t?function(s){return t.call(this,s,Dn)}:Dn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function fl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ks(e,t,n){if(!t)return e;const s=n&&n.encode||fl,r=E.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=E.isURLSearchParams(t)?t.toString():new on(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Fn{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){E.forEach(this.handlers,function(s){s!==null&&t(s)})}}const ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},hl=typeof URLSearchParams<"u"?URLSearchParams:on,ml=typeof FormData<"u"?FormData:null,pl=typeof Blob<"u"?Blob:null,El={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ml,Blob:pl},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",Gt=typeof navigator=="object"&&navigator||void 0,Al=an&&(!Gt||["ReactNative","NativeScript","NS"].indexOf(Gt.product)<0),yl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tl=an&&window.location.href||"http://localhost",Sl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:yl,navigator:Gt,origin:Tl},Symbol.toStringTag,{value:"Module"})),ie={...Sl,...El};function Cl(e,t){return yt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&E.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function gl(e){return E.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bl(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 $s(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&E.isArray(r)?r.length:i,a?(E.hasOwnProp(r,i)?r[i]=[r[i],s]:r[i]=s,!l):((!r[i]||!E.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&E.isArray(r[i])&&(r[i]=bl(r[i])),!l)}if(E.isFormData(e)&&E.isFunction(e.entries)){const n={};return E.forEachEntry(e,(s,r)=>{t(gl(s),r,n,0)}),n}return null}function wl(e,t,n){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Ke={transitional:ln,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=E.isObject(t);if(o&&E.isHTMLForm(t)&&(t=new FormData(t)),E.isFormData(t))return r?JSON.stringify($s(t)):t;if(E.isArrayBuffer(t)||E.isBuffer(t)||E.isStream(t)||E.isFile(t)||E.isBlob(t)||E.isReadableStream(t))return t;if(E.isArrayBufferView(t))return t.buffer;if(E.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Cl(t,this.formSerializer).toString();if((l=E.isFileList(t))||s.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return yt(l?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||r?(n.setContentType("application/json",!1),wl(t)):t}],transformResponse:[function(t){const n=this.transitional||Ke.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(E.isResponse(t)||E.isReadableStream(t))return t;if(t&&E.isString(t)&&(s&&!this.responseType||r)){const i=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?F.from(l,F.ERR_BAD_RESPONSE,this,null,this.response):l}}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}}};E.forEach(["delete","get","head","post","put","patch"],e=>{Ke.headers[e]={}});const Il=E.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"]),_l=e=>{const t={};let n,s,r;return e&&e.split(`
|
|
2
|
-
`).forEach(function(i){r=i.indexOf(":"),n=i.substring(0,r).trim().toLowerCase(),s=i.substring(r+1).trim(),!(!n||t[n]&&
|
|
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[jn]=this[jn]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=Me(i);s[l]||(vl(r,i),s[l]=!0)}return E.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);E.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});E.freezeMethods(ue);function Rt(e,t){const n=this||Ke,s=t||n,r=ue.from(s.headers);let o=s.data;return E.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ys(e){return!!(e&&e.__CANCEL__)}let We=class extends F{constructor(t,n,s){super(t??"canceled",F.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function Hs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new F("Request failed with status code "+n.status,[F.ERR_BAD_REQUEST,F.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ll(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dl(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 m=o,f=0;for(;m!==r;)f+=n[m++],m=m%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const y=u&&c-u;return y?Math.round(f*1e3/y):void 0}}function Fl(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(),m=u-n;m>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-m)))},()=>r&&i(r)]}const ct=(e,t,n=3)=>{let s=0;const r=Dl(50,250);return Fl(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=i-s,c=r(a),u=i<=l;s=i;const m={loaded:i,total:l,progress:l?i/l:void 0,bytes:a,rate:c||void 0,estimated:c&&l&&u?(l-i)/c:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(m)},n)},Un=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},Mn=e=>(...t)=>E.asap(()=>e(...t)),jl=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,Ul=ie.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];E.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),E.isString(s)&&l.push(`path=${s}`),E.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),E.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ml(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function kl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vs(e,t,n){let s=!Ml(t);return e&&(s||n==!1)?kl(e,t):t}const kn=e=>e instanceof ue?{...e}:e;function _e(e,t){t=t||{};const n={};function s(c,u,m,f){return E.isPlainObject(c)&&E.isPlainObject(u)?E.merge.call({caseless:f},c,u):E.isPlainObject(u)?E.merge({},u):E.isArray(u)?u.slice():u}function r(c,u,m,f){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c,m,f)}else return s(c,u,m,f)}function o(c,u){if(!E.isUndefined(u))return s(void 0,u)}function i(c,u){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,m){if(m in t)return s(c,u);if(m in e)return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(c,u,m)=>r(kn(c),kn(u),m,!0)};return E.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const m=E.hasOwnProp(a,u)?a[u]:r,f=m(e[u],t[u],u);E.isUndefined(f)&&m!==l||(n[u]=f)}),n}const qs=e=>{const t=_e({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:o,headers:i,auth:l}=t;if(t.headers=i=ue.from(i),t.url=ks(Vs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),E.isFormData(n)){if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(E.isFunction(n.getHeaders)){const a=n.getHeaders(),c=["content-type","content-length"];Object.entries(a).forEach(([u,m])=>{c.includes(u.toLowerCase())&&i.set(u,m)})}}if(ie.hasStandardBrowserEnv&&(s&&E.isFunction(s)&&(s=s(t)),s||s!==!1&&jl(t.url))){const a=r&&o&&Ul.read(o);a&&i.set(r,a)}return t},$l=typeof XMLHttpRequest<"u",Bl=$l&&function(e){return new Promise(function(n,s){const r=qs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,m,f,y,h;function p(){y&&y(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function w(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};Hs(function(S){n(S),p()},function(S){s(S),p()},_),A=null}"onloadend"in A?A.onloadend=w:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.indexOf("file:")===0)||setTimeout(w)},A.onabort=function(){A&&(s(new F("Request aborted",F.ECONNABORTED,e,A)),A=null)},A.onerror=function(I){const _=I&&I.message?I.message:"Network Error",U=new F(_,F.ERR_NETWORK,e,A);U.event=I||null,s(U),A=null},A.ontimeout=function(){let I=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const _=r.transitional||ln;r.timeoutErrorMessage&&(I=r.timeoutErrorMessage),s(new F(I,_.clarifyTimeoutError?F.ETIMEDOUT:F.ECONNABORTED,e,A)),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&E.forEach(i.toJSON(),function(I,_){A.setRequestHeader(_,I)}),E.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,h]=ct(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([m,y]=ct(a),A.upload.addEventListener("progress",m),A.upload.addEventListener("loadend",y)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new We(null,e,A):C),A.abort(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const L=Ll(r.url);if(L&&ie.protocols.indexOf(L)===-1){s(new F("Unsupported protocol "+L+":",F.ERR_BAD_REQUEST,e));return}A.send(o||null)})},Yl=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let s=new AbortController,r;const o=function(c){if(!r){r=!0,l();const u=c instanceof Error?c:this.reason;s.abort(u instanceof F?u:new We(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new F(`timeout of ${t}ms exceeded`,F.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>c.addEventListener("abort",o));const{signal:a}=s;return a.unsubscribe=()=>E.asap(l),a}},Hl=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},Vl=async function*(e,t){for await(const n of ql(e))yield*Hl(n,t)},ql=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()}},$n=(e,t,n,s)=>{const r=Vl(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 m=u.byteLength;if(n){let f=o+=m;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})},Bn=64*1024,{isFunction:et}=E,Gl=(({Request:e,Response:t})=>({Request:e,Response:t}))(E.global),{ReadableStream:Yn,TextEncoder:Hn}=E.global,Vn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Kl=e=>{e=E.merge.call({skipUndefined:!0},Gl,e);const{fetch:t,Request:n,Response:s}=e,r=t?et(t):typeof fetch=="function",o=et(n),i=et(s);if(!r)return!1;const l=r&&et(Yn),a=r&&(typeof Hn=="function"?(h=>p=>h.encode(p))(new Hn):async h=>new Uint8Array(await new n(h).arrayBuffer())),c=o&&l&&Vn(()=>{let h=!1;const p=new Yn,A=new n(ie.origin,{body:p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return p.cancel(),h&&!A}),u=i&&l&&Vn(()=>E.isReadableStream(new s("").body)),m={stream:u&&(h=>h.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!m[h]&&(m[h]=(p,A)=>{let w=p&&p[h];if(w)return w.call(p);throw new F(`Response type '${h}' is not supported`,F.ERR_NOT_SUPPORT,A)})});const f=async h=>{if(h==null)return 0;if(E.isBlob(h))return h.size;if(E.isSpecCompliantForm(h))return(await new n(ie.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(E.isArrayBufferView(h)||E.isArrayBuffer(h))return h.byteLength;if(E.isURLSearchParams(h)&&(h=h+""),E.isString(h))return(await a(h)).byteLength},y=async(h,p)=>{const A=E.toFiniteNumber(h.getContentLength());return A??f(p)};return async h=>{let{url:p,method:A,data:w,signal:L,cancelToken:C,timeout:I,onDownloadProgress:_,onUploadProgress:U,responseType:S,headers:R,withCredentials:v="same-origin",fetchOptions:D}=qs(h),x=t||fetch;S=S?(S+"").toLowerCase():"text";let k=Yl([L,C&&C.toAbortSignal()],I),P=null;const N=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let j;try{if(U&&c&&A!=="get"&&A!=="head"&&(j=await y(R,w))!==0){let J=new n(p,{method:"POST",body:w,duplex:"half"}),de;if(E.isFormData(w)&&(de=J.headers.get("content-type"))&&R.setContentType(de),J.body){const[ae,fe]=Un(j,ct(Mn(U)));w=$n(J.body,Bn,ae,fe)}}E.isString(v)||(v=v?"include":"omit");const M=o&&"credentials"in n.prototype,Y={...D,signal:k,method:A.toUpperCase(),headers:R.normalize().toJSON(),body:w,duplex:"half",credentials:M?v:void 0};P=o&&new n(p,Y);let H=await(o?x(P,D):x(p,Y));const V=u&&(S==="stream"||S==="response");if(u&&(_||V&&N)){const J={};["status","statusText","headers"].forEach(re=>{J[re]=H[re]});const de=E.toFiniteNumber(H.headers.get("content-length")),[ae,fe]=_&&Un(de,ct(Mn(_),!0))||[];H=new s($n(H.body,Bn,ae,()=>{fe&&fe(),N&&N()}),J)}S=S||"text";let K=await m[E.findKey(m,S)||"text"](H,h);return!V&&N&&N(),await new Promise((J,de)=>{Hs(J,de,{data:K,headers:ue.from(H.headers),status:H.status,statusText:H.statusText,config:h,request:P})})}catch(M){throw N&&N(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new F("Network Error",F.ERR_NETWORK,h,P,M&&M.response),{cause:M.cause||M}):F.from(M,M&&M.code,h,P,M&&M.response)}}},Wl=new Map,Gs=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=Wl;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:Kl(t)),u=c;return c};Gs();const cn={http:cl,xhr:Bl,fetch:{get:Gs}};E.forEach(cn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qn=e=>`- ${e}`,zl=e=>E.isFunction(e)||e===null||e===!1;function Jl(e,t){e=E.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,!zl(s)&&(r=cn[(l=String(s)).toLowerCase()],r===void 0))throw new F(`Unknown adapter '${l}'`);if(r&&(E.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
|
-
`+i.map(
|
|
5
|
-
`):" "+
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),S=require("@ukhomeoffice/cop-react-components"),R=require("react"),_t=require("uuid"),K=require("dayjs"),Be=require("dayjs/plugin/customParseFormat"),fn=require("dayjs/plugin/isToday"),Xr=require("dayjs/plugin/isLeapYear"),$e={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},Qr="alert",Zr="autocomplete",eo="calculation",to="checkboxes",no="collection",so="collection-summary",ro="container",oo="date",io="details",lo="email",ao="file",co="heading",uo="html",fo="inset-text",ho="list",mo="multifile",po="paragraph",Eo="phone-number",Ao="radios",yo="select",To="text",So="textarea",Co="time",go="warning",_={ALERT:Qr,AUTOCOMPLETE:Zr,CALCULATION:eo,CHECKBOXES:to,COLLECTION:no,COLLECTION_SUMMARY:so,CONTAINER:ro,DATE:oo,DETAILS:io,EMAIL:lo,FILE:ao,HEADING:co,HTML:uo,INSET_TEXT:fo,LIST:ho,MULTI_FILE:mo,PARAGRAPH:po,PHONE_NUMBER:Eo,RADIOS:Ao,SELECT:yo,TEXT:To,TEXT_AREA:So,TIME:Co,WARNING:go},bo="blur",wo="submit",_o="cancel",we={BLUR:bo,SUBMIT:wo,CANCEL:_o},Io="cya",Po="hub",xo="partial-cya",re={CYA:Io,HUB:Po,PARTIAL_CYA:xo},Oo="cya",Ro="form",No="form-with-task-list",Lo="hub-and-spoke",Do="task-list",vo="task-list-cya",Fo="wizard",ne={CYA:Oo,FORM:Ro,FORM_WITH_TASK:No,HUB:Lo,TASK:Do,TASK_CYA:vo,WIZARD:Fo},jo="CYA",Uo="TASK",ye={CYA:jo,TASK:Uo},Gt="cancel",ps="collectionAdd",Es="collectionDuplicate",As="collectionRemove",ys="navigate",Kt="saveAndContinue",Wt="saveAndNavigate",zt="saveAndReturn",Jt="submit",mt={CANCEL:Gt,COLLECTION_ADD:ps,COLLECTION_DUPLICATE:Es,COLLECTION_REMOVE:As,NAVIGATE:ys,SAVE_AND_CONTINUE:Kt,SAVE_AND_NAVIGATE:Wt,SAVE_AND_RETURN:zt,SUBMIT:Jt},Mo={[Gt]:{type:Gt,validate:!1,label:"Cancel",classModifiers:"secondary"},[ps]:void 0,[Es]:void 0,[As]:void 0,[ys]:void 0,[Kt]:{type:Kt,validate:!0,label:"Save and continue"},[Wt]:{type:Wt,validate:!0,label:"Save and continue"},[zt]:{type:zt,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Jt]:{type:Jt,validate:!0}},W={TYPES:mt,DEFAULTS:Mo},Ts="complete",Ss="inProgress",Cs="notStarted",gs="cannotStartYet",bs="skipped",ko={COMPLETE:Ts,IN_PROGRESS:Ss,NOT_STARTED:Cs,CANNOT_START_YET:gs,SKIPPED:bs},Bo={[Ts]:{label:"Completed",colour:"dark-blue"},[Ss]:{label:"In Progress",colour:"white"},[Cs]:{label:"Not Started",colour:"dark-grey"},[gs]:{label:"Cannot Start Yet",colour:"dark-grey"},[bs]:{label:"Skipped",colour:"dark-grey"}},H={TYPES:ko,DETAILS:Bo},$o={CollectionLabels:$e,ComponentTypes:_,EventTypes:we,FormPages:re,FormTypes:ne,HubFormats:ye,PageAction:W,TaskStates:H},ws=e=>{try{const t=Yo(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},Yo=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return at(e,(n,s)=>n*s);case"divide":return at(e,(n,s)=>n/s);case"plus":return at(e,(n,s)=>n+s);case"minus":return at(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},at=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return Ho(n.map(s=>Vo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},Ho=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const s=Math.pow(10,n);return Math.round((e+Number.EPSILON)*s)/s},Vo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=qo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ws({...e,formData:t});default:throw new Error("Only accept following as argument field: {field, value, or formula}")}}else throw new Error("Argument cannot have more than one reference")},qo=(e,t)=>S.Utils.interpolateString("${"+e+"}",t),Go=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return de.getSource(t,n)}return e.value},ct=e=>{if(Array.isArray(e))return e.length;if(typeof e=="string"){const t=e.replace(/,/g,"");return Number.isNaN(t)?null:parseFloat(t)}return typeof e=="number"?e:null},hn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Go(e,n);switch(e.op){case"=":case"eq":return s===t;case"!=":case"<>":case"ne":case"neq":return s!==t;case"in":return Array.isArray(s)?s.includes(t):!1;case"nin":return Array.isArray(s)?s.includes(t)===!1:!0;case"<":{const r=ct(t),o=ct(s);return r!=null&&o!=null&&r<o}case">":{const r=ct(t),o=ct(s);return r!=null&&o!=null&&r>o}case"contains":return t?.toString().toLowerCase().includes(s);case"!contains":return!t?.toString().toLowerCase().includes(s);case"includes":return Array.isArray(t)?t.includes(s):!1;case"!includes":return Array.isArray(t)?!t.includes(s):!0;case"includesObjectProp":return Array.isArray(t)?t.some(r=>r[e.key]===s):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(r=>r[e.key]===s):!0;case"includesAllOf":return Array.isArray(t)?s.every(r=>t.includes(r)):!1;case"!includesAllOf":return Array.isArray(t)?!s.every(r=>t.includes(r)):!0;default:return!1}}return!0},Ko=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const n=e.full_path;return t=Array.isArray(t)?t:[t],t.map(s=>{const r=de.getDataPath(s.field,n);return{...s,field:r}})}},Wo=e=>Array.isArray(e)||!!(e.field&&e.op),_s=e=>e&&!Wo(e)?Ko(e):e,Is=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Is(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?S.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=de.getSource(t,i);return hn(o,l,t)};return n==="and"?s.every(r):s.some(r)},Ue=(e,t)=>{const n=_s(e);return n?Is(n,t):!0},zo=(e,t)=>{const n=_s(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=de.getSource(t,r.field);return hn(r,o,t)}):!0},ae={meetsOne:zo,meetsAll:Ue,met:hn},Jo=(e,t)=>{const n=e;return t.forEach((s,r)=>{if(s.refdata_match){const o=s.refdata_match,i=Object.keys(o)[0],l=e.findIndex(a=>a[i]===o[i]);l>=0&&(n[l]={...e[l],nested:s.nested})}s.combineWithRefdata&&!n.includes(s)&&(r>0&&typeof t[r-1]=="string"&&n.push(t[r-1]),n.push(s))}),n},ut=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?ae.meetsOne(n,e.formData):ae.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:S.Utils.interpolateString(n.value,e.formData),label:S.Utils.interpolateString(n.label,e.formData),hint:S.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),Xo=(e,t)=>{const n=e.formData[t].map(s=>({value:S.Utils.interpolateString(e.item.value,s),label:S.Utils.interpolateString(e.item.label,s),hint:S.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Ps=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Xo(e,e?.data?.collection);return t(ut(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Jo(e.options,e.data.options);return t(ut(e,n))}if(e.options)return t(ut(e,e.options));if(e.data&&e.data.options)return t(ut(e,e.data.options))}return t([])},Qo=6e3,Zo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},jn=e=>e===0,xs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),ei=(e,t)=>{let n=0;return e.synonyms.some(r=>xs(r,t))&&(n=4),n},ti=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return xs(i,n)})&&(s=5),s},ni=(e,t,n,s)=>{const r=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=r.indexOf(t);return i!==-1&&(o=Zo(i,r)),jn(o)&&e.synonyms&&(o=ei(e,t)),jn(o)&&s.item?.extraFieldsToSearch&&(o=ti(s,e,t)),{score:o,label:r,option:e}},si=(e,t,n)=>(s,r)=>{const o=ni(r,e,t,n);return o.score>0&&s.push(o),s},ri=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),oi=e=>{let t=[];Ps(e,s=>{t=s});const n=e?.item?S.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(si(o,n,e),[]).sort(ri).slice(0,Qo).map(l=>l.option);r(i)}},Ne=".",mn="/",Os=`${Ne}${Ne}`,Un=`${Ne}${mn}`,Xt=e=>e.join(Ne),Qt=(e,t=Ne)=>e.split(t),ii=e=>e===Os,li=e=>[Ne,Os].indexOf(e)>-1,ai=e=>e&&e.indexOf(Ne)===0,ci=e=>e.indexOf(Un)===0?e:`${Un}${e}`,ui=(e,t)=>{const n=ci(t),s=Qt(n,mn).filter(ii).length+1,r=e?Qt(e):[];return s>=r.length?"":Xt(r.slice(0,-s))},di=(e,t)=>{const n=Qt(t,mn).filter(s=>!li(s));return e?`${e}.${Xt(n)}`:Xt(n)},fi=(e,t)=>ai(e)?di(ui(t,e),e):e,hi=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},mi=e=>e.includes("["),pi=e=>e.replace("]","").split("["),se=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&mi(s)){const[r,o]=pi(s);return hi(n[r],o)}return n?n[s]:void 0},e)},Ei=(e,t)=>{let n=e.value||e.id,s=e.label||e.name;return t&&(n=e[t.value]||n,s=e[t.label]||s),{value:n?.toString(),label:s}},Ai=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...Ei(n,t)}):[],yi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},Rs=(e,t,n,s=!1)=>{if(t&&e){const r=s?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=r.pop();let i=e;r.forEach(l=>{(!i[l]||typeof i[l]!="object")&&(i[l]={}),i=i[l]}),i[o]=n}return e},Ns=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=se(n,e.source.field))},Ti=(e,t)=>{e.forEach(n=>Ns(n,t))},Si=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Ns(s,t))})},Ci=(e,t,n)=>{const s={...n};return Ti(t,s),Si(e,s),s},gi=(e,t)=>({...e,components:Ls(e.components,t)}),bi=(e,t)=>({...e,item:Ls(e.item,t)}),Ls=(e,t)=>e.map(n=>Ds(n,t)),Ds=(e,t)=>{if(e){if(e.type===_.CONTAINER)return gi(e,t);if(e.type===_.COLLECTION)return bi(e,t);if(e.type===_.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:S.Utils.interpolateString(e.data.url,t)}}}return e},de={applyFormula:ws,getAutocompleteSource:oi,getDataPath:fi,getOptions:Ps,getSource:se,refData:{setupUrl:Ds,toOptions:Ai},deleteValues:yi,setDataItem:Rs,setupForm:Ci},Ze=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ie=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t),et=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ie(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||de.getSource(t,s.full_path);Array.isArray(r.nested)&&Ze(o,r)&&Ie(r,t)&&(n=n.concat(r.nested))})}),n},Mn=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],te=(e,t)=>{const n=Array.isArray(t)?[...Mn,...t]:Mn;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function vs(e,t){return function(){return e.apply(t,arguments)}}const{toString:wi}=Object.prototype,{getPrototypeOf:It}=Object,{iterator:Pt,toStringTag:Fs}=Symbol,xt=(e=>t=>{const n=wi.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ce=e=>(e=e.toLowerCase(),t=>xt(t)===e),Ot=e=>t=>typeof t===e,{isArray:Le}=Array,Me=Ot("undefined");function Ye(e){return e!==null&&!Me(e)&&e.constructor!==null&&!Me(e.constructor)&&me(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const js=Ce("ArrayBuffer");function _i(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&js(e.buffer),t}const Ii=Ot("string"),me=Ot("function"),Us=Ot("number"),tt=e=>e!==null&&typeof e=="object",Pi=e=>e===!0||e===!1,pt=e=>{if(xt(e)!=="object")return!1;const t=It(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fs in e)&&!(Pt in e)},xi=e=>{if(!tt(e)||Ye(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Oi=Ce("Date"),Ri=Ce("File"),Ni=e=>!!(e&&typeof e.uri<"u"),Li=e=>e&&typeof e.getParts<"u",Di=Ce("Blob"),vi=Ce("FileList"),Fi=e=>tt(e)&&me(e.pipe);function ji(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const kn=ji(),Bn=typeof kn.FormData<"u"?kn.FormData:void 0,Ui=e=>{if(!e)return!1;if(Bn&&e instanceof Bn)return!0;const t=It(e);if(!t||t===Object.prototype||!me(e.append))return!1;const n=xt(e);return n==="formdata"||n==="object"&&me(e.toString)&&e.toString()==="[object FormData]"},Mi=Ce("URLSearchParams"),[ki,Bi,$i,Yi]=["ReadableStream","Request","Response","Headers"].map(Ce),Hi=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nt(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),Le(e))for(s=0,r=e.length;s<r;s++)t.call(null,e[s],s,e);else{if(Ye(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(s=0;s<i;s++)l=o[s],t.call(null,e[l],l,e)}}function Ms(e,t){if(Ye(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,r;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const Oe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ks=e=>!Me(e)&&e!==Oe;function Zt(...e){const{caseless:t,skipUndefined:n}=ks(this)&&this||{},s={},r=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const l=t&&typeof i=="string"&&Ms(s,i)||i,a=en(s,l)?s[l]:void 0;pt(a)&&pt(o)?s[l]=Zt(a,o):pt(o)?s[l]=Zt({},o):Le(o)?s[l]=o.slice():(!n||!Me(o))&&(s[l]=o)};for(let o=0,i=e.length;o<i;o++){const l=e[o];if(!l||Ye(l)||(nt(l,r),typeof l!="object"||Le(l)))continue;const a=Object.getOwnPropertySymbols(l);for(let c=0;c<a.length;c++){const u=a[c];tl.call(l,u)&&r(l[u],u)}}return s}const Vi=(e,t,n,{allOwnKeys:s}={})=>(nt(t,(r,o)=>{n&&me(r)?Object.defineProperty(e,o,{__proto__:null,value:vs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{__proto__:null,value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),qi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Ki=(e,t,n,s)=>{let r,o,i;const l={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)i=r[o],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&It(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},zi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Us(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ji=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&It(Uint8Array)),Xi=(e,t)=>{const s=(e&&e[Pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},Qi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Zi=Ce("HTMLFormElement"),el=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),en=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),{propertyIsEnumerable:tl}=Object.prototype,nl=Ce("RegExp"),Bs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};nt(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},sl=e=>{Bs(e,(t,n)=>{if(me(e)&&["arguments","caller","callee"].includes(n))return!1;const s=e[n];if(me(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},rl=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},ol=()=>{},il=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ll(e){return!!(e&&me(e.append)&&e[Fs]==="FormData"&&e[Pt])}const al=e=>{const t=new WeakSet,n=s=>{if(tt(s)){if(t.has(s))return;if(Ye(s))return s;if(!("toJSON"in s)){t.add(s);const r=Le(s)?[]:{};return nt(s,(o,i)=>{const l=n(o);!Me(l)&&(r[i]=l)}),t.delete(s),r}}return s};return n(e)},cl=Ce("AsyncFunction"),ul=e=>e&&(tt(e)||me(e))&&me(e.then)&&me(e.catch),$s=((e,t)=>e?setImmediate:t?((n,s)=>(Oe.addEventListener("message",({source:r,data:o})=>{r===Oe&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),Oe.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",me(Oe.postMessage)),dl=typeof queueMicrotask<"u"?queueMicrotask.bind(Oe):typeof process<"u"&&process.nextTick||$s,fl=e=>e!=null&&me(e[Pt]),m={isArray:Le,isArrayBuffer:js,isBuffer:Ye,isFormData:Ui,isArrayBufferView:_i,isString:Ii,isNumber:Us,isBoolean:Pi,isObject:tt,isPlainObject:pt,isEmptyObject:xi,isReadableStream:ki,isRequest:Bi,isResponse:$i,isHeaders:Yi,isUndefined:Me,isDate:Oi,isFile:Ri,isReactNativeBlob:Ni,isReactNative:Li,isBlob:Di,isRegExp:nl,isFunction:me,isStream:Fi,isURLSearchParams:Mi,isTypedArray:Ji,isFileList:vi,forEach:nt,merge:Zt,extend:Vi,trim:Hi,stripBOM:qi,inherits:Gi,toFlatObject:Ki,kindOf:xt,kindOfTest:Ce,endsWith:Wi,toArray:zi,forEachEntry:Xi,matchAll:Qi,isHTMLForm:Zi,hasOwnProperty:en,hasOwnProp:en,reduceDescriptors:Bs,freezeMethods:sl,toObjectSet:rl,toCamelCase:el,noop:ol,toFiniteNumber:il,findKey:Ms,global:Oe,isContextDefined:ks,isSpecCompliantForm:ll,toJSONObject:al,isAsyncFn:cl,isThenable:ul,setImmediate:$s,asap:dl,isIterable:fl},hl=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ml=e=>{const t={};let n,s,r;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){r=i.indexOf(":"),n=i.substring(0,r).trim().toLowerCase(),s=i.substring(r+1).trim(),!(!n||t[n]&&hl[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t};function pl(e){let t=0,n=e.length;for(;t<n;){const s=e.charCodeAt(t);if(s!==9&&s!==32)break;t+=1}for(;n>t;){const s=e.charCodeAt(n-1);if(s!==9&&s!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}const El=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Al=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function pn(e,t){return m.isArray(e)?e.map(n=>pn(n,t)):pl(String(e).replace(t,""))}const yl=e=>pn(e,El),Tl=e=>pn(e,Al);function Ys(e){const t=Object.create(null);return m.forEach(e.toJSON(),(n,s)=>{t[s]=Tl(n)}),t}const $n=Symbol("internals");function ze(e){return e&&String(e).trim().toLowerCase()}function Et(e){return e===!1||e==null?e:m.isArray(e)?e.map(Et):yl(String(e))}function Sl(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Cl=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Mt(e,t,n,s,r){if(m.isFunction(s))return s.call(this,t,n);if(r&&(t=n),!!m.isString(t)){if(m.isString(s))return t.indexOf(s)!==-1;if(m.isRegExp(s))return s.test(t)}}function gl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function bl(e,t){const n=m.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{__proto__:null,value:function(r,o,i){return this[s].call(this,t,r,o,i)},configurable:!0})})}let ue=class{constructor(t){t&&this.set(t)}set(t,n,s){const r=this;function o(l,a,c){const u=ze(a);if(!u)return;const h=m.findKey(r,u);(!h||r[h]===void 0||c===!0||c===void 0&&r[h]!==!1)&&(r[h||a]=Et(l))}const i=(l,a)=>m.forEach(l,(c,u)=>o(c,u,a));if(m.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(m.isString(t)&&(t=t.trim())&&!Cl(t))i(ml(t),n);else if(m.isObject(t)&&m.isIterable(t)){let l={},a,c;for(const u of t){if(!m.isArray(u))throw new TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(a=l[c])?m.isArray(a)?[...a,u[1]]:[a,u[1]]:u[1]}i(l,n)}else t!=null&&o(n,t,s);return this}get(t,n){if(t=ze(t),t){const s=m.findKey(this,t);if(s){const r=this[s];if(!n)return r;if(n===!0)return Sl(r);if(m.isFunction(n))return n.call(this,r,s);if(m.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ze(t),t){const s=m.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Mt(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let r=!1;function o(i){if(i=ze(i),i){const l=m.findKey(s,i);l&&(!n||Mt(s,s[l],l,n))&&(delete s[l],r=!0)}}return m.isArray(t)?t.forEach(o):o(t),r}clear(t){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const o=n[s];(!t||Mt(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){const n=this,s={};return m.forEach(this,(r,o)=>{const i=m.findKey(s,o);if(i){n[i]=Et(r),delete n[o];return}const l=t?gl(o):String(o).trim();l!==o&&delete n[o],n[l]=Et(r),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return m.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=t&&m.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(r=>s.set(r)),s}static accessor(t){const s=(this[$n]=this[$n]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=ze(i);s[l]||(bl(r,i),s[l]=!0)}return m.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});m.freezeMethods(ue);const wl="[REDACTED ****]";function _l(e){if(m.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(m.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function Il(e,t){const n=new Set(t.map(o=>String(o).toLowerCase())),s=[],r=o=>{if(o===null||typeof o!="object"||m.isBuffer(o))return o;if(s.indexOf(o)!==-1)return;o instanceof ue&&(o=o.toJSON()),s.push(o);let i;if(m.isArray(o))i=[],o.forEach((l,a)=>{const c=r(l);m.isUndefined(c)||(i[a]=c)});else{if(!m.isPlainObject(o)&&_l(o))return s.pop(),o;i=Object.create(null);for(const[l,a]of Object.entries(o)){const c=n.has(l.toLowerCase())?wl:r(a);m.isUndefined(c)||(i[l]=c)}}return s.pop(),i};return r(e)}let D=class Hs extends Error{static from(t,n,s,r,o,i){const l=new Hs(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){const t=this.config,n=t&&m.hasOwnProp(t,"redact")?t.redact:void 0,s=m.isArray(n)&&n.length>0?Il(t,n):m.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:s,code:this.code,status:this.status}}};D.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";D.ERR_BAD_OPTION="ERR_BAD_OPTION";D.ECONNABORTED="ECONNABORTED";D.ETIMEDOUT="ETIMEDOUT";D.ECONNREFUSED="ECONNREFUSED";D.ERR_NETWORK="ERR_NETWORK";D.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";D.ERR_DEPRECATED="ERR_DEPRECATED";D.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";D.ERR_BAD_REQUEST="ERR_BAD_REQUEST";D.ERR_CANCELED="ERR_CANCELED";D.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";D.ERR_INVALID_URL="ERR_INVALID_URL";D.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Pl=null;function tn(e){return m.isPlainObject(e)||m.isArray(e)}function Vs(e){return m.endsWith(e,"[]")?e.slice(0,-2):e}function kt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Vs(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function xl(e){return m.isArray(e)&&!e.some(tn)}const Ol=m.toFlatObject(m,{},null,function(t){return/^is[A-Z]/.test(t)});function Rt(e,t,n){if(!m.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=m.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!m.isUndefined(T[A])});const s=n.metaTokens,r=n.visitor||h,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,a=n.maxDepth===void 0?100:n.maxDepth,c=l&&m.isSpecCompliantForm(t);if(!m.isFunction(r))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(m.isDate(p))return p.toISOString();if(m.isBoolean(p))return p.toString();if(!c&&m.isBlob(p))throw new D("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(p)||m.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function h(p,A,T){let N=p;if(m.isReactNative(t)&&m.isReactNativeBlob(p))return t.append(kt(T,A,o),u(p)),!1;if(p&&!T&&typeof p=="object"){if(m.endsWith(A,"{}"))A=s?A:A.slice(0,-2),p=JSON.stringify(p);else if(m.isArray(p)&&xl(p)||(m.isFileList(p)||m.endsWith(A,"[]"))&&(N=m.toArray(p)))return A=Vs(A),N.forEach(function(b,P){!(m.isUndefined(b)||b===null)&&t.append(i===!0?kt([A],P,o):i===null?A:A+"[]",u(b))}),!1}return tn(p)?!0:(t.append(kt(T,A,o),u(p)),!1)}const f=[],E=Object.assign(Ol,{defaultVisitor:h,convertValue:u,isVisitable:tn});function y(p,A,T=0){if(!m.isUndefined(p)){if(T>a)throw new D("Object is too deeply nested ("+T+" levels). Max depth: "+a,D.ERR_FORM_DATA_DEPTH_EXCEEDED);if(f.indexOf(p)!==-1)throw new Error("Circular reference detected in "+A.join("."));f.push(p),m.forEach(p,function(C,b){(!(m.isUndefined(C)||C===null)&&r.call(t,C,m.isString(b)?b.trim():b,A,E))===!0&&y(C,A?A.concat(b):[b],T+1)}),f.pop()}}if(!m.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Yn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(s){return t[s]})}function En(e,t){this._pairs=[],e&&Rt(e,this,t)}const qs=En.prototype;qs.append=function(t,n){this._pairs.push([t,n])};qs.toString=function(t){const n=t?function(s){return t.call(this,s,Yn)}:Yn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Rl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Gs(e,t,n){if(!t)return e;const s=n&&n.encode||Rl,r=m.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=m.isURLSearchParams(t)?t.toString():new En(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Hn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){m.forEach(this.handlers,function(s){s!==null&&t(s)})}}const An={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1},Nl=typeof URLSearchParams<"u"?URLSearchParams:En,Ll=typeof FormData<"u"?FormData:null,Dl=typeof Blob<"u"?Blob:null,vl={isBrowser:!0,classes:{URLSearchParams:Nl,FormData:Ll,Blob:Dl},protocols:["http","https","file","blob","url","data"]},yn=typeof window<"u"&&typeof document<"u",nn=typeof navigator=="object"&&navigator||void 0,Fl=yn&&(!nn||["ReactNative","NativeScript","NS"].indexOf(nn.product)<0),jl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ul=yn&&window.location.href||"http://localhost",Ml=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yn,hasStandardBrowserEnv:Fl,hasStandardBrowserWebWorkerEnv:jl,navigator:nn,origin:Ul},Symbol.toStringTag,{value:"Module"})),le={...Ml,...vl};function kl(e,t){return Rt(e,new le.classes.URLSearchParams,{visitor:function(n,s,r,o){return le.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Bl(e){return m.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $l(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function Ks(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&m.isArray(r)?r.length:i,a?(m.hasOwnProp(r,i)?r[i]=m.isArray(r[i])?r[i].concat(s):[r[i],s]:r[i]=s,!l):((!m.hasOwnProp(r,i)||!m.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&m.isArray(r[i])&&(r[i]=$l(r[i])),!l)}if(m.isFormData(e)&&m.isFunction(e.entries)){const n={};return m.forEachEntry(e,(s,r)=>{t(Bl(s),r,n,0)}),n}return null}const je=(e,t)=>e!=null&&m.hasOwnProp(e,t)?e[t]:void 0;function Yl(e,t,n){if(m.isString(e))try{return(t||JSON.parse)(e),m.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const st={transitional:An,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=m.isObject(t);if(o&&m.isHTMLForm(t)&&(t=new FormData(t)),m.isFormData(t))return r?JSON.stringify(Ks(t)):t;if(m.isArrayBuffer(t)||m.isBuffer(t)||m.isStream(t)||m.isFile(t)||m.isBlob(t)||m.isReadableStream(t))return t;if(m.isArrayBufferView(t))return t.buffer;if(m.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){const a=je(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return kl(t,a).toString();if((l=m.isFileList(t))||s.indexOf("multipart/form-data")>-1){const c=je(this,"env"),u=c&&c.FormData;return Rt(l?{"files[]":t}:t,u&&new u,a)}}return o||r?(n.setContentType("application/json",!1),Yl(t)):t}],transformResponse:[function(t){const n=je(this,"transitional")||st.transitional,s=n&&n.forcedJSONParsing,r=je(this,"responseType"),o=r==="json";if(m.isResponse(t)||m.isReadableStream(t))return t;if(t&&m.isString(t)&&(s&&!r||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,je(this,"parseReviver"))}catch(a){if(l)throw a.name==="SyntaxError"?D.from(a,D.ERR_BAD_RESPONSE,this,null,je(this,"response")):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:le.classes.FormData,Blob:le.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch","query"],e=>{st.headers[e]={}});function Bt(e,t){const n=this||st,s=t||n,r=ue.from(s.headers);let o=s.data;return m.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ws(e){return!!(e&&e.__CANCEL__)}let rt=class extends D{constructor(t,n,s){super(t??"canceled",D.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function zs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new D("Request failed with status code "+n.status,n.status>=400&&n.status<500?D.ERR_BAD_REQUEST:D.ERR_BAD_RESPONSE,n.config,n.request,n))}function Hl(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Vl(e,t){e=e||10;const n=new Array(e),s=new Array(e);let r=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const c=Date.now(),u=s[o];i||(i=c),n[r]=a,s[r]=c;let h=o,f=0;for(;h!==r;)f+=n[h++],h=h%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const E=u&&c-u;return E?Math.round(f*1e3/E):void 0}}function ql(e,t){let n=0,s=1e3/t,r,o;const i=(c,u=Date.now())=>{n=u,r=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),h=u-n;h>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-h)))},()=>r&&i(r)]}const St=(e,t,n=3)=>{let s=0;const r=Vl(50,250);return ql(o=>{if(!o||typeof o.loaded!="number")return;const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=l!=null?Math.min(i,l):i,c=Math.max(0,a-s),u=r(c);s=Math.max(s,a);const h={loaded:a,total:l,progress:l?a/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l?(l-a)/u:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},Vn=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},qn=e=>(...t)=>m.asap(()=>e(...t)),Gl=le.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,le.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(le.origin),le.navigator&&/(msie|trident)/i.test(le.navigator.userAgent)):()=>!0,Kl=le.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];m.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),m.isString(s)&&l.push(`path=${s}`),m.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),m.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const s=t[n].replace(/^\s+/,""),r=s.indexOf("=");if(r!==-1&&s.slice(0,r)===e)return decodeURIComponent(s.slice(r+1))}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Wl(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Js(e,t,n){let s=!Wl(t);return e&&(s||n===!1)?zl(e,t):t}const Gn=e=>e instanceof ue?{...e}:e;function De(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function s(c,u,h,f){return m.isPlainObject(c)&&m.isPlainObject(u)?m.merge.call({caseless:f},c,u):m.isPlainObject(u)?m.merge({},u):m.isArray(u)?u.slice():u}function r(c,u,h,f){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c,h,f)}else return s(c,u,h,f)}function o(c,u){if(!m.isUndefined(u))return s(void 0,u)}function i(c,u){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,h){if(m.hasOwnProp(t,h))return s(c,u);if(m.hasOwnProp(e,h))return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:l,headers:(c,u,h)=>r(Gn(c),Gn(u),h,!0)};return m.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const h=m.hasOwnProp(a,u)?a[u]:r,f=m.hasOwnProp(e,u)?e[u]:void 0,E=m.hasOwnProp(t,u)?t[u]:void 0,y=h(f,E,u);m.isUndefined(y)&&h!==l||(n[u]=y)}),n}const Jl=["content-type","content-length"];function Xl(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([s,r])=>{Jl.includes(s.toLowerCase())&&e.set(s,r)})}const Ql=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function Xs(e){const t=De({},e),n=f=>m.hasOwnProp(t,f)?t[f]:void 0,s=n("data");let r=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let l=n("headers");const a=n("auth"),c=n("baseURL"),u=n("allowAbsoluteUrls"),h=n("url");if(t.headers=l=ue.from(l),t.url=Gs(Js(c,h,u),n("params"),n("paramsSerializer")),a&&l.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?Ql(a.password):""))),m.isFormData(s)&&(le.hasStandardBrowserEnv||le.hasStandardBrowserWebWorkerEnv||m.isReactNative(s)?l.setContentType(void 0):m.isFunction(s.getHeaders)&&Xl(l,s.getHeaders(),n("formDataHeaderPolicy"))),le.hasStandardBrowserEnv&&(m.isFunction(r)&&(r=r(t)),r===!0||r==null&&Gl(t.url))){const E=o&&i&&Kl.read(i);E&&l.set(o,E)}return t}const Zl=typeof XMLHttpRequest<"u",ea=Zl&&function(e){return new Promise(function(n,s){const r=Xs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,h,f,E,y;function p(){E&&E(),y&&y(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function T(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),P={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};zs(function(g){n(g),p()},function(g){s(g),p()},P),A=null}"onloadend"in A?A.onloadend=T:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.startsWith("file:"))||setTimeout(T)},A.onabort=function(){A&&(s(new D("Request aborted",D.ECONNABORTED,e,A)),p(),A=null)},A.onerror=function(b){const P=b&&b.message?b.message:"Network Error",U=new D(P,D.ERR_NETWORK,e,A);U.event=b||null,s(U),p(),A=null},A.ontimeout=function(){let b=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const P=r.transitional||An;r.timeoutErrorMessage&&(b=r.timeoutErrorMessage),s(new D(b,P.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,A)),p(),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&m.forEach(Ys(i),function(b,P){A.setRequestHeader(P,b)}),m.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,y]=St(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([h,E]=St(a),A.upload.addEventListener("progress",h),A.upload.addEventListener("loadend",E)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new rt(null,e,A):C),A.abort(),p(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const N=Hl(r.url);if(N&&!le.protocols.includes(N)){s(new D("Unsupported protocol "+N+":",D.ERR_BAD_REQUEST,e));return}A.send(o||null)})},ta=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let s=!1;const r=function(a){if(!s){s=!0,i();const c=a instanceof Error?a:this.reason;n.abort(c instanceof D?c:new rt(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new D(`timeout of ${t}ms exceeded`,D.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),e=null)};e.forEach(a=>a.addEventListener("abort",r));const{signal:l}=n;return l.unsubscribe=()=>m.asap(i),l},na=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,r;for(;s<n;)r=s+t,yield e.slice(s,r),s=r},sa=async function*(e,t){for await(const n of ra(e))yield*na(n,t)},ra=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},Kn=(e,t,n,s)=>{const r=sa(e,t);let o=0,i,l=a=>{i||(i=!0,s&&s(a))};return new ReadableStream({async pull(a){try{const{done:c,value:u}=await r.next();if(c){l(),a.close();return}let h=u.byteLength;if(n){let f=o+=h;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})};function oa(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),s=e.slice(t+1);if(/;base64/i.test(n)){let i=s.length;const l=s.length;for(let E=0;E<l;E++)if(s.charCodeAt(E)===37&&E+2<l){const y=s.charCodeAt(E+1),p=s.charCodeAt(E+2);(y>=48&&y<=57||y>=65&&y<=70||y>=97&&y<=102)&&(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)&&(i-=2,E+=2)}let a=0,c=l-1;const u=E=>E>=2&&s.charCodeAt(E-2)===37&&s.charCodeAt(E-1)===51&&(s.charCodeAt(E)===68||s.charCodeAt(E)===100);c>=0&&(s.charCodeAt(c)===61?(a++,c--):u(c)&&(a++,c-=3)),a===1&&c>=0&&(s.charCodeAt(c)===61||u(c))&&a++;const f=Math.floor(i/4)*3-(a||0);return f>0?f:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(s,"utf8");let o=0;for(let i=0,l=s.length;i<l;i++){const a=s.charCodeAt(i);if(a<128)o+=1;else if(a<2048)o+=2;else if(a>=55296&&a<=56319&&i+1<l){const c=s.charCodeAt(i+1);c>=56320&&c<=57343?(o+=4,i++):o+=3}else o+=3}return o}const Tn="1.17.0",Wn=64*1024,{isFunction:dt}=m,ia=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),zn=e=>{if(!m.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Jn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},la=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},aa=e=>{const t=m.global!==void 0&&m.global!==null?m.global:globalThis,{ReadableStream:n,TextEncoder:s}=t;e=m.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:r,Request:o,Response:i}=e,l=r?dt(r):typeof fetch=="function",a=dt(o),c=dt(i);if(!l)return!1;const u=l&&dt(n),h=l&&(typeof s=="function"?(T=>N=>T.encode(N))(new s):async T=>new Uint8Array(await new o(T).arrayBuffer())),f=a&&u&&Jn(()=>{let T=!1;const N=new o(le.origin,{body:new n,method:"POST",get duplex(){return T=!0,"half"}}),C=N.headers.has("Content-Type");return N.body!=null&&N.body.cancel(),T&&!C}),E=c&&u&&Jn(()=>m.isReadableStream(new i("").body)),y={stream:E&&(T=>T.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(T=>{!y[T]&&(y[T]=(N,C)=>{let b=N&&N[T];if(b)return b.call(N);throw new D(`Response type '${T}' is not supported`,D.ERR_NOT_SUPPORT,C)})});const p=async T=>{if(T==null)return 0;if(m.isBlob(T))return T.size;if(m.isSpecCompliantForm(T))return(await new o(le.origin,{method:"POST",body:T}).arrayBuffer()).byteLength;if(m.isArrayBufferView(T)||m.isArrayBuffer(T))return T.byteLength;if(m.isURLSearchParams(T)&&(T=T+""),m.isString(T))return(await h(T)).byteLength},A=async(T,N)=>{const C=m.toFiniteNumber(T.getContentLength());return C??p(N)};return async T=>{let{url:N,method:C,data:b,signal:P,cancelToken:U,timeout:g,onDownloadProgress:L,onUploadProgress:v,responseType:F,headers:I,withCredentials:k="same-origin",fetchOptions:O,maxContentLength:x,maxBodyLength:j}=Xs(T);const $=m.isNumber(x)&&x>-1,q=m.isNumber(j)&&j>-1,X=Y=>m.hasOwnProp(T,Y)?T[Y]:void 0;let G=r||fetch;F=F?(F+"").toLowerCase():"text";let V=ta([P,U&&U.toAbortSignal()],g),z=null;const fe=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let pe;try{let Y;const J=X("auth");if(J){const M=J.username||"",oe=J.password||"";Y={username:M,password:oe}}if(la(N)){const M=new URL(N,le.origin);if(!Y&&(M.username||M.password)){const oe=zn(M.username),be=zn(M.password);Y={username:oe,password:be}}(M.username||M.password)&&(M.username="",M.password="",N=M.href)}if(Y&&(I.delete("authorization"),I.set("Authorization","Basic "+btoa(ia((Y.username||"")+":"+(Y.password||""))))),$&&typeof N=="string"&&N.startsWith("data:")&&oa(N)>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);if(q&&C!=="get"&&C!=="head"){const M=await A(I,b);if(typeof M=="number"&&isFinite(M)&&M>j)throw new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,T,z)}if(v&&f&&C!=="get"&&C!=="head"&&(pe=await A(I,b))!==0){let M=new o(N,{method:"POST",body:b,duplex:"half"}),oe;if(m.isFormData(b)&&(oe=M.headers.get("content-type"))&&I.setContentType(oe),M.body){const[be,ve]=Vn(pe,St(qn(v)));b=Kn(M.body,Wn,be,ve)}}m.isString(k)||(k=k?"include":"omit");const Ke=a&&"credentials"in o.prototype;if(m.isFormData(b)){const M=I.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&I.delete("content-type")}I.set("User-Agent","axios/"+Tn,!1);const We={...O,signal:V,method:C.toUpperCase(),headers:Ys(I.normalize()),body:b,duplex:"half",credentials:Ke?k:void 0};z=a&&new o(N,We);let Ee=await(a?G(z,O):G(N,We));if($){const M=m.toFiniteNumber(Ee.headers.get("content-length"));if(M!=null&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}const xe=E&&(F==="stream"||F==="response");if(E&&Ee.body&&(L||$||xe&&fe)){const M={};["status","statusText","headers"].forEach(Fe=>{M[Fe]=Ee[Fe]});const oe=m.toFiniteNumber(Ee.headers.get("content-length")),[be,ve]=L&&Vn(oe,St(qn(L),!0))||[];let lt=0;const vn=Fe=>{if($&&(lt=Fe,lt>x))throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);be&&be(Fe)};Ee=new i(Kn(Ee.body,Wn,vn,()=>{ve&&ve(),fe&&fe()}),M)}F=F||"text";let Ae=await y[m.findKey(y,F)||"text"](Ee,T);if($&&!E&&!xe){let M;if(Ae!=null&&(typeof Ae.byteLength=="number"?M=Ae.byteLength:typeof Ae.size=="number"?M=Ae.size:typeof Ae=="string"&&(M=typeof s=="function"?new s().encode(Ae).byteLength:Ae.length)),typeof M=="number"&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}return!xe&&fe&&fe(),await new Promise((M,oe)=>{zs(M,oe,{data:Ae,headers:ue.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:T,request:z})})}catch(Y){if(fe&&fe(),V&&V.aborted&&V.reason instanceof D){const J=V.reason;throw J.config=T,z&&(J.request=z),Y!==J&&(J.cause=Y),J}throw Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,T,z,Y&&Y.response),{cause:Y.cause||Y}):D.from(Y,Y&&Y.code,T,z,Y&&Y.response)}}},ca=new Map,Qs=e=>{let t=e&&e.env||{};const{fetch:n,Request:s,Response:r}=t,o=[s,r,n];let i=o.length,l=i,a,c,u=ca;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:aa(t)),u=c;return c};Qs();const Sn={http:Pl,xhr:ea,fetch:{get:Qs}};m.forEach(Sn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Xn=e=>`- ${e}`,ua=e=>m.isFunction(e)||e===null||e===!1;function da(e,t){e=m.isArray(e)?e:[e];const{length:n}=e;let s,r;const o={};for(let i=0;i<n;i++){s=e[i];let l;if(r=s,!ua(s)&&(r=Sn[(l=String(s)).toLowerCase()],r===void 0))throw new D(`Unknown adapter '${l}'`);if(r&&(m.isFunction(r)||(r=r.get(t))))break;o[l||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
|
+
`+i.map(Xn).join(`
|
|
5
|
+
`):" "+Xn(i[0]):"as no adapter specified";throw new D("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return r}const Zs={getAdapter:da,adapters:Sn};function $t(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rt(null,e)}function Qn(e){return $t(e),e.headers=ue.from(e.headers),e.data=Bt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Zs.getAdapter(e.adapter||st.adapter,e)(e).then(function(s){$t(e),e.response=s;try{s.data=Bt.call(e,e.transformResponse,s)}finally{delete e.response}return s.headers=ue.from(s.headers),s},function(s){if(!Ws(s)&&($t(e),s&&s.response)){e.response=s.response;try{s.response.data=Bt.call(e,e.transformResponse,s.response)}finally{delete e.response}s.response.headers=ue.from(s.response.headers)}return Promise.reject(s)})}const Nt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Nt[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Zn={};Nt.transitional=function(t,n,s){function r(o,i){return"[Axios v"+Tn+"] Transitional option '"+o+"'"+i+(s?". "+s:"")}return(o,i,l)=>{if(t===!1)throw new D(r(i," has been removed"+(n?" in "+n:"")),D.ERR_DEPRECATED);return n&&!Zn[i]&&(Zn[i]=!0,console.warn(r(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}};Nt.spelling=function(t){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function fa(e,t,n){if(typeof e!="object")throw new D("options must be an object",D.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let r=s.length;for(;r-- >0;){const o=s[r],i=Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0;if(i){const l=e[o],a=l===void 0||i(l,o,e);if(a!==!0)throw new D("option "+o+" must be "+a,D.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new D("Unknown option "+o,D.ERR_BAD_OPTION)}}const At={assertOptions:fa,validators:Nt},he=At.validators;let Re=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Hn,response:new Hn}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const o=(()=>{if(!r.stack)return"";const i=r.stack.indexOf(`
|
|
6
6
|
`);return i===-1?"":r.stack.slice(i+1)})();try{if(!s.stack)s.stack=o;else if(o){const i=o.indexOf(`
|
|
7
7
|
`),l=i===-1?-1:o.indexOf(`
|
|
8
8
|
`,i+1),a=l===-1?"":o.slice(l+1);String(s.stack).endsWith(a)||(s.stack+=`
|
|
9
|
-
`+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=_e(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&it.assertOptions(s,{silentJSONParsing:me.transitional(me.boolean),forcedJSONParsing:me.transitional(me.boolean),clarifyTimeoutError:me.transitional(me.boolean),legacyInterceptorReqResOrdering:me.transitional(me.boolean)},!1),r!=null&&(E.isFunction(r)?n.paramsSerializer={serialize:r}:it.assertOptions(r,{encode:me.function,serialize:me.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),it.assertOptions(n,{baseUrl:me.spelling("baseURL"),withXsrfToken:me.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&E.merge(o.common,o[n.method]);o&&E.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||ln;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,m=0,f;if(!a){const h=[Gn.bind(this),void 0];for(h.unshift(...l),h.push(...c),f=h.length,u=Promise.resolve(n);m<f;)u=u.then(h[m++],h[m++]);return u}f=l.length;let y=n;for(;m<f;){const h=l[m++],p=l[m++];try{y=h(y)}catch(A){p.call(this,A);break}}try{u=Gn.call(this,y)}catch(h){return Promise.reject(h)}for(m=0,f=c.length;m<f;)u=u.then(c[m++],c[m++]);return u}getUri(t){t=_e(this.defaults,t);const n=Vs(t.baseURL,t.url,t.allowAbsoluteUrls);return ks(n,t.params,t.paramsSerializer)}};E.forEach(["delete","get","head","options"],function(t){we.prototype[t]=function(n,s){return this.request(_e(s||{},{method:t,url:n,data:(s||{}).data}))}});E.forEach(["post","put","patch"],function(t){function n(s){return function(o,i,l){return this.request(_e(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}we.prototype[t]=n(),we.prototype[t+"Form"]=n(!0)});let Ql=class zs{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 We(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 zs(function(r){t=r}),cancel:t}}};function Zl(e){return function(n){return e.apply(null,n)}}function ea(e){return E.isObject(e)&&e.isAxiosError===!0}const Kt={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(Kt).forEach(([e,t])=>{Kt[t]=e});function Js(e){const t=new we(e),n=xs(we.prototype.request,t);return E.extend(n,we.prototype,t,{allOwnKeys:!0}),E.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return Js(_e(e,r))},n}const z=Js(Ke);z.Axios=we;z.CanceledError=We;z.CancelToken=Ql;z.isCancel=Ys;z.VERSION=Ws;z.toFormData=yt;z.AxiosError=F;z.Cancel=z.CanceledError;z.all=function(t){return Promise.all(t)};z.spread=Zl;z.isAxiosError=ea;z.mergeConfig=_e;z.AxiosHeaders=ue;z.formToJSON=e=>$s(E.isHTMLForm(e)?new FormData(e):e);z.getAdapter=Ks.getAdapter;z.HttpStatusCode=Kt;z.default=z;const{Axios:Wd,AxiosError:zd,CanceledError:Jd,isCancel:Xd,CancelToken:Qd,VERSION:Zd,all:ef,Cancel:tf,isAxiosError:nf,spread:sf,toFormData:rf,AxiosHeaders:of,HttpStatusCode:lf,formToJSON:af,getAdapter:cf,mergeConfig:uf}=z,oe={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=>{}},Wn=Object.keys(oe),Xs=O.createContext(),Qs=({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]=O.useState({onAction:e?.onAction||oe.onAction,onChange:e?.onChange||oe.onChange,onFormComplete:e?.onFormComplete||oe.onFormComplete,onFormLoad:e?.onFormLoad||oe.onFormLoad,onGetComponent:e?.onGetComponent||oe.onGetComponent,onGetCYA:e?.onGetCYA||oe.onGetCYA,onGetCYARows:e?.onGetCYARows||oe.onGetCYARows,onGoingBack:e?.onGoingBack||oe.onGoingBack,onPageChange:e?.onPageChange||oe.onPageChange,onRequest:e?.onRequest||oe.onRequest,onSubmit:e?.onSubmit||oe.onSubmit,onValidate:e?.onValidate||oe.onValidate,onCancel:e?.onCancel||oe.onCancel}),r=(i,l)=>{Wn.includes(i)&&s(a=>({...a,[i]:l||oe[i]}))},o=i=>{Wn.includes(i)&&s(l=>({...l,[i]:oe[i]}))};return d.jsx(Xs.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},ge=()=>O.useContext(Xs),ta=()=>{const{hooks:e}=ge(),[t,n]=O.useState({});return O.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},un=O.createContext(),Zs=({children:e=null})=>{const{hooks:t}=ge(),[n,s]=O.useState([]),[r,o]=O.useState([]),i=f=>{o(y=>[...y,...f].filter(h=>!!h))},l=f=>{typeof f=="function"&&o(y=>y.filter(h=>!f(h)))},a=()=>{r.length&&o([])},c=f=>{s(y=>[...y,...f].filter(h=>!!h))},u=()=>{o([]),s([])},m={page:f=>{const y=g.Validate.page(f,r),h=t.onValidate(f,y);return s(h),h},pages:f=>{const y=f.map(p=>g.Validate.page(p,r)),h=f.flatMap((p,A)=>t.onValidate(p,y[A]));return s(h),h}};return d.jsx(un.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:m},children:e})},De=()=>O.useContext(un),Lt={},Dt={},na="idle",sa="fetching",er="fetched",tr="error",ra=(e,t=!0)=>{const n=ta(),s=O.useRef(z.CancelToken.source()),[r,o]=O.useState(na),[i,l]=O.useState(null),[a,c]=O.useState(null),u=()=>{s.current&&s.current.cancel()};return O.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(sa);let f;if(t&&Lt[e])f=Lt[e];else{if(t&&Dt[e])throw Dt[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(h=>{throw l(h),h})).data,t&&(Lt[e]=f)}c(f),o(er)}catch(f){t&&(Dt[e]=f),l(f),c(null),o(tr)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},oa="loading",lt="complete",ia=e=>{const t=e.data;if(t&&!t.options||t?.url)return T.Utils.interpolateString(t.url,e.formData)},la=(e,t)=>{const n=ia({...e,formData:t}),{status:s,data:r}=ra(n,e?.data?.useCache),[o,i]=O.useState([]),[l,a]=O.useState(oa);return O.useEffect(()=>{n?s===er?(r&&i(le.refData.toOptions(r.data||r,e.item)),a(lt)):s===tr&&(i([]),a(lt)):(e.data&&e.data.options&&i(le.refData.toOptions(e.data.options,e.item)),a(lt))},[e.id,s,r,n]),{data:o,status:l}},$e=(e,t)=>{const n=Q(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(T.FormGroup,{...n,onChange:null,children:t})},dn=(e,t,n,s,r={})=>{if(!t)return[];const o=g.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 dn(e,u,n,s,r);const m=g.Validate.page(u);return s.onValidate(u,m)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},fn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Fe,{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"}),aa="Continue",Wt=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?G.DEFAULTS[e]:e,r=G.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||aa}):null},ca="hods-form-confirmation",ua="Are you sure?",da="Confirm",fa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=T.Utils.classBuilder(ca,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||ua}),s,d.jsx(T.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||da}),d.jsx(T.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},hn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===b.CONTAINER?hn(t):ze.editable(t)?t:null).filter(t=>!!t):[],ha=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===b.CONTAINER?zt(r):(n.type===b.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===b.CONTAINER&&(r.data.options[i].nested[a]=zt(l))})}),r)})},zt=e=>{if(e){const t=ha(e);return{...e,components:t}}return e},ma=(e,t)=>e.some(n=>ze.show(n,t)),pa=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=hn(e);return n.length>0?ma(n,t):!0},St={editableComponents:hn,setup:zt,show:pa},Ea=(e,t)=>e.some(n=>Ce(n,t)),Ct=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=St.editableComponents(e);return n.length>0?Ea(n,t):!0},Aa=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Ct(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(m=>m.id===a)});return}const c=l.components.find(m=>m.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){xe(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},mn=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(T.ButtonGroup,{children:e.map((n,s)=>d.jsx(Wt,{action:n,onAction:t},s))}),ya=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?se.meetsOne(t.runWhen?.constraint,e.formData):!1},nr="hods-form__page",pn=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=nr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:m})=>{const[f,y]=O.useState({}),{errors:h,validate:p}=De(),[A,w]=O.useState({}),[L,C]=O.useState(!1),I=O.useMemo(()=>ya(e),[e]);O.useEffect(()=>{C(!0)},[]),O.useEffect(()=>{L&&I&&p.page(e)},[m,L]);const _=({target:x})=>{const k=e,{value:P}=x;P?(k.formData[x.name]=P,y(N=>({...N,[x.name]:P})),w(N=>({...N,[x.component]:x.label}))):(delete k.formData[x.name],y(N=>{const{[x.name]:j,...M}=N;return M}),w(N=>{const{[x.component]:j,...M}=N;return M})),typeof o=="function"&&o(e.formData)};O.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=h.length>0?"Error: "+x:x},[h]);const U=g.classBuilder(l,a,c),S=e;S.actions=S.actions?.map(x=>x.label?{...x,label:g.interpolateString(x.label,S.formData)}:x),S.formData=g.Operate.runPageOperations(S,{...S.formData,...f},s||_);const R=e.title?d.jsx(T.Heading,{size:e.titleSize,children:g.FormPage.getTitle(e.title,e.formData)}):d.jsx(T.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(x=>g.Component.show(x,e.formData)).map((x,k)=>d.jsx(Fe,{component:x,onAction:P=>n(P,f,A),onChange:s||_,onTopLevelChange:r||_,value:e.formData[x.fieldId]||f[x.fieldId],formData:e.formData,pages:t,submitting:u},k));let D=null;return I&&h?.length>0?D=[{error:e?.customValidation?.[0]?.message}]:h?.length>0&&!I&&(D=h),d.jsxs("div",{className:U(),children:[D&&d.jsx(T.ErrorSummary,{errors:D,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:R}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[R,v]}),d.jsx(mn,{actions:e.actions?.filter(x=>g.Component.show(x,e.formData)),onAction:x=>n(x,f,A)})]},e.id)},zn="hods-form-banner-strip",sr=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=g.classBuilder(zn,s,""),o=t.filter(i=>g.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:g.interpolateString(c,n)})},a)}return d.jsx(T.Tag,{classBlock:`${zn}__tag`,classModifiers:i.classModifiers,text:g.interpolateString(i.text,n)},a)})})},Ta=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{}},En=({row:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ta(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},rr=({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(En,{row:e})})]}),or=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(T.SmallHeading,{children:e})}),at=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=wt(o,t);return t.type==="title"?d.jsx(or,{title:t.key,classes:n}):d.jsx(rr,{row:{key:i.key,value:d.jsx(fn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Sa="govuk-summary-card",Ca="govuk-summary-list",tt="Item",nt="Change",Jn="Delete",ga="warning",ba=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=T.Utils.classBuilder(Sa,i,n.className),c=T.Utils.classBuilder(Ca,[]);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||tt,{...t,index:t.index+1})}),n.banners&&d.jsx(sr,{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||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt}):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||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt})}),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||ga,"aria-label":T.Utils.interpolateString(`${n.deleteAction?.label||Jn} ${n.title||tt}`,{...t,index:t.index+1}),children:n.deleteAction.label||Jn})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const m=u.components.map(f=>g.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const h=f.columns.filter(p=>se.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return h.length?h.flatMap(p=>{const A=m.find(w=>w.fieldId===p);return A?at(u,A,c,t,l):null}):null})})})})]})},wa=({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=>g.Component.show(a,o)).map(a=>d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||Xn},e))}):d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||Xn}),Ia=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},gt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ia(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},ir=[b.ALERT,b.COLLECTION_SUMMARY,b.DETAILS,b.HEADING,b.HTML,b.INSET_TEXT],ut=(e,t)=>{if(!e||ir.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===b.COLLECTION){if(!ee(t,e.full_path||e.fieldId)?.length)return!1}else{const n=ee(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===b.CONTAINER?St.show(e,t):ze.show(e,t)},lr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>ir.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),_a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:gt(!1,e,t)}],Pa=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.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}`}))}),xa=(e,t,n,s,r)=>{const o={...ve,...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},An=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&ut(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Pa(t,o,l,a);return c=lr(c),[xa(t,o,e.id,l,a),...je(e,c,o,s,r)]}).filter(o=>!!o):_a(e,s),Na="hods-form-summary-card-details",ar=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=g.classBuilder(Na,r),a=O.useMemo(()=>t.map(u=>e.childPages.find(m=>m.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,m,f)=>{let y=0;return u.flatMap((h,p)=>{let A=0;const w=h.fields?.flatMap(C=>m.filter(_=>_.fieldId===C).map(_=>{if(!_||!Ce(_,{...f.formData,...s}))return null;if(_.type===b.CONTAINER){const U=je(f,_,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(S=>{const R={...s,[S.fieldId]:s[_.fieldId]?.[S.fieldId]};return at(f,{...S,label:S.key},l,R,i)})},C)}if(_.type===b.COLLECTION){const U=An({...f,formData:{...f.formData,...s}},_,s[_.id]);A+=1;let S=0;return d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(R=>{const v={...s,[R.fieldId]:s[_.fieldId]?.[R.fieldId]},D=at(f,{...R,label:R.key},l,v,i);return R.type==="title"&&(S+=1,S>1)?d.jsx("div",{style:{marginTop:"40px"},children:D}):D})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:at(f,_,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&w.length!==0?(y+=2,[...w,d.jsx("div",{className:l("divider"),style:{"--column":y}},`divider${y}`)]):w}).filter(h=>!!h)};return e?.childPages?.filter(u=>g.FormPage.show(u,{...n,...s})).map(u=>{const m=g.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!g.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const h=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return h&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(ar,{masterPage:h,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const y=f.columns.filter(h=>se.meetsAll(h,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:g.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":y.length-1},children:c(y,m,u)})]},f.title)})}).filter(u=>!!u)||null},Oa="hods-form-summary-card",Xn="Change",Ra="Delete",va="Quick Edit",La="Duplicate",Da="Full details",Qn="secondary",Zn=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:m,hideDetails:f=!1})=>{const[y,h]=O.useState(!1),p=T.Utils.classBuilder(Oa,s,n.className),A=O.useMemo(()=>n.quickEdit?Aa(m,u,t):null,[m,n,u,t,y]),{addErrors:w,resetQuickEditErrors:L,clearTopLevelErrorsForCard:C,validate:I}=De(),{hooks:_}=ge(),U=async(S,R)=>{if(S.type==="cancel"&&(h(v=>!v),L?.()),S.type==="save"&&typeof l=="function"){const v={...A.formData,...R,[`${a}ActiveId`]:t.id},D=I.page({...A,formData:v});if(D.length)return;let x;await _.onSubmit("quickEdit",v,()=>{},P=>{x=P}),x&&w(x);const k=D.concat(x);if(k.length===0||k.length===1&&k[0]===void 0){C();const P=g.CollectionPage.getData(a,u),{isDuplicate:N,...j}=P[t.index];P[t.index]={...j,...R},l({target:{name:a,value:P}}),h(M=>!M)}}};return n.listView?d.jsx(ba,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:m,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(sr,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:g.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:g.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(T.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>h(S=>!S),classModifiers:"primary",disabled:y,name:"QuickEdit",autoFocus:n.focusOn,children:va}),n.changeAction&&typeof r=="function"&&d.jsx(wa,{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":g.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ra}),n.duplicateAction&&typeof i=="function"&&d.jsx(T.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":g.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||La})]})]}),y&&A&&d.jsx(pn,{page:A,onAction:(S,R)=>U(S,R),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(T.Details,{summary:n.detailsTitle||Da,className:"details",children:d.jsx(ar,{masterPage:m,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Fa=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=ge(),o=t.filter(m=>m.entryId===e)||[],[i,l]=O.useState(null),a=()=>{l(null)},c=m=>{l(f=>(f??[]).concat(m))},u={page:m=>{const f=g.Validate.page(m),y=r.onValidate(m,f);return l(y),y}};return d.jsx(un.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},es="Add",ja=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=ge(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:m,dequeueErrors:f}=De(),[y,h]=O.useState(null),p=O.useMemo(()=>g.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((R,v)=>v.isDuplicate&&(!R||v.id>R.id)?v:R,null):null,w=O.useMemo(()=>{const R=e.collectionName.split(".");let v=g.CollectionPage.mergePages(o||[])||[];return R.reduce((D,x,k)=>{const P=k===0?`${D}${x}`:`${D}.${x}`;return k===R.length-1?v?.find(N=>N.collection?.name===P)||null:(v=v.find(N=>N.collection?.name===P)?.childPages||null,P)},"")},[o]),L=O.useMemo(()=>e.card.listView?w.childPages?.reduce((v,D)=>{const x=He(D.components,{...t,...y});return v.concat(x)},[])||[]:[],[w,t,y,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const R=dn(e,w,t,i);R.length>0&&m(R)};O.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const I=(R,v)=>{if(typeof n=="function"){const D=[...p],x=p.findIndex(N=>N.id===v),{isDuplicate:k,...P}=p[x];D[x]={...P},n({type:st.SAVE_AND_NAVIGATE,page:R,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:D,isCollection:!0}]})}},_=R=>{g.CollectionPage.duplicateEntry(e.collectionName,t,R.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:g.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!y)return;g.CollectionPage.removeEntry(e.collectionName,t,y.id);const R=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:R,value:g.CollectionPage.getData(R,t)}}),h(null),C()},S=R=>{const v=L.find(x=>x.fieldId===R);if(!v)return null;const D=wt({...w,formData:{...t,...y}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(fn,{value:D.value,component:D.component,formData:D.formData})},R)};return d.jsxs("div",{id:e.fieldId,children:[y&&d.jsx(fa,{id:`${e.fieldId}.confirmation`,message:g.interpolateString(e.confirmation?.message,{...y,index:y.index+1})||null,confirmLabel:g.interpolateString(e.confirmation?.label,y)||null,onConfirm:U,onCancel:()=>h(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(S)}):d.jsx(Zn,{id:`${e.fieldId}.confirmationChild`,entryData:y,config:e.card?{...e.card,quickEdit:null}:{},masterPage:w,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((R,v)=>{const D=l.filter(P=>P.entryId===R.id).length>0,x={...e.card,...R.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...D&&e.errorCard?e.errorCard:{},focusOn:A?.id===R.id},k=`${e.fieldId}.summaryCard${R.id}`;return d.jsx("li",{children:d.jsx(Fa,{entryId:R.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const P=l.filter(N=>N.entryId!==R.id);c(),a(P)},children:d.jsx(Zn,{id:k,entryData:{...R,index:v},masterPage:w,config:x||{},onFullEdit:I,onDuplicate:_,onDelete:()=>h({...R,index:v}),onQuickEdit:P=>(C(),s(P)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:R.id===y?.id?["deleting-summary-card"]:[""],inError:l.filter(P=>P.entryId===R.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Ua="hods-form-collection",Ma=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=O.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===g.Meta.name)s({target:p});else{const A=i.findIndex(w=>w.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:mt.v4()}])},m=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;O.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,w=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');w&&w.length>0&&w[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),O.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const y={...ve,...e.labels},h=g.classBuilder(Ua,[],e.className);return d.jsxs("div",{className:h(),id:e.id,children:[e.label&&d.jsx(T.Label,{id:e.id,required:e.required,className:h("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const w=`${e.full_path||e.fieldId}[${A}]`,L=(e.countOffset||0)+A+1,C=g.interpolateString(y.item,{...p,index:L}),I=g.interpolateString(y.remove,{...p,index:L}),_=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${h("item")}`,style:U,children:[d.jsxs(T.Label,{id:p.id,required:!0,className:h("item-title"),children:[C,_==="start"&&d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})]}),d.jsx(Cn,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:w,components:e.item.map(S=>{const{firstOnlyLabel:R,...v}=S;let{hint:D}=S;e.restrictHint&&A>0&&(D=void 0);let{label:x}=S;return A===0&&(x=S.firstOnlyLabel??S.label),{...v,hint:D,readonly:!!(e?.readonly||S.readonly),label:g.interpolateString(x,{...p,index:L}),full_path:`${w}.${S.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),_==="end"&&d.jsx(T.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(T.ButtonGroup,{children:d.jsx(T.Button,{onClick:u,classModifiers:"secondary",children:f(y)})})]})},ka=(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},$a=(e,t)=>typeof e=="string"?!!T.Utils.interpolateString(e,t):!!e,Ft=(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}}},Ba=[b.RADIOS,b.CHECKBOXES,b.DATE,b.TIME],Ya=e=>e.fieldset||Ba.includes(e.type),Fe=({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}=ge(),m=De(),{data:f,status:y}=la(e,n),[h,p]=O.useState([]);O.useEffect(()=>{y===lt&&p(f)},[e,f,y]);const A=({target:C})=>typeof o=="function"?(e.type===b.EMAIL&&(C.value=C.value.trim()),e.type===b.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(I=>{I.children&&I.nested&&(delete I.children,delete I.nested)}),C=ka(C,e,f),e.type===b.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(O.useEffect(()=>{const C=g.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===b.CONTAINER){let C=d.jsx(Cn,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=$e(e,C)),e.additionalValidation&&(C=$e({...e,...Ft(e,m?.errors)},C)),C}if(e.type===b.COLLECTION)return d.jsx(Ma,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});if(e.type===b.COLLECTION_SUMMARY)return $e({...e,...Ft(e,m?.errors)},d.jsx(ja,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const w=C=>{let I=e.full_path||e.fieldId;if(e.pageCollection){const _=g.CollectionPage.getActiveIndex(e.pageCollection.name,n);I=`${`${e.pageCollection.name}[${_}]`}.${I}`}i({target:{name:g.Meta.name,value:g.Meta.documents.setForField(C,n,I,e.allowMultiple)}})},L=({target:C})=>{if(A({target:C})){if(e.type===b.FILE)w([C.value]);else if(e.type===b.MULTI_FILE){const I=C.value.map((_,U)=>({..._,indexInField:U}));w(I)}}};return g.Component.get({...c,...e,id:e.full_path||e.id,...Ft(e,m?.errors),fieldset:Ya(e),disabled:$a(e.disabled,n),label:g.interpolateString(e.label,n),content:g.interpolateString(e.content,n),hint:g.interpolateString(e.hint,n),cya_label:g.interpolateString(e.cya_label,n),suffix:g.interpolateString(e.suffix,n),options:h,value:t,onChange:L,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},Ha=[b.AUTOCOMPLETE,b.CALCULATION,b.CHECKBOXES,b.COLLECTION_SUMMARY,b.DATE,b.EMAIL,b.FILE,b.MULTI_FILE,b.PHONE_NUMBER,b.RADIOS,b.SELECT,b.TEXT,b.TEXT_AREA,b.TIME],cr=e=>Ha.includes(e?.type)||e?.isEditable||!1,Va="govuk-list",qa="govuk-body",Ga=e=>{const t=Q(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})},Ka=e=>{const t=Q(e),n=le.getAutocompleteSource(e);return d.jsx(T.Autocomplete,{...t,source:n})},Wa=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Checkboxes,{...n,options:t})},za=e=>{const t=le.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=Q(e,["formula"]);return d.jsx(T.TextInput,{...n,readonly:!0})},Ja=e=>{const t=Q(e);return d.jsx(T.DateInput,{...t})},Xa=e=>{const t=Q(e,["tagName"]),n=bt(e);return d.jsx(T.Details,{...t,children:n})},Qa=e=>{const t=Q(e);return d.jsx(T.FileUpload,{...t})},Za=e=>{const t=Q(e);return d.jsx(T.MultiFileUpload,{...t})},ec=e=>{const t=Q(e);return d.jsx(T.Heading,{...t,children:e.content})},bt=e=>{const t=Q(e);return d.jsx(T.Markup,{...t})},tc=e=>{const t=Q(e);return d.jsx(T.InsetText,{...t,children:e.content})},nc=e=>{const t=Q(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=T.Utils.classBuilder(Va,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return bt({...t,className:r(),tagName:n,content:o,type:b.HTML})},sc=e=>{const t=Q(e);return bt({className:qa,...t,tagName:"p",type:b.HTML})},rc=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Radios,{...n,options:t})},oc=e=>{const t=Q(e);return d.jsx(T.TextArea,{...t})},ic=e=>{const t=Q(e);return d.jsx(T.TextInput,{...t})},lc=e=>{const t=Q(e);return d.jsx(T.TimeInput,{...t})},ac=e=>{let t=[];le.getOptions(e,s=>{t=s});const n=Q(e);return d.jsx(T.Select,{...n,options:t})},cc=e=>{const t=Q(e);return d.jsx(T.WarningText,{...t,children:e.content})},uc=e=>{switch(e.type){case b.HTML:return bt(e);case b.HEADING:return ec(e);case b.INSET_TEXT:return tc(e);case b.TEXT:case b.EMAIL:case b.PHONE_NUMBER:return ic(e);case b.TEXT_AREA:return oc(e);case b.AUTOCOMPLETE:return Ka(e);case b.RADIOS:return rc(e);case b.CHECKBOXES:return Wa(e);case b.DATE:return Ja(e);case b.TIME:return lc(e);case b.FILE:return Qa(e);case b.MULTI_FILE:return Za(e);case b.WARNING:return cc(e);case b.SELECT:return ac(e);case b.DETAILS:return Xa(e);case b.CALCULATION:return za(e);case b.ALERT:return Ga(e);case b.PARAGRAPH:return sc(e);case b.LIST:return nc(e);default:return null}},dc=(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]||le.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:dr(n,!1)})):d.jsx(Fe,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},ur=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!se.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:dc(e,s)},s.id));return n.length>0?n:null},dr=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=uc(e);return s&&t&&cr(e)?$e(e,s):s},fc=e=>e.defaultValue||e.defaultObjectValue,hc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?q().format("DD-MM-YYYY"):n},mc=(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"&&ee(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},fr=(e,t)=>fc(e)?e.type===b.DATE?hc(e):(e.defaultObjectValue?mc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,pc={[b.COLLECTION]:[],[b.CONTAINER]:{}},Ec=(e,t)=>e&&(fr(e,t)||pc[e.type])||"",ze={clean:Q,defaultValue:Ec,defaultValueFromConfig:fr,editable:cr,elevateNested:He,get:dr,setupContainerPaths:lr,show:Ce,wrap:$e},Ac=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ye(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},wt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Ac(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:ze.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:gt(t.readonly,e,n)}},je=(e,t,n,s,r)=>ut(t,{...e.formData,...n})?He(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>ut(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===b.CONTAINER?je(e,i,{...l,...n},s,r):i.type===b.COLLECTION?An(e,i,l,s,r):wt({...e,formData:n},i,s)}):null,yc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{g.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ts=(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:xe(r.show_when,t));return typeof s=="string"?T.Utils.interpolateString(s,t):T.Utils.interpolateString(s[n],t)},Tc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Sc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return G.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return G.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),Tc(n)}}).filter(t=>!!t)},Cc=e=>({type:b.HTML,tagName:"p",content:e}),gc=(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?Jt(l,t):l)),r},Jt=(e,t)=>{if(e){const n=gc(e,t);if(n)return n}return{...e}},hr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return Cc(o);let i;return o.type===b.CONTAINER&&(o.components=o.components.map(l=>l.use?Jt(l,t):l)),o.use?i=Jt(o,t):i={...o},n?le.refData.setupUrl(i,n):i}),r=Sc(e);return St.setup({...e,formData:n,components:s,actions:r})},bc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...hr(s,t,n),index:r})):[],mr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Ct(e,t),Je={applyConditionalProperties:yc,getConditionalText:ts,get:hr,getAll:bc,getTitle:(e,t)=>ts(e,t,"title"),show:Ct,showCYA:mr},wc=(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},Ic=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},It=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},_c=e=>typeof e=="number"&&e>=0,pr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return _c(o)?(e.shift(),pr(e,t[s][o],n)):null},Ue=(e,t)=>{const n=e.split(".");return pr(n,t,t)},Er=(e,t,n,s=[],r={})=>{const o=Ue(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=mt.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},Pc=(e,t)=>{const n=It(e,t);return Er(e,t,n)},xc=e=>typeof e=="number"&&e>=0,Ar=(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 xc(o)?e.length===1?o:(e.shift(),Ar(e,t[s][o],n)):null},yr=(e,t)=>{const n=e.split(".");return Ar(n,t,t)},Nc=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]}),Oc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Rc=(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},Tr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Nc(s);return t[s.collection.name]=o,o}return Oc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Rc(s,t)?null:s).filter(s=>!!s)},vc=(e,t,n)=>{const s=Ue(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},Lc=e=>typeof e=="number"&&e>=0,yn=(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=mt.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 Lc(a)?(o=o[i][a],!1):!0})},dt={addEntry:Ic,duplicateActiveEntry:Pc,duplicateEntry:Er,getActiveId:It,getActiveIndex:yr,getData:Ue,getErrorsForCollection:dn,mergePages:Tr,removeEntry:vc,setData:yn},Dc=e=>typeof e=="number"&&e>=0,Fc=(e,t,n,s,r,o)=>{const i=r?.label||ve.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[y,h]=f;c[y]=h});const u=dt.getData(e.collection.name,c),m=u?.findIndex(f=>f.id===t.id);return Dc(m)&&u.splice(m,1),c})},label:T.Utils.interpolateString(i,{...t,index:s})}}},jc=(e,t,n,s,r,o={})=>{const i=r?.label||ve.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(m=>{const[f,y]=m;u[f]=y}),u};n(r.page?{pageId:r.page}:l,a)},label:T.Utils.interpolateString(i,{...t,index:s})}}},Uc=(e,t)=>t.show_when?xe(t.show_when,e):!0,Mc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.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}`}))}),kc=(e,t,n,s,r)=>{const o={...ve,...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"}},$c=(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"}},Bc=(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"}}),Yc=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Uc(r,i)).map(i=>i.type==="remove"?Fc(e,t,n,s,i,o):i.type==="change"?jc(e,t,n,s,i,o):null).filter(i=>!!i),Sr=(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)},Hc=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Cr(c,n,s,t,i));else if(c.collection.route&&(c=wc(c,c.collection.route)||c),mr(c,{...c.formData,...t})){const u=Sr(c,n,i);if(c.collection.heading){const y=c.collection.heading.changeLink?u:null,h=$c(c.collection.heading,c.id,r,y,t);l=l.concat(h)}const m=Mc(c,t,r,o),f=je({...c,formData:{...c.formData,...t}},m,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Cr=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?Sr({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(Bc(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?xe(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?xe(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((y,h)=>(c=h,y.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const y=c+1,h=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=Yc(e,f,t,y,s,r);if(!u){const w=kc(e,f,e.id,y,p);a=a.concat(w)}h==="top"&&(a=a.concat(A)),a=a.concat(Hc(e.childPages,f,t,n,y,p,r)),h==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},Vc=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Fe,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,qc=(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?Vc(t[o]):null})}),firstComponentIndex:n}},Gc=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=qc(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:gt(!1,e,s)},insertAt:o}},Kc=(e,t,n=null)=>{if(Je.showCYA(e,e.formData)){if(e.collection)return Cr(e,t,n,e.formData);const r=He(e.components,e.formData).filter(o=>ut(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case b.CONTAINER:return je(e,o,e.formData[o.fieldId],t,n);case b.COLLECTION:return An(e,o,e.formData[o.fieldId],t,n);default:return wt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=Gc(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[]},Wc={getRows:Kc,getCYARowsForContainer:je},gr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},br=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=gr(e.format,s[e.fieldId]))},wr=(e,t,n)=>{e.forEach(s=>br(s,t,n))},Ir=(e,t,n)=>{wr(e.components,t,n)},zc=(e,t,n)=>{e.forEach(s=>Ir(s,t,n))},Jc=(e,t,n)=>{const s={...t};return wr(e.components,s,n),zc(e.pages,s,n),s},Xc={component:br,data:gr,form:Jc,page:Ir},Qc=(e,t,n,s)=>{if(e===Z.HUB&&t){if(t.format===he.CYA)return he.CYA;if(t.components)return Je.get(t,n,s)}if(e===Z.TASK||e===Z.FORM_WITH_TASK)return he.TASK},Zc={get:Qc},Tn="meta",Sn="documents",Xt=e=>e?.[Tn]?.[Sn]||[],eu=(e,t,n,s)=>{const r=s?Xt(t):Xt(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Tn]:void 0,[Sn]:r}},tu={setForField:eu,get:Xt,name:Sn},nu={documents:tu,name:Tn},su=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return!!ee(t,n)}return!1},jt=(e,t)=>{if(e?.value)return e.value;const n=T.Utils.interpolateString(e?.field,t);return ee(t,n)},ru=(e,t)=>{if(!e||!t)return null;const n=T.Utils.interpolateString(e.target,t),s=ee(t,n),r=jt(e,t),o=jt(e.cutoff,t),i=jt(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&&ee(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},ou=(e,t,n)=>{let s;if(e?.field){const r=T.Utils.interpolateString(e.field,t);s=ee(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},iu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return ee(t,n)||null}return e?.value||null},lu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},au=(e,t)=>{if(e?.condition){const n=e,s=T.Utils.interpolateString(n.field,t),r=ee(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},cu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=T.Utils.interpolateString(s,t),o=ee(t,r);return o?(n=o,!0):!1}),n||(e.fallback?T.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},uu=(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=yr(l,t);s+=`${l}[${a}]`}else s+=i});const r=T.Utils.interpolateString(s,t);return ee(t,r)?.length||0},du=(e,t)=>{const n=T.Utils.interpolateString(e.target,t),s=ee(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?ee(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?ee(s,e.key)===e.value:!1},fu={checkValueIsTruthy:su,getIndexOfMatchingValueIn:ru,doesContainValue:du,persistValueInFormData:ou,setValueInFormData:iu,deleteValueInFormData:lu,getLength:uu,getFirstOf:cu},hu=(e,t,n)=>{const s=fu[e.function];if(typeof s=="function")return s(e,t,n)},mu=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(au(s.run_when,t)){const r=hu(s,t,n);if(s.output){const o=T.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");ws(t,o,r)}}}),t),pu={runPageOperations:mu},Eu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Au=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},yu=e=>/^-?\d+$/.test(e),ft=e=>yu(e)?e.padStart(2,"0"):"",ye=e=>{const[t,n,s]=e.split("-");return`${ft(t)}-${ft(n)}-${s}`},_r=e=>{const[t,n]=e.split(":");return`${ft(t)}:${ft(n)}`},Ee="DD-MM-YYYY";q.extend(Re);const Tu=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isAfter(n)};q.extend(Re);const Su=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isBefore(n)};q.extend(Re);const Cu=(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||Be(s,e[n.fieldId],e[n.fieldId])||Be(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ye(e[n.fieldId]?.[t.date]),a=_r(e[n.fieldId]?.[t.time]);return q(`${l} ${a}`,`${Ee} HH:mm`).isBefore(q())};q.extend(Re);q.extend(tn);const gu=(e,t)=>{const n=q(ye(e),Ee).isBefore(q()),s=q(ye(e),Ee).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};q.extend(Re);q.extend(tn);const bu=(e,t)=>q(ye(e),Ee).isAfter(q())?!0:!!t?.todayAllowed&&q(ye(e),Ee).isToday(),wu=(e,t)=>e?e.length>t.value:!0,Iu=(e,t)=>e?e.length<t.value:!0,_u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Pu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},xu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Nu=(e,t)=>e?t.array.includes(e):!0,Ou=(e,t,n,s)=>{if(!e||!s)return!0;const r=It(t.collectionPath,s);return!Ue(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)},Ru=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),vu=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Lu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,Du=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Lu.test(t)}return!1},Fu=(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,ju={conditionallyPermittedChange:Eu,conditionallyRequired:Au,mustBeAfter:Tu,mustBeBefore:Su,mustBeEarlierDateTime:Cu,mustBeGreaterThan:_u,mustBeInTheFuture:bu,mustBeInThePast:gu,mustBeLessThan:Pu,mustBeLongerThan:wu,mustBeNumbersOnly:xu,mustBeOneOf:Nu,mustBeShorterThan:Iu,mustBeUniqueInCollection:Ou,mustEnterAtLeastOne:Ru,mustHaveLessThanDecimalPlaces:vu,mustNotContainSql:Du,mustSelectOnlyOne:Fu},Uu=(e,t,n,s)=>{const r=ju[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Pr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Uu(t,r,e,n))}),s}},ht=(e,t,n)=>{if(!e)return[];const s=n||t,r=Pr(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;He(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Be({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Mu=(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(m=>({...m,message:T.Utils.interpolateString(o===0&&m.firstOnlyMessage?m.firstOnlyMessage:m.message,{index:i})}))),u})};s.push(ht(a,r,n))}),s.filter(r=>!!r).flat()};q.extend(Re);q.extend(tn);q.extend(Wr);const ku=(e,t)=>e==="02"?q().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,xr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ye(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=ku(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 q(t,Ee).format(Ee)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},$u=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,Bu=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,Nr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&($u.test(e)||Bu.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`}},Yu="Invalid files must be deleted",Or=(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 Yu}},Rr=(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"}},vr=(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`}},Lr=(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`}},Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=_r(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}},Hu=(e,t)=>e?.type==="or"?se.meetsOne(e.conditions,t):se.meetsAll(e.conditions,t),Be=(e,t,n)=>{const s=n||t;if(!Ce(e,{...s,...t}))return;if(e.type===b.CONTAINER)return ht(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===b.COLLECTION_SUMMARY&&(l=Ue(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!Hu(e.requiredOverrideConditions,s))&&(r=vr(l,e.label,e.custom_errors)),!r){switch(e.type){case b.COLLECTION:return Mu(e,l,s);case b.EMAIL:r=Nr(l,e.label,e.custom_errors);break;case b.DATE:case b.TIME:{const a=e.type===b.DATE?xr:Dr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case b.CHECKBOXES:case b.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ye(n[e.id],c)&&(a=a.concat(ht({components:c.nested},n)))}),a.length>0)return a;break}case b.MULTI_FILE:r=Or(l,e.custom_errors);break;case b.TEXT_AREA:r=Lr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=Rr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Pr(e,l,n),e.type===b.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},Vu=(e,t=[])=>{let n=e.formData;if(e.collection){const s=dt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...dt.getData(e.collection.name,e.formData)?.[s]})}return Ct(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ce(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Be(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:T.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},qu={component:Be,container:ht,email:Nr,date:xr,multifile:Or,page:Vu,regex:Rr,required:vr,textarea:Lr,time:Dr},g={CheckYourAnswers:Wc,CollectionPage:dt,Component:ze,Condition:se,Container:St,Data:le,Format:Xc,FormPage:Je,Hub:Zc,Meta:nu,Operate:pu,Validate:qu,...T.Utils},Gu="hods-form-container",Cn=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:m})=>{if(typeof s=="function")if(m.name===g.Meta.name)s({target:m});else{const f={...t,[m.name]:m.value};s({target:{name:e.fieldId,value:f}})}},a=m=>{const f=`${e.full_path||e.fieldId}.${m.fieldId}`;return m.type===b.CONTAINER?g.Container.show({...m,full_path:f},n):g.Component.show({...m,full_path:f},{...n,...ee(n,e.full_path)})},c=g.classBuilder(Gu,[],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((m,f)=>{const y=m.type===b.FILE?{}:"",h=t?t[m.fieldId]:y,p=`${e.full_path||e.fieldId}.${m.fieldId}`;return d.jsx(Fe,{...i,component:{...m,full_path:p,readonly:!!(e.readonly||m.readonly)},formData:n,value:h||y,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},Ku=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{}},ns=({group:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ku(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},Wu=({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})]}),zu=({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(En,{row:{action:e.action}})})]}),Ju="govuk-summary-list",Qt=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=Ju,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=T.Utils.classBuilder(r,o,i),u=T.Utils.cleanHtmlAttributes(a);let m=null;if(s){const f=e.filter(y=>!!y.action);m=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const y=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(or,{title:f.key,classes:c},y):f.type==="heading"?d.jsx(Wu,{title:f.key,size:f.size||"s",classes:c},y):f.type==="headingWithAction"?d.jsx(zu,{row:f,classes:c,noChangeAction:t},y):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(ns,{group:f})},`${y}-actions`):d.jsx(rr,{row:f,classes:c,showAction:!t},y)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(ns,{group:m})})]})})},Xu="hods-check-your-answers",Qu="Check your answers",ss=9,Zu=({title:e=Qu,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:m,groups:f,sections:y=[],type:h,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[w,L]=O.useState([]),[C,I]=O.useState([]),{errors:_}=De(),{hooks:U}=ge();O.useEffect(()=>{const N=(Y,H)=>g.CheckYourAnswers.getRows(Y,o,U.onGetCYARows).map((K,J)=>({...K,value:d.jsx(fn,{value:K.value,component:K.component,formData:Y.formData,placeholder:A},`${H}_${J}`)})),M=g.CollectionPage.mergePages(n).map((Y,H)=>{const V=N(Y,H);return V?.length?{...Y,rows:V}:null}).filter(Y=>!!Y);L(M)},[n,o,L]);const S=i?0:ss,R=N=>N===w.length-1;O.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map(M=>M.pageId):[];I(j)})()},[I,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:m,groups:f,errors:_,sections:y,type:h});if(v)return v;const D=N=>C.includes(N),x=N=>f?.find(j=>j.pageId===N),k=(N,j)=>{if(!N.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]});const M=gt(!1,N,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(En,{row:{action:M}})})]})},P=()=>Array.from(new Set(_.map(j=>j.id))).map(j=>_.find(M=>M.id===j));return d.jsxs("div",{className:Xu,children:[e&&!a&&d.jsx(T.Heading,{size:t,children:e},"heading"),_&&_.length>0&&d.jsx(T.ErrorSummary,{errors:P()}),h===Z.TASK_CYA&&w.length>0&&y&&y.map(N=>N.tasks.filter(j=>j.state!==B.TYPES.SKIPPED).map((j,M)=>{const Y=w.filter(H=>j.pages.some(V=>V===H.name));return d.jsxs(O.Fragment,{children:[d.jsx(T.MediumHeading,{children:Y.length>0&&(j.displayName||j.name)}),Y.map((H,V)=>{const K=D(H.id)||u,J=!i&&H.title&&!D(H.id);return d.jsxs(O.Fragment,{children:[J&&k(H,"s"),d.jsx(Qt,{rows:H.rows,classModifiers:c,noChangeAction:K,noGroupAction:m,isGroup:D(H.id)})]},V)})]},M)})),h!==Z.TASK_CYA&&w&&w.map((N,j,M)=>{const Y=!p||N.collection?N.rows:N.rows.filter(ae=>ae?.value?.props?.value);if(Y.length===0)return null;const H=!i&&N.title&&!D(N.id),V=R(j)||D(M[j].id)||M.length>j+1&&D(M[j+1].id)?ss:S,K=D(N.id)?x(N.id):void 0,J=`govuk-!-margin-bottom-${V}`,de=D(N.id)||u;return d.jsxs(O.Fragment,{children:[H&&k(N,"m"),K&&d.jsx("div",{className:"group-title",children:d.jsx(T.MediumHeading,{children:K.title||g.FormPage.getTitle(N.title,N.formData)})}),d.jsx(Qt,{className:J,rows:Y,classModifiers:c,noChangeAction:de,noGroupAction:m,isGroup:D(N.id)})]},j)}),!l&&d.jsx(mn,{actions:s?.filter(N=>g.Component.show(N,n[n.length-1].formData)),onAction:N=>r(N)})]})},ed=nr,td=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=ed,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=O.useState({});let m=g.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let y=g.CollectionPage.getActiveIndex(e.collection.name,e.formData);const h=e,p=({target:_})=>{g.CollectionPage.setData(h.collection.name,_.value,e.formData),m=_.value;const U=e.collection.name.split(".").shift();u(S=>({...S,[U]:g.CollectionPage.getData(U,e.formData)}))},A=({target:_})=>{h.formData[_.name]=_.value,u(U=>({...U,[_.name]:_.value}))},w=_=>{p({target:{value:_}}),typeof n=="function"&&n(e.formData)},L=_=>{y=m.length,A({target:{name:`${f}ActiveId`,value:_}})},C=_=>{s(_,c,{})},I=({target:_})=>{if(y===null){const U=mt.v4();L(U),w([...m,{id:U,[_.name]:_.value}])}else w([...m.slice(0,y),{...m[y],[_.name]:_.value},...m.slice(y+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(pn,{page:{...e,formData:{...e.formData,...m[y],[`${f}ActiveIndex`]:y,[`${f}NumberedIndex`]:typeof y=="number"?y+1:null},components:e.components.map(_=>({..._,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:I,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},nd="hods-task-list",sd=({state:e=B.TYPES.CANNOT_START_YET})=>{const t=T.Utils.classBuilder(nd,void 0,void 0),n=B.DETAILS[e]||B.DETAILS.cannotStartYet;return d.jsx(T.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},rd="hods-task-list",od=({task:e,onClick:t})=>{const n=T.Utils.classBuilder(rd,void 0,void 0),[s,r]=O.useState(e.state!==B.TYPES.CANNOT_START_YET),[o,i]=O.useState(e.state);O.useEffect(()=>{r(e.state!==B.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(sd,{state:o})]})},id="hods-task-list",ld="Incomplete form",ad=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=ld,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=id,classModifiers:u=[],className:m="",formData:f={},annotations:y=[],...h})=>{const p=T.Utils.classBuilder(c,u,m),A=T.Utils.cleanHtmlAttributes(h),[w,L]=i.filter(S=>!S.skipped).reduce((S,R)=>[S[0]+(R.tasks?.filter(v=>v.state===B.TYPES.COMPLETE).length??0),S[1]+(R.tasks?.filter(v=>v.state!==B.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:I,text:_}=s&&s||{},U=S=>{typeof a=="function"&&a(S)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),y.length>0&&y.map(S=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:T.Utils.interpolateString(S.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:T.Utils.interpolateString(S.value,f)})]},S.key)),o&&L!==w&&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 ${w} of ${L} sections`}),I&&_&&Ce(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:T.Utils.interpolateString(I,f)})}),d.jsx(T.TextArea,{id:C,fieldId:C,readOnly:!0,value:T.Utils.interpolateString(_,f)})]}),i.filter(S=>!S.skipped).map((S,R)=>d.jsxs(O.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${R+1}. `:" ",S.name]}),S.label&&d.jsx(T.Hint,{children:S.label}),d.jsx("ol",{className:p("items"),children:S.tasks.filter(v=>v.state!==B.TYPES.SKIPPED).map(v=>d.jsx(od,{task:v,onClick:U},`${S.name}-${v.name}`))})]},`${S.name}`))]})},Fr=(e,t)=>e?.page||t,cd=(e,t,n)=>{const s=Fr(e.action,e.pageId);s!==t&&n(s)},ud=(e,t,n,s=void 0)=>{const r=Fr(e,t);r!==t&&n(r,s)},dd=(e,t)=>{t(e)},pe={cyaAction:cd,navigate:ud,submissionError:dd},fd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,hd=(e,t)=>t(e).length===0,md=["radios","checkboxes"],pd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Ed(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ye(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const jr=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!md.includes(s.type))return;Ed(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...pd(t.collection.name,t.formData),...n};const s=Ue(t.collection.name,n);if(s){const r=It(t.collection.name,n),o=s.map(i=>i.id===r?jr(i,{...t,collection:void 0}):i);yn(t.collection.name,o,n)}}return n},Ad=(e,t,n)=>{if(e===te.HUB&&n===he.CYA)return{title:""};if(e===te.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===te.PARTIAL_CYA){const r=g.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Ur=(e,t,n)=>{if(e)return e===te.HUB?n===he.CYA||n===he.TASK?void 0:n:t.find(s=>s.id===e)},yd=(e,t,n)=>({pageId:e,cya:Ad(e,t,n),page:Ur(e,t,n)}),rs=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Td=(e,t,n)=>e.page?.type===te.PARTIAL_CYA?rs(n||t,e.pageId):n||t,os=(e,t,n,s,r)=>{if(!t&&r===Z.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:te.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{Je.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||te.HUB},Mr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!Je.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Sd=(e,t,n)=>Mr(e,t,n)||te.CYA,Cd=e=>e.length>0?e[0].id:void 0,Zt=(e,t,n,s,r)=>{if(s){if(s.type===G.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===G.TYPES.SAVE_AND_RETURN)return e===Z.HUB?te.HUB:void 0}switch(e){case Z.HUB:return os(s);case Z.CYA:return Sd(t,n,r);case Z.FORM_WITH_TASK:case Z.TASK:return os(s,n,t,r,e);case Z.WIZARD:return Mr(t,n,r);default:return Cd(t)}},gd=(e,t,n,s,r,o,i,l)=>{if(e===Z.TASK||e===Z.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(te.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===G.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:Zt(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 m=u.pages[u.pages.length-1];(m===n||m.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===G.TYPES.SAVE_AND_RETURN?{page:n}:{page:Zt(e,t,n,s,r)}},bd=({complete:e,currentPage:t},n=B.TYPES.NOT_STARTED)=>e?B.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?B.TYPES.IN_PROGRESS:n,wd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===B.TYPES.SKIPPED?s:s&&o?.complete},!0),kr=(e,t)=>{const n=e[t-1].state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:kr(e,t-1):!1},Id=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return bd(s[e.name],e.state);if(r)return e.depends_on&&!wd(s,e.depends_on,e.ignoreSkipped)?B.TYPES.CANNOT_START_YET:B.TYPES.NOT_STARTED;let i=o;return t&&(i=kr(n,t)),i?B.TYPES.NOT_STARTED:B.TYPES.CANNOT_START_YET},_d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==B.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Id(l,i,r,t,n,s)}),r},$r=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:$r(e,t-1):!1},Pd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!g.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:B.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&&!g.Condition.meetsAll(c,s)?{...a,state:B.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===B.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:B.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||$r(r,l);a.tasks=_d(a,o,n,c)}),r},xd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},Oe=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)Oe(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]]},Br=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},gn=(e,t)=>{const n=Br(e);return n?`${n}.${t}`:t},Nd=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)}},Od=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},Rd=(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},ke=(e,t)=>e.show_when?e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t):!0,Yr=(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},vd=(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)}},en=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):en(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]):en(e[t])})},Hr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Ld=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;Oe(e,t),Hr(n,r=>{const o=gn(t,r.fieldId);s[o]>1?s[o]-=1:Oe(e,o)})}},Dd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&vd(r,n,s),r.preserveInPayload)return;Oe(n,r.fieldId),Hr(r,o=>{const i=gn(r.fieldId,o.fieldId);e.has(i)||Oe(n,i)})}})},is=e=>Array.isArray(e)?e:[e],Fd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,m)=>{u.fieldId&&(m=m?`${m}.${u.fieldId}`:u.fieldId,o[m]=(o[m]||0)+1,u.path=m,c.show_when&&(u.show_when=u.show_when?[...is(c.show_when),...is(u.show_when)]:c.show_when),xd(m,u,r),u.components?u.components.forEach(f=>{a(c,f,m)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const y=!Ye(ee(s,m),f),h=f.show_when;f.nested.forEach(p=>{y&&i.push(gn(m,p.fieldId)),h&&(p.show_when=h),a(c,p,Br(m))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const m=Yr(u,t,n);a(c,m,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:Oe(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},jd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=Od(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},Ud=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const y=Rd(f,t);if(y)y.forEach(h=>{a.has(h)||i(a,h,u)});else{const h=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(h);if(p){const A=p[1],w=s.get(A);w&&w.childPages?.forEach(L=>{if(L.show_when){const C=JSON.stringify(L.show_when),I=`It is not possible to reliably clean hidden data when a component is dependent on a
|
|
9
|
+
`+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=De(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&At.assertOptions(s,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean),legacyInterceptorReqResOrdering:he.transitional(he.boolean),advertiseZstdAcceptEncoding:he.transitional(he.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:At.assertOptions(r,{encode:he.function,serialize:he.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),At.assertOptions(n,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&m.merge(o.common,o[n.method]);o&&m.forEach(["delete","get","head","post","put","patch","query","common"],y=>{delete o[y]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||An;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,h=0,f;if(!a){const y=[Qn.bind(this),void 0];for(y.unshift(...l),y.push(...c),f=y.length,u=Promise.resolve(n);h<f;)u=u.then(y[h++],y[h++]);return u}f=l.length;let E=n;for(;h<f;){const y=l[h++],p=l[h++];try{E=y(E)}catch(A){p.call(this,A);break}}try{u=Qn.call(this,E)}catch(y){return Promise.reject(y)}for(h=0,f=c.length;h<f;)u=u.then(c[h++],c[h++]);return u}getUri(t){t=De(this.defaults,t);const n=Js(t.baseURL,t.url,t.allowAbsoluteUrls);return Gs(n,t.params,t.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(t){Re.prototype[t]=function(n,s){return this.request(De(s||{},{method:t,url:n,data:(s||{}).data}))}});m.forEach(["post","put","patch","query"],function(t){function n(s){return function(o,i,l){return this.request(De(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Re.prototype[t]=n(),t!=="query"&&(Re.prototype[t+"Form"]=n(!0))});let ha=class er{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(r=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](r);s._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(l=>{s.subscribe(l),o=l}).then(r);return i.cancel=function(){s.unsubscribe(o)},i},t(function(o,i,l){s.reason||(s.reason=new rt(o,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new er(function(r){t=r}),cancel:t}}};function ma(e){return function(n){return e.apply(null,n)}}function pa(e){return m.isObject(e)&&e.isAxiosError===!0}const sn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(sn).forEach(([e,t])=>{sn[t]=e});function tr(e){const t=new Re(e),n=vs(Re.prototype.request,t);return m.extend(n,Re.prototype,t,{allOwnKeys:!0}),m.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return tr(De(e,r))},n}const Z=tr(st);Z.Axios=Re;Z.CanceledError=rt;Z.CancelToken=ha;Z.isCancel=Ws;Z.VERSION=Tn;Z.toFormData=Rt;Z.AxiosError=D;Z.Cancel=Z.CanceledError;Z.all=function(t){return Promise.all(t)};Z.spread=ma;Z.isAxiosError=pa;Z.mergeConfig=De;Z.AxiosHeaders=ue;Z.formToJSON=e=>Ks(m.isHTMLForm(e)?new FormData(e):e);Z.getAdapter=Zs.getAdapter;Z.HttpStatusCode=sn;Z.default=Z;const{Axios:af,AxiosError:cf,CanceledError:uf,isCancel:df,CancelToken:ff,VERSION:hf,all:mf,Cancel:pf,isAxiosError:Ef,spread:Af,toFormData:yf,AxiosHeaders:Tf,HttpStatusCode:Sf,formToJSON:Cf,getAdapter:gf,mergeConfig:bf,create:wf}=Z,ce={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,n)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,n,s)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},es=Object.keys(ce),nr=R.createContext(),sr=({overrides:e={onAction:void 0,onCancel:void 0,onChange:void 0,onFormComplete:void 0,onFormLoad:void 0,onGetComponent:void 0,onGetCYA:void 0,onGetCYARows:void 0,onGoingBack:void 0,onPageChange:void 0,onRequest:void 0,onSubmit:void 0,onValidate:void 0},children:t=null})=>{const[n,s]=R.useState({onAction:e?.onAction||ce.onAction,onChange:e?.onChange||ce.onChange,onFormComplete:e?.onFormComplete||ce.onFormComplete,onFormLoad:e?.onFormLoad||ce.onFormLoad,onGetComponent:e?.onGetComponent||ce.onGetComponent,onGetCYA:e?.onGetCYA||ce.onGetCYA,onGetCYARows:e?.onGetCYARows||ce.onGetCYARows,onGoingBack:e?.onGoingBack||ce.onGoingBack,onPageChange:e?.onPageChange||ce.onPageChange,onRequest:e?.onRequest||ce.onRequest,onSubmit:e?.onSubmit||ce.onSubmit,onValidate:e?.onValidate||ce.onValidate,onCancel:e?.onCancel||ce.onCancel}),r=(i,l)=>{es.includes(i)&&s(a=>({...a,[i]:l||ce[i]}))},o=i=>{es.includes(i)&&s(l=>({...l,[i]:ce[i]}))};return d.jsx(nr.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},Pe=()=>R.useContext(nr),Ea=()=>{const{hooks:e}=Pe(),[t,n]=R.useState({});return R.useEffect(()=>{const s=Z.create({baseURL:"/"});return s.interceptors.request.use(e.onRequest),s.interceptors.response.use(r=>r,async r=>Promise.reject(r)),n({instance:s}),()=>{n({})}},[e]),t.instance},Cn=R.createContext(),rr=({children:e=null})=>{const{hooks:t}=Pe(),[n,s]=R.useState([]),[r,o]=R.useState([]),i=f=>{f!==void 0&&o(E=>[...E,...f].filter(y=>!!y))},l=f=>{typeof f=="function"&&o(E=>E.filter(y=>!f(y)))},a=()=>{r.length&&o([])},c=f=>{f!==void 0&&s(E=>[...E,...f].filter(y=>!!y))},u=()=>{o([]),s([])},h={page:f=>{const E=w.Validate.page(f,r),y=t.onValidate(f,E);return s(y),y},pages:f=>{const E=f.map(p=>w.Validate.page(p,r)),y=f.flatMap((p,A)=>t.onValidate(p,E[A]));return s(y),y}};return d.jsx(Cn.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:h},children:e})},He=()=>R.useContext(Cn),Yt={},Ht={},Aa="idle",ya="fetching",or="fetched",ir="error",Ta=(e,t=!0)=>{const n=Ea(),s=R.useRef(Z.CancelToken.source()),[r,o]=R.useState(Aa),[i,l]=R.useState(null),[a,c]=R.useState(null),u=()=>{s.current&&s.current.cancel()};return R.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(ya);let f;if(t&&Yt[e])f=Yt[e];else{if(t&&Ht[e])throw Ht[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(y=>{throw l(y),y})).data,t&&(Yt[e]=f)}c(f),o(or)}catch(f){t&&(Ht[e]=f),l(f),c(null),o(ir)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},Sa="loading",yt="complete",Ca=e=>{const t=e.data;if(t&&!t.options||t?.url)return S.Utils.interpolateString(t.url,e.formData)},ga=(e,t)=>{const n=Ca({...e,formData:t}),{status:s,data:r}=Ta(n,e?.data?.useCache),[o,i]=R.useState([]),[l,a]=R.useState(Sa);return R.useEffect(()=>{n?s===or?(r&&i(de.refData.toOptions(r.data||r,e.item)),a(yt)):s===ir&&(i([]),a(yt)):(e.data&&e.data.options&&i(de.refData.toOptions(e.data.options,e.item)),a(yt))},[e.id,s,r,n]),{data:o,status:l}},Xe=(e,t)=>{const n=te(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(S.FormGroup,{...n,onChange:null,children:t})},gn=(e,t,n,s,r={})=>{if(!t)return[];const o=w.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(l=>{r={...r,[`${t.collection.name.split(".").pop()}ActiveId`]:l.id};const a=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...r}};if(c.childPages)return gn(e,u,n,s,r);const h=w.Validate.page(u);return s.onValidate(u,h)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},bn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Ve,{component:{...t,readonly:!0},wrap:!1,value:e,formData:n}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:s)||d.jsx(S.VisuallyHidden,{children:"No answer"}),ba="Continue",rn=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?W.DEFAULTS[e]:e,r=W.DEFAULTS[e.type];return s?d.jsx(S.Button,{...n,className:s.className,classModifiers:s.classModifiers,start:s.start||!1,name:s.label,onClick:s.disabled?()=>{}:()=>t(s),children:s.label||r?.label||ba}):null},wa="hods-form-confirmation",_a="Are you sure?",Ia="Confirm",Pa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=S.Utils.classBuilder(wa,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||_a}),s,d.jsx(S.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||Ia}),d.jsx(S.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},wn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===_.CONTAINER?wn(t):ot.editable(t)?t:null).filter(t=>!!t):[],xa=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const s=t?`${t}.${n.fieldId}`:n.fieldId,r={...n,full_path:s};return n.type===_.CONTAINER?on(r):(n.type===_.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===_.CONTAINER&&(r.data.options[i].nested[a]=on(l))})}),r)})},on=e=>{if(e){const t=xa(e);return{...e,components:t}}return e},Oa=(e,t)=>e.some(n=>ot.show(n,t)),Ra=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=wn(e);return n.length>0?Oa(n,t):!0},Lt={editableComponents:wn,setup:on,show:Ra},Na=(e,t)=>e.some(n=>Ie(n,t)),Dt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=Lt.editableComponents(e);return n.length>0?Na(n,t):!0},La=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Dt(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(h=>h.id===a)});return}const c=l.components.find(h=>h.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){Ue(a.show_when,{...t,...n})&&s.push({...u,show_when:c.show_when||[]});return}s.push(u)})});const r={...e.childPages[0],formData:t};r.components=s,r.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return r.formData={...r.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete r.title,delete r.collection,r},_n=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(S.ButtonGroup,{children:e.map((n,s)=>d.jsx(rn,{action:n,onAction:t},s))}),Da=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?ae.meetsOne(t.runWhen?.constraint,e.formData):!1},lr="hods-form__page",In=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=lr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:h})=>{const[f,E]=R.useState({}),{errors:y,validate:p}=He(),[A,T]=R.useState({}),[N,C]=R.useState(!1),b=R.useMemo(()=>Da(e),[e]);R.useEffect(()=>{C(!0)},[]),R.useEffect(()=>{N&&b&&p.page(e)},[h,N]);const P=({target:I})=>{const k=e,{value:O}=I;O?(k.formData[I.name]=O,E(x=>({...x,[I.name]:O})),T(x=>({...x,[I.component]:I.label}))):(delete k.formData[I.name],E(x=>{const{[I.name]:j,...$}=x;return $}),T(x=>{const{[I.component]:j,...$}=x;return $})),typeof o=="function"&&o(e.formData)};R.useEffect(()=>{const I=document.title.replace("Error: ","");document.title=y.length>0?"Error: "+I:I},[y]);const U=w.classBuilder(l,a,c),g=e;g.actions=g.actions?.map(I=>I.label?{...I,label:w.interpolateString(I.label,g.formData)}:I),g.formData=w.Operate.runPageOperations(g,{...g.formData,...f},s||P);const L=e.title?d.jsx(S.Heading,{size:e.titleSize,children:w.FormPage.getTitle(e.title,e.formData)}):d.jsx(S.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(I=>w.Component.show(I,e.formData)).map((I,k)=>d.jsx(Ve,{component:I,onAction:O=>n(O,f,A),onChange:s||P,onTopLevelChange:r||P,value:e.formData[I.fieldId]||f[I.fieldId],formData:e.formData,pages:t,submitting:u},k));let F=null;return b&&y?.length>0?F=[{error:e?.customValidation?.[0]?.message}]:y?.length>0&&!b&&(F=y),d.jsxs("div",{className:U(),children:[F&&d.jsx(S.ErrorSummary,{errors:F,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:L}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[L,v]}),d.jsx(_n,{actions:e.actions?.filter(I=>w.Component.show(I,e.formData)),onAction:I=>n(I,f,A)})]},e.id)},ts="hods-form-banner-strip",ar=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=w.classBuilder(ts,s,""),o=t.filter(i=>w.Component.show(i,n));return d.jsx("div",{id:e,className:r(),children:o.map((i,l)=>{const a=`${e}-banner-${l}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:a,className:r("banner"),children:d.jsx(S.Markup,{content:w.interpolateString(c,n)})},a)}return d.jsx(S.Tag,{classBlock:`${ts}__tag`,classModifiers:i.classModifiers,text:w.interpolateString(i.text,n)},a)})})},va=e=>{if(e&&e.action){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},Pn=({row:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(va(e))},[e,n]),e.action?d.jsxs(S.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(S.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},cr=({row:e,classes:t,showAction:n=!1})=>d.jsxs("dl",{className:t("row"),role:"listitem",children:[d.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),d.jsx("dd",{className:t("value"),children:e.value}),n&&d.jsx("dd",{className:t("actions"),children:e.action&&d.jsx(Pn,{row:e})})]}),ur=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(S.SmallHeading,{children:e})}),Tt=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=jt(o,t);return t.type==="title"?d.jsx(ur,{title:t.key,classes:n}):d.jsx(cr,{row:{key:i.key,value:d.jsx(bn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Fa="govuk-summary-card",ja="govuk-summary-list",ft="Item",ht="Change",ns="Delete",Ua="warning",Ma=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=S.Utils.classBuilder(Fa,i,n.className),c=S.Utils.classBuilder(ja,[]);return d.jsxs("div",{className:a(),id:e,children:[d.jsxs("div",{className:a("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:a("title-content"),children:[d.jsx("h2",{className:a("title"),children:S.Utils.interpolateString(n.title||ft,{...t,index:t.index+1})}),n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:a("actions"),children:[d.jsx("li",{className:a("action"),children:n.changeAction&&typeof s=="function"&&n.changeAction.classModifiers?d.jsx(S.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||Ua,"aria-label":S.Utils.interpolateString(`${n.deleteAction?.label||ns} ${n.title||ft}`,{...t,index:t.index+1}),children:n.deleteAction.label||ns})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const h=u.components.map(f=>w.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const y=f.columns.filter(p=>ae.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return y.length?y.flatMap(p=>{const A=h.find(T=>T.fieldId===p);return A?Tt(u,A,c,t,l):null}):null})})})})]})},ka=({id:e,"data-testid":t,actions:n,onFullEdit:s=null,entryData:r,formData:o,name:i,autoFocus:l})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(a=>w.Component.show(a,o)).map(a=>d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||ss},e))}):d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||ss}),Ba=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},vt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ba(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},dr=[_.ALERT,_.COLLECTION_SUMMARY,_.DETAILS,_.HEADING,_.HTML,_.INSET_TEXT],Ct=(e,t)=>{if(!e||dr.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===_.COLLECTION){if(!se(t,e.full_path||e.fieldId)?.length)return!1}else{const n=se(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===_.CONTAINER?Lt.show(e,t):ot.show(e,t)},fr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>dr.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),$a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:vt(!1,e,t)}],Ya=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),Ha=(e,t,n,s,r)=>{const o={...$e,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},xn=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&Ct(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Ya(t,o,l,a);return c=fr(c),[Ha(t,o,e.id,l,a),...qe(e,c,o,s,r)]}).filter(o=>!!o):$a(e,s),Va="hods-form-summary-card-details",hr=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=w.classBuilder(Va,r),a=R.useMemo(()=>t.map(u=>e.childPages.find(h=>h.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,h,f)=>{let E=0;return u.flatMap((y,p)=>{let A=0;const T=y.fields?.flatMap(C=>h.filter(P=>P.fieldId===C).map(P=>{if(!P||!Ie(P,{...f.formData,...s}))return null;if(P.type===_.CONTAINER){const U=qe(f,P,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(g=>{const L={...s,[g.fieldId]:s[P.fieldId]?.[g.fieldId]};return Tt(f,{...g,label:g.key},l,L,i)})},C)}if(P.type===_.COLLECTION){const U=xn({...f,formData:{...f.formData,...s}},P,s[P.id]);A+=1;let g=0;return d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(L=>{const v={...s,[L.fieldId]:s[P.fieldId]?.[L.fieldId]},F=Tt(f,{...L,label:L.key},l,v,i);return L.type==="title"&&(g+=1,g>1)?d.jsx("div",{style:{marginTop:"40px"},children:F}):F})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:Tt(f,P,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&T.length!==0?(E+=2,[...T,d.jsx("div",{className:l("divider"),style:{"--column":E}},`divider${E}`)]):T}).filter(y=>!!y)};return e?.childPages?.filter(u=>w.FormPage.show(u,{...n,...s})).map(u=>{const h=w.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!w.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const y=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return y&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(hr,{masterPage:y,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const E=f.columns.filter(y=>ae.meetsAll(y,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:w.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":E.length-1},children:c(E,h,u)})]},f.title)})}).filter(u=>!!u)||null},qa="hods-form-summary-card",ss="Change",Ga="Delete",Ka="Quick Edit",Wa="Duplicate",za="Full details",rs="secondary",os=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:h,hideDetails:f=!1})=>{const[E,y]=R.useState(!1),p=S.Utils.classBuilder(qa,s,n.className),A=R.useMemo(()=>n.quickEdit?La(h,u,t):null,[h,n,u,t,E]),{addErrors:T,resetQuickEditErrors:N,clearTopLevelErrorsForCard:C,validate:b}=He(),{hooks:P}=Pe(),U=async(g,L)=>{if(g.type==="cancel"&&(y(v=>!v),N?.()),g.type==="save"&&typeof l=="function"){const v={...A.formData,...L,[`${a}ActiveId`]:t.id},F=b.page({...A,formData:v});if(F.length)return;let I;await P.onSubmit("quickEdit",v,()=>{},O=>{I=O}),I&&T(I);const k=F.concat(I);if(k.length===0||k.length===1&&k[0]===void 0){C();const O=w.CollectionPage.getData(a,u),{isDuplicate:x,...j}=O[t.index];O[t.index]={...j,...L},l({target:{name:a,value:O}}),y($=>!$)}}};return n.listView?d.jsx(Ma,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:h,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:w.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:w.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(S.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>y(g=>!g),classModifiers:"primary",disabled:E,name:"QuickEdit",autoFocus:n.focusOn,children:Ka}),n.changeAction&&typeof r=="function"&&d.jsx(ka,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:r,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ga}),n.duplicateAction&&typeof i=="function"&&d.jsx(S.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||Wa})]})]}),E&&A&&d.jsx(In,{page:A,onAction:(g,L)=>U(g,L),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(S.Details,{summary:n.detailsTitle||za,className:"details",children:d.jsx(hr,{masterPage:h,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Ja=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=Pe(),o=t.filter(h=>h.entryId===e)||[],[i,l]=R.useState(null),a=()=>{l(null)},c=h=>{l(f=>(f??[]).concat(h))},u={page:h=>{const f=w.Validate.page(h),E=r.onValidate(h,f);return l(E),E}};return d.jsx(Cn.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},is="Add",Xa=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=Pe(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:h,dequeueErrors:f}=He(),[E,y]=R.useState(null),p=R.useMemo(()=>w.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((L,v)=>v.isDuplicate&&(!L||v.id>L.id)?v:L,null):null,T=R.useMemo(()=>{const L=e.collectionName.split(".");let v=w.CollectionPage.mergePages(o||[])||[];return L.reduce((F,I,k)=>{const O=k===0?`${F}${I}`:`${F}.${I}`;return k===L.length-1?v?.find(x=>x.collection?.name===O)||null:(v=v.find(x=>x.collection?.name===O)?.childPages||null,O)},"")},[o]),N=R.useMemo(()=>e.card.listView?T.childPages?.reduce((v,F)=>{const I=et(F.components,{...t,...E});return v.concat(I)},[])||[]:[],[T,t,E,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const L=gn(e,T,t,i);L.length>0&&h(L)};R.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const b=(L,v)=>{if(typeof n=="function"){const F=[...p],I=p.findIndex(x=>x.id===v),{isDuplicate:k,...O}=p[I];F[I]={...O},n({type:mt.SAVE_AND_NAVIGATE,page:L,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:F,isCollection:!0}]})}},P=L=>{w.CollectionPage.duplicateEntry(e.collectionName,t,L.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:w.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!E)return;w.CollectionPage.removeEntry(e.collectionName,t,E.id);const L=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:L,value:w.CollectionPage.getData(L,t)}}),y(null),C()},g=L=>{const v=N.find(I=>I.fieldId===L);if(!v)return null;const F=jt({...T,formData:{...t,...E}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(bn,{value:F.value,component:F.component,formData:F.formData})},L)};return d.jsxs("div",{id:e.fieldId,children:[E&&d.jsx(Pa,{id:`${e.fieldId}.confirmation`,message:w.interpolateString(e.confirmation?.message,{...E,index:E.index+1})||null,confirmLabel:w.interpolateString(e.confirmation?.label,E)||null,onConfirm:U,onCancel:()=>y(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(g)}):d.jsx(os,{id:`${e.fieldId}.confirmationChild`,entryData:E,config:e.card?{...e.card,quickEdit:null}:{},masterPage:T,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((L,v)=>{const F=l.filter(O=>O.entryId===L.id).length>0,I={...e.card,...L.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...F&&e.errorCard?e.errorCard:{},focusOn:A?.id===L.id},k=`${e.fieldId}.summaryCard${L.id}`;return d.jsx("li",{children:d.jsx(Ja,{entryId:L.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const O=l.filter(x=>x.entryId!==L.id);c(),a(O)},children:d.jsx(os,{id:k,entryData:{...L,index:v},masterPage:T,config:I||{},onFullEdit:b,onDuplicate:P,onDelete:()=>y({...L,index:v}),onQuickEdit:O=>(C(),s(O)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:L.id===E?.id?["deleting-summary-card"]:[""],inError:l.filter(O=>O.entryId===L.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Qa="hods-form-collection",Za=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=R.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===w.Meta.name)s({target:p});else{const A=i.findIndex(T=>T.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:_t.v4()}])},h=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;R.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,T=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');T&&T.length>0&&T[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),R.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const E={...$e,...e.labels},y=w.classBuilder(Qa,[],e.className);return d.jsxs("div",{className:y(),id:e.id,children:[e.label&&d.jsx(S.Label,{id:e.id,required:e.required,className:y("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const T=`${e.full_path||e.fieldId}[${A}]`,N=(e.countOffset||0)+A+1,C=w.interpolateString(E.item,{...p,index:N}),b=w.interpolateString(E.remove,{...p,index:N}),P=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${y("item")}`,style:U,children:[d.jsxs(S.Label,{id:p.id,required:!0,className:y("item-title"),children:[C,P==="start"&&d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})]}),d.jsx(Ln,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:T,components:e.item.map(g=>{const{firstOnlyLabel:L,...v}=g;let{hint:F}=g;e.restrictHint&&A>0&&(F=void 0);let{label:I}=g;return A===0&&(I=g.firstOnlyLabel??g.label),{...v,hint:F,readonly:!!(e?.readonly||g.readonly),label:w.interpolateString(I,{...p,index:N}),full_path:`${T}.${g.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),P==="end"&&d.jsx(S.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(S.ButtonGroup,{children:d.jsx(S.Button,{onClick:u,classModifiers:"secondary",children:f(E)})})]})},ec=(e,t,n)=>{const s=e,r=typeof s.value=="object"?s.value?.value:s.value,o=n.find(i=>String(i.id)===r);return s.label=o===void 0?s.value||"":o.label,s.component=t.cya_label,s},tc=(e,t)=>typeof e=="string"?!!S.Utils.interpolateString(e,t):!!e,Vt=(e,t)=>{if(Array.isArray(t)){const n=t.find(s=>s.id===(e.full_path||e.id));if(n){const s={error:n.error};return n.properties&&(s.propsInError=n.properties),s}}},nc=[_.RADIOS,_.CHECKBOXES,_.DATE,_.TIME],sc=e=>e.fieldset||nc.includes(e.type),Ve=({component:e,value:t=null,formData:n=null,wrap:s=!0,onAction:r,onChange:o,onTopLevelChange:i,pages:l=[],submitting:a=!1,...c})=>{const{hooks:u}=Pe(),h=He(),{data:f,status:E}=ga(e,n),[y,p]=R.useState([]);R.useEffect(()=>{E===yt&&p(f)},[e,f,E]);const A=({target:C})=>typeof o=="function"?(e.type===_.EMAIL&&(C.value=C.value.trim()),e.type===_.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(b=>{b.children&&b.nested&&(delete b.children,delete b.nested)}),C=ec(C,e,f),e.type===_.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(R.useEffect(()=>{const C=w.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===_.CONTAINER){let C=d.jsx(Ln,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=Xe(e,C)),e.additionalValidation&&(C=Xe({...e,...Vt(e,h?.errors)},C)),C}if(e.type===_.COLLECTION)return d.jsx(Za,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});if(e.type===_.COLLECTION_SUMMARY)return Xe({...e,...Vt(e,h?.errors)},d.jsx(Xa,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const T=C=>{let b=e.full_path||e.fieldId;if(e.pageCollection){const P=w.CollectionPage.getActiveIndex(e.pageCollection.name,n);b=`${`${e.pageCollection.name}[${P}]`}.${b}`}i({target:{name:w.Meta.name,value:w.Meta.documents.setForField(C,n,b,e.allowMultiple)}})},N=({target:C})=>{if(A({target:C})){if(e.type===_.FILE)T([C.value]);else if(e.type===_.MULTI_FILE){const b=C.value.map((P,U)=>({...P,indexInField:U}));T(b)}}};return w.Component.get({...c,...e,id:e.full_path||e.id,...Vt(e,h?.errors),fieldset:sc(e),disabled:tc(e.disabled,n),label:w.interpolateString(e.label,n),content:w.interpolateString(e.content,n),hint:w.interpolateString(e.hint,n),cya_label:w.interpolateString(e.cya_label,n),suffix:w.interpolateString(e.suffix,n),options:y,value:t,onChange:N,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},rc=[_.AUTOCOMPLETE,_.CALCULATION,_.CHECKBOXES,_.COLLECTION_SUMMARY,_.DATE,_.EMAIL,_.FILE,_.MULTI_FILE,_.PHONE_NUMBER,_.RADIOS,_.SELECT,_.TEXT,_.TEXT_AREA,_.TIME],mr=e=>rc.includes(e?.type)||e?.isEditable||!1,oc="govuk-list",ic="govuk-body",lc=e=>{const t=te(e),n=S.Utils.interpolateString(e.heading,e.formData),s=S.Utils.interpolateString(e.text,e.formData);return d.jsx(S.Alert,{...t,heading:n,children:s})},ac=e=>{const t=te(e),n=de.getAutocompleteSource(e);return d.jsx(S.Autocomplete,{...t,source:n})},cc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Checkboxes,{...n,options:t})},uc=e=>{const t=de.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=te(e,["formula"]);return d.jsx(S.TextInput,{...n,readonly:!0})},dc=e=>{const t=te(e);return d.jsx(S.DateInput,{...t})},fc=e=>{const t=te(e,["tagName"]),n=Ft(e);return d.jsx(S.Details,{...t,children:n})},hc=e=>{const t=te(e);return d.jsx(S.FileUpload,{...t})},mc=e=>{const t=te(e);return d.jsx(S.MultiFileUpload,{...t})},pc=e=>{const t=te(e);return d.jsx(S.Heading,{...t,children:e.content})},Ft=e=>{const t=te(e);return d.jsx(S.Markup,{...t})},Ec=e=>{const t=te(e);return d.jsx(S.InsetText,{...t,children:e.content})},Ac=e=>{const t=te(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=S.Utils.classBuilder(oc,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return Ft({...t,className:r(),tagName:n,content:o,type:_.HTML})},yc=e=>{const t=te(e);return Ft({className:ic,...t,tagName:"p",type:_.HTML})},Tc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Radios,{...n,options:t})},Sc=e=>{const t=te(e);return d.jsx(S.TextArea,{...t})},Cc=e=>{const t=te(e);return d.jsx(S.TextInput,{...t})},gc=e=>{const t=te(e);return d.jsx(S.TimeInput,{...t})},bc=e=>{let t=[];de.getOptions(e,s=>{t=s});const n=te(e);return d.jsx(S.Select,{...n,options:t})},wc=e=>{const t=te(e);return d.jsx(S.WarningText,{...t,children:e.content})},_c=e=>{switch(e.type){case _.HTML:return Ft(e);case _.HEADING:return pc(e);case _.INSET_TEXT:return Ec(e);case _.TEXT:case _.EMAIL:case _.PHONE_NUMBER:return Cc(e);case _.TEXT_AREA:return Sc(e);case _.AUTOCOMPLETE:return ac(e);case _.RADIOS:return Tc(e);case _.CHECKBOXES:return cc(e);case _.DATE:return dc(e);case _.TIME:return gc(e);case _.FILE:return hc(e);case _.MULTI_FILE:return mc(e);case _.WARNING:return wc(e);case _.SELECT:return bc(e);case _.DETAILS:return fc(e);case _.CALCULATION:return uc(e);case _.ALERT:return lc(e);case _.PARAGRAPH:return yc(e);case _.LIST:return Ac(e);default:return null}},Ic=(e,t)=>{const n={...t};if(e.full_path){const s=e.full_path.split(".");s.pop(),s.push(n.fieldId),n.full_path=s.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||de.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:Er(n,!1)})):d.jsx(Ve,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},pr=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!ae.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:Ic(e,s)},s.id));return n.length>0?n:null},Er=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=_c(e);return s&&t&&mr(e)?Xe(e,s):s},Pc=e=>e.defaultValue||e.defaultObjectValue,xc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?K().format("DD-MM-YYYY"):n},Oc=(e,t)=>{const n={...e};let s=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(s={...n.literal}),n.sourced&&(s=s??{},Object.keys(n.sourced).every(r=>{const o=typeof n.sourced[r]=="string"&&se(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},Ar=(e,t)=>Pc(e)?e.type===_.DATE?xc(e):(e.defaultObjectValue?Oc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Rc={[_.COLLECTION]:[],[_.CONTAINER]:{}},Nc=(e,t)=>e&&(Ar(e,t)||Rc[e.type])||"",ot={clean:te,defaultValue:Nc,defaultValueFromConfig:Ar,editable:mr,elevateNested:et,get:Er,setupContainerPaths:fr,show:Ie,wrap:Xe},Lc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ze(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},jt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Lc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:S.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ot.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:vt(t.readonly,e,n)}},qe=(e,t,n,s,r)=>Ct(t,{...e.formData,...n})?et(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>Ct(i,{...e.formData,...n})).flatMap(i=>{const l=n?n[i.fieldId]:void 0;if(typeof r=="function"){const a=r({...e,formData:n},i,s);if(a)return a}return i.type===_.CONTAINER?qe(e,i,{...l,...n},s,r):i.type===_.COLLECTION?xn(e,i,l,s,r):jt({...e,formData:n},i,s)}):null,Dc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{w.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ls=(e,t,n="text")=>{if(typeof e=="string")return S.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:Ue(r.show_when,t));return typeof s=="string"?S.Utils.interpolateString(s,t):S.Utils.interpolateString(s[n],t)},vc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Fc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return W.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return W.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),vc(n)}}).filter(t=>!!t)},jc=e=>({type:_.HTML,tagName:"p",content:e}),Uc=(e,t)=>{const n=e.use.split("."),s=n.shift();let r=JSON.parse(JSON.stringify({...t.find(l=>l.id===s)})),o=r,i=r;for(;o&&n.length>0;){const l=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(a=>a.id===l),i.components.length>0?o=i.components[0]:o=void 0):o=void 0}if(o)return o={cya_label:o.label,...o,...e},i&&i.id!==o.id?i.components=[o]:r=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(l=>l.use?ln(l,t):l)),r},ln=(e,t)=>{if(e){const n=Uc(e,t);if(n)return n}return{...e}},yr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return jc(o);let i;return o.type===_.CONTAINER&&(o.components=o.components.map(l=>l.use?ln(l,t):l)),o.use?i=ln(o,t):i={...o},n?de.refData.setupUrl(i,n):i}),r=Fc(e);return Lt.setup({...e,formData:n,components:s,actions:r})},Mc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...yr(s,t,n),index:r})):[],Tr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Dt(e,t),it={applyConditionalProperties:Dc,getConditionalText:ls,get:yr,getAll:Mc,getTitle:(e,t)=>ls(e,t,"title"),show:Dt,showCYA:Tr},kc=(e,t)=>{if(!e)return null;if(!t)return e;const n={...e};return n.show_when?Array.isArray(t)?n.show_when=Array.isArray(n.show_when)?[...t,...n.show_when]:[...t,n.show_when]:n.show_when=Array.isArray(n.show_when)?[...n.show_when,t]:[n.show_when,t]:n.show_when=t,n},Bc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},Ut=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},$c=e=>typeof e=="number"&&e>=0,Sr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return $c(o)?(e.shift(),Sr(e,t[s][o],n)):null},Ge=(e,t)=>{const n=e.split(".");return Sr(n,t,t)},Cr=(e,t,n,s=[],r={})=>{const o=Ge(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=_t.v4(),a={...i,...r,id:l};s.forEach(u=>delete a[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(a):o.splice(c,0,a),t[`${e.split(".").pop()}ActiveId`]=a.id,l},Yc=(e,t)=>{const n=Ut(e,t);return Cr(e,t,n)},Hc=e=>typeof e=="number"&&e>=0,gr=(e,t,n)=>{const s=e[0],r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return Hc(o)?e.length===1?o:(e.shift(),gr(e,t[s][o],n)):null},br=(e,t)=>{const n=e.split(".");return gr(n,t,t)},Vc=e=>({id:e.id,name:e.name,...e.collection.show_when&&{show_when:e.collection.show_when},orderInForm:e.orderInForm,deleteCollectionWhenHidden:e.deleteCollectionWhenHidden,collection:{masterPage:!0,...e.collection},formData:{...e.formData},childPages:[e]}),qc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Gc=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const s=n.join("."),r=t[s]||null;return r?(r.childPages.push(e),r.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},wr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Vc(s);return t[s.collection.name]=o,o}return qc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Gc(s,t)?null:s).filter(s=>!!s)},Kc=(e,t,n)=>{const s=Ge(e,t);if(!s)return null;const r=s.findIndex(l=>l.id===n);if(r===-1)return null;const o=s[r];s.splice(r,1);const i=t;return i[`${e}ActiveId`]=s.length>0?s[0].id:null,o},Wc=e=>typeof e=="number"&&e>=0,On=(e,t,n)=>{const s=e.split("."),r=s[s.length-1];let o=n;s.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=_t.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===r)return o[r]=t,!0;const l=n[`${i}ActiveId`],a=o[i]?.findIndex(c=>c.id===l);return Wc(a)?(o=o[i][a],!1):!0})},gt={addEntry:Bc,duplicateActiveEntry:Yc,duplicateEntry:Cr,getActiveId:Ut,getActiveIndex:br,getData:Ge,getErrorsForCollection:gn,mergePages:wr,removeEntry:Kc,setData:On},zc=e=>typeof e=="number"&&e>=0,Jc=(e,t,n,s,r,o)=>{const i=r?.label||$e.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[E,y]=f;c[E]=y});const u=gt.getData(e.collection.name,c),h=u?.findIndex(f=>f.id===t.id);return zc(h)&&u.splice(h,1),c})},label:S.Utils.interpolateString(i,{...t,index:s})}}},Xc=(e,t,n,s,r,o={})=>{const i=r?.label||$e.change;return{pageId:e.id,fieldId:`change${s}${r.page}`,key:`change${s}${r.page}`,type:"action",action:{onAction:l=>{const a=c=>{const u=c;return Object.entries(o).forEach(h=>{const[f,E]=h;u[f]=E}),u};n(r.page?{pageId:r.page}:l,a)},label:S.Utils.interpolateString(i,{...t,index:s})}}},Qc=(e,t)=>t.show_when?Ue(t.show_when,e):!0,Zc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),eu=(e,t,n,s,r)=>{const o={...$e,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},tu=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:S.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},nu=(e,t,n,s)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:n?.text||t.charAt(0).toUpperCase()+t.slice(1),type:s==null?"heading":"headingWithAction",size:n?.size||"m",action:s===null?null:{onAction:s,label:"Change"}}),su=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Qc(r,i)).map(i=>i.type==="remove"?Jc(e,t,n,s,i,o):i.type==="change"?Xc(e,t,n,s,i,o):null).filter(i=>!!i),_r=(e,t,n={})=>()=>{const s=r=>{const o=r;return Object.entries(n).forEach(i=>{const[l,a]=i;o[l]=a}),o};t({pageId:e.id},s)},ru=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Ir(c,n,s,t,i));else if(c.collection.route&&(c=kc(c,c.collection.route)||c),Tr(c,{...c.formData,...t})){const u=_r(c,n,i);if(c.collection.heading){const E=c.collection.heading.changeLink?u:null,y=tu(c.collection.heading,c.id,r,E,t);l=l.concat(y)}const h=Zc(c,t,r,o),f=qe({...c,formData:{...c.formData,...t}},h,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Ir=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?_r({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(nu(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Ue(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Ue(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((E,y)=>(c=y,E.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const E=c+1,y=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=su(e,f,t,E,s,r);if(!u){const T=eu(e,f,e.id,E,p);a=a.concat(T)}y==="top"&&(a=a.concat(A)),a=a.concat(ru(e.childPages,f,t,n,E,p,r)),y==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},ou=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Ve,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,iu=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(r=>{const o=t.findIndex(i=>i.id===r);return n<0&&(n=o),o>-1?ou(t[o]):null})}),firstComponentIndex:n}},lu=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=iu(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:vt(!1,e,s)},insertAt:o}},au=(e,t,n=null)=>{if(it.showCYA(e,e.formData)){if(e.collection)return Ir(e,t,n,e.formData);const r=et(e.components,e.formData).filter(o=>Ct(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case _.CONTAINER:return qe(e,o,e.formData[o.fieldId],t,n);case _.COLLECTION:return xn(e,o,e.formData[o.fieldId],t,n);default:return jt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=lu(e,i,r,t);a>-1?r.splice(a,0,l):r.push(l)});const o=e.groups.flatMap(i=>i.components);return r.filter(i=>!o.includes(i.id))}return r}return[]},cu={getRows:au,getCYARowsForContainer:qe},Pr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},xr=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=Pr(e.format,s[e.fieldId]))},Or=(e,t,n)=>{e.forEach(s=>xr(s,t,n))},Rr=(e,t,n)=>{Or(e.components,t,n)},uu=(e,t,n)=>{e.forEach(s=>Rr(s,t,n))},du=(e,t,n)=>{const s={...t};return Or(e.components,s,n),uu(e.pages,s,n),s},fu={component:xr,data:Pr,form:du,page:Rr},hu=(e,t,n,s)=>{if(e===ne.HUB&&t){if(t.format===ye.CYA)return ye.CYA;if(t.components)return it.get(t,n,s)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return ye.TASK},mu={get:hu},Rn="meta",Nn="documents",an=e=>e?.[Rn]?.[Nn]||[],pu=(e,t,n,s)=>{const r=s?an(t):an(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Rn]:void 0,[Nn]:r}},Eu={setForField:pu,get:an,name:Nn},Au={documents:Eu,name:Rn},yu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return!!se(t,n)}return!1},qt=(e,t)=>{if(e?.value)return e.value;const n=S.Utils.interpolateString(e?.field,t);return se(t,n)},Tu=(e,t)=>{if(!e||!t)return null;const n=S.Utils.interpolateString(e.target,t),s=se(t,n),r=qt(e,t),o=qt(e.cutoff,t),i=qt(e.ignore,t);let l=null;return s&&r&&Array.isArray(s)&&s.every((a,c)=>c===o?!1:c===i?!0:a===r||e.key&&se(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},Su=(e,t,n)=>{let s;if(e?.field){const r=S.Utils.interpolateString(e.field,t);s=se(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},Cu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return se(t,n)||null}return e?.value||null},gu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},bu=(e,t)=>{if(e?.condition){const n=e,s=S.Utils.interpolateString(n.field,t),r=se(t,s);switch(n.condition){case"changes":{const o=`${s}LastValue`,i=n[o]||null;return i===null?(n[o]=r,!1):r!==i?(n[o]=r,!0):!1}case"isTruthy":return!!r;case"isFalsy":return!r;default:return!1}}return!0},wu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=S.Utils.interpolateString(s,t),o=se(t,r);return o?(n=o,!0):!1}),n||(e.fallback?S.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},_u=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let s="";n.forEach(i=>{if(s!==""&&(s+="."),i.slice(-2)==="[]"){const l=i.slice(0,-2),a=br(l,t);s+=`${l}[${a}]`}else s+=i});const r=S.Utils.interpolateString(s,t);return se(t,r)?.length||0},Iu=(e,t)=>{const n=S.Utils.interpolateString(e.target,t),s=se(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?se(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?se(s,e.key)===e.value:!1},Pu={checkValueIsTruthy:yu,getIndexOfMatchingValueIn:Tu,doesContainValue:Iu,persistValueInFormData:Su,setValueInFormData:Cu,deleteValueInFormData:gu,getLength:_u,getFirstOf:wu},xu=(e,t,n)=>{const s=Pu[e.function];if(typeof s=="function")return s(e,t,n)},Ou=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(bu(s.run_when,t)){const r=xu(s,t,n);if(s.output){const o=S.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");Rs(t,o,r)}}}),t),Ru={runPageOperations:Ou},Nu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Lu=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},Du=e=>/^-?\d+$/.test(e),bt=e=>Du(e)?e.padStart(2,"0"):"",ge=e=>{const[t,n,s]=e.split("-");return`${bt(t)}-${bt(n)}-${s}`},Nr=e=>{const[t,n]=e.split(":");return`${bt(t)}:${bt(n)}`},Se="DD-MM-YYYY";K.extend(Be);const vu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isAfter(n)};K.extend(Be);const Fu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isBefore(n)};K.extend(Be);const ju=(e,t,n)=>{const s=n.components?.find(c=>c.fieldId===t.date),r=n.components?.find(c=>c.fieldId===t.time);if(!s||!r||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Qe(s,e[n.fieldId],e[n.fieldId])||Qe(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ge(e[n.fieldId]?.[t.date]),a=Nr(e[n.fieldId]?.[t.time]);return K(`${l} ${a}`,`${Se} HH:mm`).isBefore(K())};K.extend(Be);K.extend(fn);const Uu=(e,t)=>{const n=K(ge(e),Se).isBefore(K()),s=K(ge(e),Se).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};K.extend(Be);K.extend(fn);const Mu=(e,t)=>K(ge(e),Se).isAfter(K())?!0:!!t?.todayAllowed&&K(ge(e),Se).isToday(),ku=(e,t)=>e?e.length>t.value:!0,Bu=(e,t)=>e?e.length<t.value:!0,$u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Yu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},Hu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Vu=(e,t)=>e?t.array.includes(e):!0,qu=(e,t,n,s)=>{if(!e||!s)return!0;const r=Ut(t.collectionPath,s);return!Ge(t.collectionPath,s)?.some(l=>l.id===r?!1:t.caseInsensitive&&typeof e=="string"&&typeof l[n.id]=="string"?l[n.id].toUpperCase()===e.toUpperCase():l[n.id]===e)},Gu=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),Ku=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Wu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,zu=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Wu.test(t)}return!1},Ju=(e,t,n)=>n.components?.reduce((r,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?r:r+1:r,0)<2,Xu={conditionallyPermittedChange:Nu,conditionallyRequired:Lu,mustBeAfter:vu,mustBeBefore:Fu,mustBeEarlierDateTime:ju,mustBeGreaterThan:$u,mustBeInTheFuture:Mu,mustBeInThePast:Uu,mustBeLessThan:Yu,mustBeLongerThan:ku,mustBeNumbersOnly:Hu,mustBeOneOf:Vu,mustBeShorterThan:Bu,mustBeUniqueInCollection:qu,mustEnterAtLeastOne:Gu,mustHaveLessThanDecimalPlaces:Ku,mustNotContainSql:zu,mustSelectOnlyOne:Ju},Qu=(e,t,n,s)=>{const r=Xu[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Lr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Qu(t,r,e,n))}),s}},wt=(e,t,n)=>{if(!e)return[];const s=n||t,r=Lr(e,s);if(r)return{id:e.id,error:r};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;et(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Qe({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Zu=(e,t,n)=>{const s=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((r,o)=>{const i=(e.countOffset||0)+o+1,l=`${e.full_path||e.fieldId}[${o}]`,a={full_path:l,components:e.item.map(c=>{const u={...c,full_path:`${l}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(h=>({...h,message:S.Utils.interpolateString(o===0&&h.firstOnlyMessage?h.firstOnlyMessage:h.message,{index:i})}))),u})};s.push(wt(a,r,n))}),s.filter(r=>!!r).flat()};K.extend(Be);K.extend(fn);K.extend(Xr);const ed=(e,t)=>e==="02"?K().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ge(e),[n,s,r]=t.split("-"),o=parseInt(n,10),i=parseInt(s,10),l=[],a=[];if(r.length===0?(l.push("year"),a.push("Date must include a year")):r.length!==4&&(l.push("year"),a.push("Year must be 4 numbers")),s.length===0?(l.push("month"),a.push("Date must include a month")):(i>12||i<1)&&(l.push("month"),a.push("Month must be between 1 and 12")),n.length===0)l.push("day"),a.push("Date must include a day");else{const c=ed(s,r);(o>c||o<1)&&(l.push("day"),a.push(`Day must be between 1 and ${c}`))}if(l.length>0){const c={};return l.includes("day")&&(c.day=!0),l.includes("month")&&(c.month=!0),l.includes("year")&&(c.year=!0),{message:l.length===1?a[0]:"Enter a valid date",propsInError:c}}return K(t,Se).format(Se)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},td=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,nd=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,vr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&(td.test(e)||nd.test(e)))return;if(Array.isArray(n)){const r=n.filter(o=>o.type==="format");if(r&&r.length>0&&r[0].message)return r[0].message}return`Enter ${s} in the correct format, like jane.doe@homeoffice.gov.uk`}},sd="Invalid files must be deleted",Fr=(e,t)=>{if(!e)return;let n=!1;if(e.every(s=>(n=s.error,!n)),n){if(Array.isArray(t)){const s=t.filter(r=>r.type==="invalidFile");if(s&&s.length>0&&s[0].message)return s[0].message}return sd}},jr=(e,t,n,s)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(s)){const o=s.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},Ur=(e,t,n)=>{let s=!1;if((e||e===!1||e===0)&&(s=!0,typeof e=="string"?s=e.trim().length>0:Array.isArray(e)&&(s=e.length>0)),!s){if(Array.isArray(n)){const o=n.filter(i=>i.type==="required");if(o&&o.length>0&&o[0].message)return o[0].message}return`${t||"Field"} is required`}},Mr=(e,t,n,s,r,o=1e3)=>{if(!n||!r&&!t)return;if(r&&!t||t.length>o){if(Array.isArray(s)){const l=s.filter(a=>a.type==="length");if(l&&l.length>0&&l[0].message)return l[0].message}return`${e} must be ${o} characters or less`}},kr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Nr(e),[n,s]=t.split(":"),r=parseInt(n,10),o=parseInt(s,10),i=[],l=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),l.push("Enter a valid time")),n.length===0?(i.push("hour"),l.push("Time must include a hour")):(r>23||r<0)&&(i.push("hour"),l.push("Hour must be between 0 and 23")),s.length===0?(i.push("minute"),l.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),l.push("Minute must be between 0 and 59")),i.length>0){const c={};return i.includes("hour")&&(c.hour=!0),i.includes("minute")&&(c.minute=!0),i.includes("invalid")&&(c.invalid=!0),{message:i.length>1?"Enter a valid time":l[0],propsInError:c}}return{message:void 0,propsInError:void 0}},rd=(e,t)=>e?.type==="or"?ae.meetsOne(e.conditions,t):ae.meetsAll(e.conditions,t),Qe=(e,t,n)=>{const s=n||t;if(!Ie(e,{...s,...t}))return;if(e.type===_.CONTAINER)return wt(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===_.COLLECTION_SUMMARY&&(l=Ge(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!rd(e.requiredOverrideConditions,s))&&(r=Ur(l,e.label,e.custom_errors)),!r){switch(e.type){case _.COLLECTION:return Zu(e,l,s);case _.EMAIL:r=vr(l,e.label,e.custom_errors);break;case _.DATE:case _.TIME:{const a=e.type===_.DATE?Dr:kr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case _.CHECKBOXES:case _.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ze(n[e.id],c)&&(a=a.concat(wt({components:c.nested},n)))}),a.length>0)return a;break}case _.MULTI_FILE:r=Fr(l,e.custom_errors);break;case _.TEXT_AREA:r=Mr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=jr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Lr(e,l,n),e.type===_.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},od=(e,t=[])=>{let n=e.formData;if(e.collection){const s=gt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...gt.getData(e.collection.name,e.formData)?.[s]})}return Dt(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ie(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Qe(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:S.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},id={component:Qe,container:wt,email:vr,date:Dr,multifile:Fr,page:od,regex:jr,required:Ur,textarea:Mr,time:kr},w={CheckYourAnswers:cu,CollectionPage:gt,Component:ot,Condition:ae,Container:Lt,Data:de,Format:fu,FormPage:it,Hub:mu,Meta:Au,Operate:Ru,Validate:id,...S.Utils},ld="hods-form-container",Ln=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:h})=>{if(typeof s=="function")if(h.name===w.Meta.name)s({target:h});else{const f={...t,[h.name]:h.value};s({target:{name:e.fieldId,value:f}})}},a=h=>{const f=`${e.full_path||e.fieldId}.${h.fieldId}`;return h.type===_.CONTAINER?w.Container.show({...h,full_path:f},n):w.Component.show({...h,full_path:f},{...n,...se(n,e.full_path)})},c=w.classBuilder(ld,[],e.className),u=S.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(S.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((h,f)=>{const E=h.type===_.FILE?{}:"",y=t?t[h.fieldId]:E,p=`${e.full_path||e.fieldId}.${h.fieldId}`;return d.jsx(Ve,{...i,component:{...h,full_path:p,readonly:!!(e.readonly||h.readonly)},formData:n,value:y||E,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},ad=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,"action")){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},as=({group:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(ad(e))},[e,n]),e?.action?d.jsxs(S.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&d.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},cd=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(S.SmallHeading,{children:e}),t==="m"&&d.jsx(S.MediumHeading,{children:e})]}),ud=({row:e,classes:t,noChangeAction:n=!1})=>d.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[d.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&d.jsx(S.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(S.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Pn,{row:{action:e.action}})})]}),dd="govuk-summary-list",cn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=dd,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=S.Utils.classBuilder(r,o,i),u=S.Utils.cleanHtmlAttributes(a);let h=null;if(s){const f=e.filter(E=>!!E.action);h=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const E=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(ur,{title:f.key,classes:c},E):f.type==="heading"?d.jsx(cd,{title:f.key,size:f.size||"s",classes:c},E):f.type==="headingWithAction"?d.jsx(ud,{row:f,classes:c,noChangeAction:t},E):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(as,{group:f})},`${E}-actions`):d.jsx(cr,{row:f,classes:c,showAction:!t},E)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(as,{group:h})})]})})},fd="hods-check-your-answers",hd="Check your answers",cs=9,md=({title:e=hd,titleSize:t="l",pages:n,actions:s=[],onAction:r,onRowAction:o,hide_page_titles:i=!1,hide_actions:l=!1,hide_title:a=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,sections:E=[],type:y,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[T,N]=R.useState([]),[C,b]=R.useState([]),{errors:P}=He(),{hooks:U}=Pe();R.useEffect(()=>{const x=(q,X)=>w.CheckYourAnswers.getRows(q,o,U.onGetCYARows).map((V,z)=>({...V,value:d.jsx(bn,{value:V.value,component:V.component,formData:q.formData,placeholder:A},`${X}_${z}`)})),$=w.CollectionPage.mergePages(n).map((q,X)=>{const G=x(q,X);return G?.length?{...q,rows:G}:null}).filter(q=>!!q);N($)},[n,o,N]);const g=i?0:cs,L=x=>x===T.length-1;R.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map($=>$.pageId):[];b(j)})()},[b,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,errors:P,sections:E,type:y});if(v)return v;const F=x=>C.includes(x),I=x=>f?.find(j=>j.pageId===x),k=(x,j)=>{if(!x.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]});const $=vt(!1,x,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Pn,{row:{action:$}})})]})},O=()=>Array.from(new Set(P.map(j=>j.id))).map(j=>P.find($=>$.id===j));return d.jsxs("div",{className:fd,children:[e&&!a&&d.jsx(S.Heading,{size:t,children:e},"heading"),P&&P.length>0&&d.jsx(S.ErrorSummary,{errors:O()}),y===ne.TASK_CYA&&T.length>0&&E&&E.map(x=>x.tasks.filter(j=>j.state!==H.TYPES.SKIPPED).map((j,$)=>{const q=T.filter(X=>j.pages.some(G=>G===X.name));return d.jsxs(R.Fragment,{children:[d.jsx(S.MediumHeading,{children:q.length>0&&(j.displayName||j.name)}),q.map((X,G)=>{const V=F(X.id)||u,z=!i&&X.title&&!F(X.id);return d.jsxs(R.Fragment,{children:[z&&k(X,"s"),d.jsx(cn,{rows:X.rows,classModifiers:c,noChangeAction:V,noGroupAction:h,isGroup:F(X.id)})]},G)})]},$)})),y!==ne.TASK_CYA&&T&&T.map((x,j,$)=>{const q=!p||x.collection?x.rows:x.rows.filter(pe=>pe?.value?.props?.value);if(q.length===0)return null;const X=!i&&x.title&&!F(x.id),G=L(j)||F($[j].id)||$.length>j+1&&F($[j+1].id)?cs:g,V=F(x.id)?I(x.id):void 0,z=`govuk-!-margin-bottom-${G}`,fe=F(x.id)||u;return d.jsxs(R.Fragment,{children:[X&&k(x,"m"),V&&d.jsx("div",{className:"group-title",children:d.jsx(S.MediumHeading,{children:V.title||w.FormPage.getTitle(x.title,x.formData)})}),d.jsx(cn,{className:z,rows:q,classModifiers:c,noChangeAction:fe,noGroupAction:h,isGroup:F(x.id)})]},j)}),!l&&d.jsx(_n,{actions:s?.filter(x=>w.Component.show(x,n[n.length-1].formData)),onAction:x=>r(x)})]})},pd=lr,Ed=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=pd,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=R.useState({});let h=w.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let E=w.CollectionPage.getActiveIndex(e.collection.name,e.formData);const y=e,p=({target:P})=>{w.CollectionPage.setData(y.collection.name,P.value,e.formData),h=P.value;const U=e.collection.name.split(".").shift();u(g=>({...g,[U]:w.CollectionPage.getData(U,e.formData)}))},A=({target:P})=>{y.formData[P.name]=P.value,u(U=>({...U,[P.name]:P.value}))},T=P=>{p({target:{value:P}}),typeof n=="function"&&n(e.formData)},N=P=>{E=h.length,A({target:{name:`${f}ActiveId`,value:P}})},C=P=>{s(P,c,{})},b=({target:P})=>{if(E===null){const U=_t.v4();N(U),T([...h,{id:U,[P.name]:P.value}])}else T([...h.slice(0,E),{...h[E],[P.name]:P.value},...h.slice(E+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(In,{page:{...e,formData:{...e.formData,...h[E],[`${f}ActiveIndex`]:E,[`${f}NumberedIndex`]:typeof E=="number"?E+1:null},components:e.components.map(P=>({...P,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:b,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},Ad="hods-task-list",yd=({state:e=H.TYPES.CANNOT_START_YET})=>{const t=S.Utils.classBuilder(Ad,void 0,void 0),n=H.DETAILS[e]||H.DETAILS.cannotStartYet;return d.jsx(S.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Td="hods-task-list",Sd=({task:e,onClick:t})=>{const n=S.Utils.classBuilder(Td,void 0,void 0),[s,r]=R.useState(e.state!==H.TYPES.CANNOT_START_YET),[o,i]=R.useState(e.state);R.useEffect(()=>{r(e.state!==H.TYPES.CANNOT_START_YET),i(e.state)},[e.state,r,i]);const l=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:s?d.jsx(S.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(yd,{state:o})]})},Cd="hods-task-list",gd="Incomplete form",bd=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=gd,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=Cd,classModifiers:u=[],className:h="",formData:f={},annotations:E=[],...y})=>{const p=S.Utils.classBuilder(c,u,h),A=S.Utils.cleanHtmlAttributes(y),[T,N]=i.filter(g=>!g.skipped).reduce((g,L)=>[g[0]+(L.tasks?.filter(v=>v.state===H.TYPES.COMPLETE).length??0),g[1]+(L.tasks?.filter(v=>v.state!==H.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:b,text:P}=s&&s||{},U=g=>{typeof a=="function"&&a(g)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),E.length>0&&E.map(g=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:S.Utils.interpolateString(g.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:S.Utils.interpolateString(g.value,f)})]},g.key)),o&&N!==T&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:r})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${T} of ${N} sections`}),b&&P&&Ie(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:S.Utils.interpolateString(b,f)})}),d.jsx(S.TextArea,{id:C,fieldId:C,readOnly:!0,value:S.Utils.interpolateString(P,f)})]}),i.filter(g=>!g.skipped).map((g,L)=>d.jsxs(R.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${L+1}. `:" ",g.name]}),g.label&&d.jsx(S.Hint,{children:g.label}),d.jsx("ol",{className:p("items"),children:g.tasks.filter(v=>v.state!==H.TYPES.SKIPPED).map(v=>d.jsx(Sd,{task:v,onClick:U},`${g.name}-${v.name}`))})]},`${g.name}`))]})},Br=(e,t)=>e?.page||t,wd=(e,t,n)=>{const s=Br(e.action,e.pageId);s!==t&&n(s)},_d=(e,t,n,s=void 0)=>{const r=Br(e,t);r!==t&&n(r,s)},Id=(e,t)=>{t(e)},Te={cyaAction:wd,navigate:_d,submissionError:Id},Pd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,xd=(e,t)=>t(e).length===0,Od=["radios","checkboxes"],Rd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Nd(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ze(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const $r=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!Od.includes(s.type))return;Nd(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Rd(t.collection.name,t.formData),...n};const s=Ge(t.collection.name,n);if(s){const r=Ut(t.collection.name,n),o=s.map(i=>i.id===r?$r(i,{...t,collection:void 0}):i);On(t.collection.name,o,n)}}return n},Ld=(e,t,n)=>{if(e===re.HUB&&n===ye.CYA)return{title:""};if(e===re.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===re.PARTIAL_CYA){const r=w.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Yr=(e,t,n)=>{if(e)return e===re.HUB?n===ye.CYA||n===ye.TASK?void 0:n:t.find(s=>s.id===e)},Dd=(e,t,n)=>({pageId:e,cya:Ld(e,t,n),page:Yr(e,t,n)}),us=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),vd=(e,t,n)=>e.page?.type===re.PARTIAL_CYA?us(n||t,e.pageId):n||t,ds=(e,t,n,s,r)=>{if(!t&&r===ne.FORM_WITH_TASK){if(s?.formStatus?.taskPage){const i=n.find(l=>l.id===s.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:re.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{it.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||re.HUB},Hr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!it.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Fd=(e,t,n)=>Hr(e,t,n)||re.CYA,jd=e=>e.length>0?e[0].id:void 0,un=(e,t,n,s,r)=>{if(s){if(s.type===W.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===W.TYPES.SAVE_AND_RETURN)return e===ne.HUB?re.HUB:void 0}switch(e){case ne.HUB:return ds(s);case ne.CYA:return Fd(t,n,r);case ne.FORM_WITH_TASK:case ne.TASK:return ds(s,n,t,r,e);case ne.WIZARD:return Hr(t,n,r);default:return jd(t)}},Ud=(e,t,n,s,r,o,i,l)=>{if(e===ne.TASK||e===ne.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(re.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===W.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:un(e,t,n,s,r)}:o.pages?.includes(n)&&(a.tasks[o.name]={complete:!!s?.complete,currentPage:n}):l&&l.forEach(c=>{c.tasks.forEach(u=>{const h=u.pages[u.pages.length-1];(h===n||h.id===n)&&i&&u?.type==="pre-task-list"?a.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(a.tasks[u.name]={complete:!1,currentPage:n})})}),a.taskPage=a.tasks[o.name].currentPage,a}return s?.type===W.TYPES.SAVE_AND_RETURN?{page:n}:{page:un(e,t,n,s,r)}},Md=({complete:e,currentPage:t},n=H.TYPES.NOT_STARTED)=>e?H.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?H.TYPES.IN_PROGRESS:n,kd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===H.TYPES.SKIPPED?s:s&&o?.complete},!0),Vr=(e,t)=>{const n=e[t-1].state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:Vr(e,t-1):!1},Bd=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return Md(s[e.name],e.state);if(r)return e.depends_on&&!kd(s,e.depends_on,e.ignoreSkipped)?H.TYPES.CANNOT_START_YET:H.TYPES.NOT_STARTED;let i=o;return t&&(i=Vr(n,t)),i?H.TYPES.NOT_STARTED:H.TYPES.CANNOT_START_YET},$d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==H.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Bd(l,i,r,t,n,s)}),r},qr=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:qr(e,t-1):!1},Yd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!w.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:H.TYPES.SKIPPED}))}:{...i}});r.forEach(i=>{const l=i;l.tasks=l.tasks.map(a=>{const c=a.show_when?[a.show_when].flat():[];return s&&!w.Condition.meetsAll(c,s)?{...a,state:H.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===H.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:H.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||qr(r,l);a.tasks=$d(a,o,n,c)}),r},Hd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},ke=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)ke(e[r],t);const n=t.split(".");let s=e;for(let r=0;r<n.length-1;r+=1)if(s=s[n[r]],s===void 0)return;s[n[n.length-1]]&&delete s[n[n.length-1]]},Gr=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},Dn=(e,t)=>{const n=Gr(e);return n?`${n}.${t}`:t},Vd=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&e.splice(t,1)}},qd=e=>{const t=(n,s)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(r=>{t(r,s)}):Object.keys(n).forEach(r=>{r==="field"&&s.push(n[r]),t(n[r],s)})),s);return e.show_when?new Set(t(e.show_when,[])||[]):null},Gd=(e,t)=>{const n=e.split(".");for(let s=n.length;s>0;s-=1){const r=n.slice(0,s).join("."),o=t.get(r);if(o)return o}return null},Je=(e,t)=>e.show_when?e.show_when?.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t):!0,Kr=(e,t,n)=>{const s=t.get(e.use)??n.get(e.use)??e,r=JSON.parse(JSON.stringify(s));return e.use&&e.show_when&&(r.show_when=e.show_when),r},Kd=(e,t,n)=>{const{meta:{documents:s}}=n,r=t[e.fieldId];if(!s||!r)return;const o=Array.isArray(r)?r:[r];for(let i=o.length-1;i>=0;i-=1){const l=s.findIndex(a=>a.url===o[i].url);l!==-1&&s.splice(l,1)}},dn=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):dn(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):dn(e[t])})},Wr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Wd=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;ke(e,t),Wr(n,r=>{const o=Dn(t,r.fieldId);s[o]>1?s[o]-=1:ke(e,o)})}},zd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&Kd(r,n,s),r.preserveInPayload)return;ke(n,r.fieldId),Wr(r,o=>{const i=Dn(r.fieldId,o.fieldId);e.has(i)||ke(n,i)})}})},fs=e=>Array.isArray(e)?e:[e],Jd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,h)=>{u.fieldId&&(h=h?`${h}.${u.fieldId}`:u.fieldId,o[h]=(o[h]||0)+1,u.path=h,c.show_when&&(u.show_when=u.show_when?[...fs(c.show_when),...fs(u.show_when)]:c.show_when),Hd(h,u,r),u.components?u.components.forEach(f=>{a(c,f,h)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const E=!Ze(se(s,h),f),y=f.show_when;f.nested.forEach(p=>{E&&i.push(Dn(h,p.fieldId)),y&&(p.show_when=y),a(c,p,Gr(h))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const h=Kr(u,t,n);a(c,h,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:ke(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},Xd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=qd(s);if(r)if(t.has(s.path)){const o=t.get(s.path);r.forEach(i=>o.add(i))}else t.set(s.path,new Set(r))})}),t},Qd=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const E=Gd(f,t);if(E)E.forEach(y=>{a.has(y)||i(a,y,u)});else{const y=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(y);if(p){const A=p[1],T=s.get(A);T&&T.childPages?.forEach(N=>{if(N.show_when){const C=JSON.stringify(N.show_when),b=`It is not possible to reliably clean hidden data when a component is dependent on a
|
|
10
10
|
collection's data, and that collection is itself dependent on data elsewhere in the form.
|
|
11
11
|
The dependency path is ${f}, and the chained show_when is ${C}.
|
|
12
|
-
The form will need to be changed to break this chained dependency`;throw new Error(I)}})}}}),ke(c,o)||Ld(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(m=>{l.has(m)||i(l,m,e)})})},Md=(e,t,n,s)=>{e?.forEach((r,o)=>{ke(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(m=>{const f=ke(m,a);m.components?.forEach(y=>{const h=Yr(y,n,s);if(!h.fieldId)return;const p=ke(y,a);f&&p&&ke(h,a)?c.add(h.fieldId):u.set(h.id,h)})}),Dd(c,u,l,t)}),i&&Nd(i)})},kd=(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=Tr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Fd(o,s,r,n),c=jd(i);return Ud(c,i,l,a,t,n),Md(a,n,s,r),en(n),n},W={canActionProceed:fd,canCYASubmit:hd,cleanHiddenNestedData:jr,getFormState:yd,getRelevantPages:Td,getNextPageId:Zt,getPage:Ur,getSubmissionStatus:gd,getUpdatedSectionStates:Pd,clearOutUncompletedRoutes:kd},$d=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w)=>{if(t.type===G.TYPES.SUBMIT&&y!==he.TASK){if(e("submit"),W.canCYASubmit(n,s.pages)&&!A){w(!0);const L=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),C={pages:n,components:o};W.clearOutUncompletedRoutes(r,C,L),L.formStatus=W.getSubmissionStatus(a,n,c,t,L,u,!0),l(L),m.onSubmit(t.type,L,()=>{m.onFormComplete(),w(!1)},I=>{w(!1),pe.submissionError(I,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?W.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===G.TYPES.SAVE_AND_CONTINUE&&y===he.TASK&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(te.HUB)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SUBMIT&&y===he.TASK&&(e("submit"),C)){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),_={pages:n,components:o};W.clearOutUncompletedRoutes(r,_,I),I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{m.onFormComplete(),w(!1)},U=>{w(!1),pe.submissionError(U,f)})}if(t.type===G.TYPES.SAVE_AND_NAVIGATE&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(t.page)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SAVE_AND_RETURN&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!1),l(I),m.onSubmit(t.type,I,()=>{a===Z.TASK?h(void 0):h(te.HUB),w(!1)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.NAVIGATE&&(h(W.getNextPageId(a,n,c,t,p.page?.formData)),w(!1)),t.type===G.TYPES.CANCEL){const I=g.Format.form({pages:n,components:o},{...i},Te.CANCEL);m.onCancel(I),w(!1)}}},ls=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w,L,C,I,_)=>{const U={...r},S=o,R=s.onAction(S.page.formData,t,r,e.customAction);S.page.formData=R.formData;let v=R.patch;if(S.page.formData={...S.page.formData,...v},e.type===G.TYPES.CANCEL){s.onCancel(S.page.formData),I(!1);return}if(W.canActionProceed(e,S.page,i.page,_)&&(!C||e.ignoreSubmittingFlag))if(v=W.cleanHiddenNestedData(v,S.page),I(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?yn(x.field,x.value,o.page.formData):g.Data.setDataItem(o.page.formData,x.field,x.value)}),S.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===G.TYPES.NAVIGATE)pe.navigate(e,f,l),I(!1);else{let D=V=>l(W.getNextPageId(a,u,f,e,V)),x,k;e.collection&&(x=e.collection,k=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let P,N;switch(x&&(P=S.page.formData[x],P&&P.length>0&&S.page.formData[`${x}ActiveId`]&&(N=P.findIndex(V=>V.id===S.page.formData[`${x}ActiveId`]))),e.type){case G.TYPES.SUBMIT:y("submit");break;case G.TYPES.SAVE_AND_NAVIGATE:const V={...h};P&&P.length>0&&e.resetActiveId&&(S.page.formData[`${x}ActiveId`]=P[0].id),P&&P.length>0&&!e.resetActiveId&&(N!==void 0&&N+1<S.page.formData[x].length&&(S.page.formData[k]="Yes"),N!==void 0&&N+1===S.page.formData[x].length&&S.page.formData[k]&&(S.page.formData[k]="No")),D=()=>pe.navigate(e,f,l,V);break;case G.TYPES.COLLECTION_ADD:if(N===void 0||P.length===0||N+1===S.page.formData[x].length?g.CollectionPage.addEntry(e.collection,S.page.formData):S.page.formData[`${e.collection}ActiveId`]=P[N+1].id,S.page.formData[`${e.collection}`]&&S.page.formData[`${e.collection}`].length>0){const ae=S.page.formData[`${e.collection}`].length-1;Object.keys(S.page.formData[`${e.collection}`][ae]).filter(re=>re in S.page.formData&&re!=="id").forEach(re=>delete S.page.formData[re])}D=()=>pe.navigate(e,f,l);break;case G.TYPES.COLLECTION_DUPLICATE:g.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(D=()=>pe.navigate(e,f,l));break;case G.TYPES.COLLECTION_REMOVE:const K=e.targetId||S.page.formData[`${e.collection.split(".").pop()}ActiveId`],J=g.CollectionPage.removeEntry(e.collection,o.page.formData,K);e.recordRemoval&&(S.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...J});const de=S.page.formData.id;J!==null&&Object.keys(J).filter(fe=>fe in S.page.formData).forEach(fe=>delete S.page.formData[fe]),Object.assign(S.page.formData,P[P.length-1]),S.page.formData.id=de,P.length>0?S.page.formData[`${e.collection}ActiveId`]=P[P.length-1].id:(delete S.page.formData[`${e.collection}ActiveId`],delete S.page.formData[e.collection]),D=()=>pe.navigate(e,f,l);break}g.Data.deleteValues(r,o.page.formData);const j=g.Format.form({pages:u,components:m},{...r,...t,...o.page.formData},Te.SUBMIT);j.formStatus=W.getSubmissionStatus(a,u,f,e,j,h,!0,A?.sections),v&&p(j);const M={pages:u,components:m};e.type===G.TYPES.SUBMIT&&W.clearOutUncompletedRoutes(c,M,j);let Y,H;a===Z.HUB&&Object.keys(n).length>0&&(Y=Object.keys(n)[0],H=Object.values(n)[0]),s.onSubmit(e.type,j,V=>{const K={...j,...V};w({data:K}),D(K),I(!1)},(V,K=!0)=>{pe.submissionError(V,L),K&&p({...U}),I(!1)},Y,H,f)}},as=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(W.getPage(a,t))}),n(e);const l={...i};if(i.state===B.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(te.CYA,l);else if(i.state===B.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)}},Vr=({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:m=Bd,classModifiers:f=[],className:y="",hide_title:h,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:w="",viewOnly:L=!0,hideBlankRows:C=!1})=>d.jsx(Qs,{overrides:u,children:d.jsx(Zs,{children:d.jsx(Yd,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:m,classModifiers:f,className:y,hashLink:c,hide_title:h,summaryListClassModifiers:p,noChangeAction:A,newPageId:w,viewOnly:L,hideBlankRows:C})})}),Bd="hods-form",Yd=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:m,hashLink:f,hide_title:y,summaryListClassModifiers:h,noChangeAction:p,newPageId:A,viewOnly:w,hideBlankRows:L})=>{const[C,I]=O.useState({}),[_,U]=O.useState(),[S,R]=O.useState([]),[v,D]=O.useState(void 0),[x,k]=O.useState(W.getNextPageId(n,o,null,null,a)),[P,N]=O.useState(W.getFormState(x,S,v)),[j,M]=O.useState({}),[Y,H]=O.useState({}),[V,K]=O.useState("load"),[J,de]=O.useState(!1),[ae,fe]=O.useState(!1),{hooks:re}=ge(),{addErrors:_t,clearErrors:bn,errors:wn,validate:Pt}=De();window.onpopstate=$=>{if(!document.location.hash&&($.state&&$.state.fullPages!==void 0&&M(X=>({...X,fullPages:$.state?.fullPages})),bn(),de(!0),re.onGoingBack($.state?$.state:null,P.page?.formData),r&&S&&C&&P.page?.formData&&V===void 0)){const X=g.Format.form({pages:S,components:r},{...C,...P.page.formData},Te.SUBMIT);if(X?.formStatus?.taskPage){const ne=X.formStatus.tasks;Object.keys(ne).forEach(Se=>{const Pn=ne[Se];Pn.currentPage&&!Pn.complete&&delete ne[Se].currentPage}),delete X.formStatus.taskPage}I(X)}},O.useEffect(()=>{r&&o&&a&&(V==="load"||w)&&(I(g.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,I,V,w]),O.useEffect(()=>{R(g.FormPage.getAll(o,r,{...C}))},[r,o,C,R]),O.useEffect(()=>{k($=>$||W.getNextPageId(n,S))},[n,S,k]),O.useEffect(()=>{D(g.Hub.get(n,i,r,{...C}))},[n,i,C,r,D]),O.useEffect(()=>{n===Z.HUB&&J&&C&&P.page?.formData&&(P.page.formData={...C}),de(!1),N(W.getFormState(x,S,v))},[S,v,x,N,n,J,C,P.page]),O.useEffect(()=>{K(void 0),re.onFormLoad($=>{M($)})},[re]),O.useEffect(()=>{H(i)},[i]),O.useEffect(()=>{_?.data&&(I(_.data),U(void 0))},[_,I,U]);const xt=i?.sections,In=i?.nonSequential;O.useEffect(()=>{const $=j.fullPages;if($&&($.forEach(X=>{const ne=X;ne&&(ne.formData=C)}),M(X=>({...X,fullPages:$}))),xt){const X=C?.formStatus?.tasks||{},ne=W.getUpdatedSectionStates(xt,X,In,C);H(Se=>({...Se,sections:[...ne]}))}},[j.fullPages,C,xt,In]);const Pe=($,X={})=>{bn(),k($),re.onPageChange($,X)};O.useEffect(()=>{A!==void 0&&k(A)},[A]);const _n=$=>{re.onChange($)},qr=($,X)=>{if(typeof X=="function"){const ne=X({...C});ne&&I(ne)}P.page?.type===te.PARTIAL_CYA&&!l.disableTaskSwitch&&Y.sections.every(ne=>ne.tasks.every(Se=>Se.pages.includes($.pageId)&&Se.name!==j.name?(as(Se,S,M,Y,C,Pe),!1):!0)),$&&pe.cyaAction($,x,Pe)},Gr=g.classBuilder(c,u,m);if(v===he.TASK){const $=l;$.actions=[G.TYPES.SAVE_AND_CONTINUE,G.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:Hd,nonSequential:Vd,...Kr}=Y;return d.jsxs("div",{className:Gr(),children:[e&&!y&&x===te.HUB&&d.jsx(T.Heading,{size:t,children:e}),P.cya&&d.jsx(Zu,{pages:W.getRelevantPages(P,S,j.fullPages),...l,...P.page?.type===te.PARTIAL_CYA&&{actions:P.page.actions?.filter($=>g.Component.show($,C))},...P.cya,onAction:$=>{$d(K,$,S,Pt,s,r,C,I,n,x,j,re,_t,v,Pe,P,ae,fe)},onRowAction:qr,summaryListClassModifiers:h,hide_title:y,noChangeAction:P.cya.hideChangeActions??p,noGroupAction:P.cya.hideGroupActions??!1,sections:typeof Y<"u"?Y.sections:[],type:n,hideBlankRows:L}),v===he.TASK&&P.pageId===te.HUB&&d.jsx(ad,{...Kr,refNumber:C.businessKey,onTaskAction:$=>{as($,S,M,Y,C,Pe)},annotations:Y?.taskListAnnotations||[],formData:C}),P.page&&!P.cya&&!P.page.collection&&d.jsx(pn,{page:P.page,pages:[...S],onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},onChange:_n,hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae,pageId:x}),P.page&&!P.cya&&P.page.collection&&d.jsx(td,{page:P.page,pages:S,onCollectionChange:_n,onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae})]})};exports.Container=Cn;exports.FormComponent=Fe;exports.FormRenderer=Vr;exports.FormTypes=Z;exports.HooksContextProvider=Qs;exports.HubFormats=he;exports.Models=Mo;exports.PageActions=mn;exports.SummaryList=Qt;exports.Utils=g;exports.ValidationContextProvider=Zs;exports.default=Vr;
|
|
12
|
+
The form will need to be changed to break this chained dependency`;throw new Error(b)}})}}}),Je(c,o)||Wd(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(h=>{l.has(h)||i(l,h,e)})})},Zd=(e,t,n,s)=>{e?.forEach((r,o)=>{Je(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(h=>{const f=Je(h,a);h.components?.forEach(E=>{const y=Kr(E,n,s);if(!y.fieldId)return;const p=Je(E,a);f&&p&&Je(y,a)?c.add(y.fieldId):u.set(y.id,y)})}),zd(c,u,l,t)}),i&&Vd(i)})},ef=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=wr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Jd(o,s,r,n),c=Xd(i);return Qd(c,i,l,a,t,n),Zd(a,n,s,r),dn(n),n},Q={canActionProceed:Pd,canCYASubmit:xd,cleanHiddenNestedData:$r,getFormState:Dd,getRelevantPages:vd,getNextPageId:un,getPage:Yr,getSubmissionStatus:Ud,getUpdatedSectionStates:Yd,clearOutUncompletedRoutes:ef},tf=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T)=>{if(t.type===W.TYPES.SUBMIT&&E!==ye.TASK){if(e("submit"),Q.canCYASubmit(n,s.pages)&&!A){T(!0);const N=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),C={pages:n,components:o};Q.clearOutUncompletedRoutes(r,C,N),N.formStatus=Q.getSubmissionStatus(a,n,c,t,N,u,!0),l(N),h.onSubmit(t.type,N,()=>{h.onFormComplete(),T(!1)},b=>{T(!1),Te.submissionError(b,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Q.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===W.TYPES.SAVE_AND_CONTINUE&&E===ye.TASK&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(re.HUB)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.SUBMIT&&E===ye.TASK&&(e("submit"),C)){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),P={pages:n,components:o};Q.clearOutUncompletedRoutes(r,P,b),b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{h.onFormComplete(),T(!1)},U=>{T(!1),Te.submissionError(U,f)})}if(t.type===W.TYPES.SAVE_AND_NAVIGATE&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(t.page)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.SAVE_AND_RETURN&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!1),l(b),h.onSubmit(t.type,b,()=>{a===ne.TASK?y(void 0):y(re.HUB),T(!1)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.NAVIGATE&&(y(Q.getNextPageId(a,n,c,t,p.page?.formData)),T(!1)),t.type===W.TYPES.CANCEL){const b=w.Format.form({pages:n,components:o},{...i},we.CANCEL);h.onCancel(b),T(!1)}}},hs=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T,N,C,b,P)=>{const U={...r},g=o,L=s.onAction(g.page.formData,t,r,e.customAction);g.page.formData=L.formData;let v=L.patch;if(g.page.formData={...g.page.formData,...v},e.type===W.TYPES.CANCEL){s.onCancel(g.page.formData),b(!1);return}if(Q.canActionProceed(e,g.page,i.page,P)&&(!C||e.ignoreSubmittingFlag))if(v=Q.cleanHiddenNestedData(v,g.page),b(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(I=>{I.isCollection?On(I.field,I.value,o.page.formData):w.Data.setDataItem(o.page.formData,I.field,I.value)}),g.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===W.TYPES.NAVIGATE)Te.navigate(e,f,l),b(!1);else{let F=G=>l(Q.getNextPageId(a,u,f,e,G)),I,k;e.collection&&(I=e.collection,k=`addAnother${I.charAt(0).toUpperCase()+I.slice(1)}`.slice(0,-1));let O,x;switch(I&&(O=g.page.formData[I],O&&O.length>0&&g.page.formData[`${I}ActiveId`]&&(x=O.findIndex(G=>G.id===g.page.formData[`${I}ActiveId`]))),e.type){case W.TYPES.SUBMIT:E("submit");break;case W.TYPES.SAVE_AND_NAVIGATE:const G={...y};O&&O.length>0&&e.resetActiveId&&(g.page.formData[`${I}ActiveId`]=O[0].id),O&&O.length>0&&!e.resetActiveId&&(x!==void 0&&x+1<g.page.formData[I].length&&(g.page.formData[k]="Yes"),x!==void 0&&x+1===g.page.formData[I].length&&g.page.formData[k]&&(g.page.formData[k]="No")),F=()=>Te.navigate(e,f,l,G);break;case W.TYPES.COLLECTION_ADD:if(x===void 0||O.length===0||x+1===g.page.formData[I].length?w.CollectionPage.addEntry(e.collection,g.page.formData):g.page.formData[`${e.collection}ActiveId`]=O[x+1].id,g.page.formData[`${e.collection}`]&&g.page.formData[`${e.collection}`].length>0){const pe=g.page.formData[`${e.collection}`].length-1;Object.keys(g.page.formData[`${e.collection}`][pe]).filter(J=>J in g.page.formData&&J!=="id").forEach(J=>delete g.page.formData[J])}F=()=>Te.navigate(e,f,l);break;case W.TYPES.COLLECTION_DUPLICATE:w.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(F=()=>Te.navigate(e,f,l));break;case W.TYPES.COLLECTION_REMOVE:const V=e.targetId||g.page.formData[`${e.collection.split(".").pop()}ActiveId`],z=w.CollectionPage.removeEntry(e.collection,o.page.formData,V);e.recordRemoval&&(g.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...z});const fe=g.page.formData.id;z!==null&&Object.keys(z).filter(Y=>Y in g.page.formData).forEach(Y=>delete g.page.formData[Y]),Object.assign(g.page.formData,O[O.length-1]),g.page.formData.id=fe,O.length>0?g.page.formData[`${e.collection}ActiveId`]=O[O.length-1].id:(delete g.page.formData[`${e.collection}ActiveId`],delete g.page.formData[e.collection]),F=()=>Te.navigate(e,f,l);break}w.Data.deleteValues(r,o.page.formData);const j=w.Format.form({pages:u,components:h},{...r,...t,...o.page.formData},we.SUBMIT);j.formStatus=Q.getSubmissionStatus(a,u,f,e,j,y,!0,A?.sections),v&&p(j);const $={pages:u,components:h};e.type===W.TYPES.SUBMIT&&Q.clearOutUncompletedRoutes(c,$,j);let q,X;a===ne.HUB&&Object.keys(n).length>0&&(q=Object.keys(n)[0],X=Object.values(n)[0]),s.onSubmit(e.type,j,G=>{const V={...j,...G};T({data:V}),F(V),b(!1)},(G,V=!0)=>{Te.submissionError(G,N),V&&p({...U}),b(!1)},q,X,f)}},ms=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(Q.getPage(a,t))}),n(e);const l={...i};if(i.state===H.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(re.CYA,l);else if(i.state===H.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},zr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:h=nf,classModifiers:f=[],className:E="",hide_title:y,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:T="",viewOnly:N=!0,hideBlankRows:C=!1})=>d.jsx(sr,{overrides:u,children:d.jsx(rr,{children:d.jsx(sf,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:h,classModifiers:f,className:E,hashLink:c,hide_title:y,summaryListClassModifiers:p,noChangeAction:A,newPageId:T,viewOnly:N,hideBlankRows:C})})}),nf="hods-form",sf=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:h,hashLink:f,hide_title:E,summaryListClassModifiers:y,noChangeAction:p,newPageId:A,viewOnly:T,hideBlankRows:N})=>{const[C,b]=R.useState({}),[P,U]=R.useState(),[g,L]=R.useState([]),[v,F]=R.useState(void 0),[I,k]=R.useState(Q.getNextPageId(n,o,null,null,a)),[O,x]=R.useState(Q.getFormState(I,g,v)),[j,$]=R.useState({}),[q,X]=R.useState({}),[G,V]=R.useState("load"),[z,fe]=R.useState(!1),[pe,Y]=R.useState(!1),{hooks:J}=Pe(),{addErrors:Ke,clearErrors:We,errors:Ee,validate:xe}=He();window.onpopstate=B=>{if(!document.location.hash&&(B.state&&B.state.fullPages!==void 0&&$(ee=>({...ee,fullPages:B.state?.fullPages})),We(),fe(!0),J.onGoingBack(B.state?B.state:null,O.page?.formData),r&&g&&C&&O.page?.formData&&G===void 0)){const ee=w.Format.form({pages:g,components:r},{...C,...O.page.formData},we.SUBMIT);if(ee?.formStatus?.taskPage){const ie=ee.formStatus.tasks;Object.keys(ie).forEach(_e=>{const Fn=ie[_e];Fn.currentPage&&!Fn.complete&&delete ie[_e].currentPage}),delete ee.formStatus.taskPage}b(ee)}},R.useEffect(()=>{r&&o&&a&&(G==="load"||T)&&(b(w.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,b,G,T]),R.useEffect(()=>{L(w.FormPage.getAll(o,r,{...C}))},[r,o,C,L]),R.useEffect(()=>{k(B=>B||Q.getNextPageId(n,g))},[n,g,k]),R.useEffect(()=>{F(w.Hub.get(n,i,r,{...C}))},[n,i,C,r,F]),R.useEffect(()=>{n===ne.HUB&&z&&C&&O.page?.formData&&(O.page.formData={...C}),fe(!1),x(Q.getFormState(I,g,v))},[g,v,I,x,n,z,C,O.page]),R.useEffect(()=>{V(void 0),J.onFormLoad(B=>{$(B)})},[J]),R.useEffect(()=>{X(i)},[i]),R.useEffect(()=>{P?.data&&(b(P.data),U(void 0))},[P,b,U]);const Ae=i?.sections,M=i?.nonSequential;R.useEffect(()=>{const B=j.fullPages;if(B&&(B.forEach(ee=>{const ie=ee;ie&&(ie.formData=C)}),$(ee=>({...ee,fullPages:B}))),Ae){const ee=C?.formStatus?.tasks||{},ie=Q.getUpdatedSectionStates(Ae,ee,M,C);X(_e=>({..._e,sections:[...ie]}))}},[j.fullPages,C,Ae,M]);const oe=(B,ee={})=>{We(),k(B),J.onPageChange(B,ee)};R.useEffect(()=>{A!==void 0&&k(A)},[A]);const be=B=>{J.onChange(B)},ve=(B,ee)=>{if(typeof ee=="function"){const ie=ee({...C});ie&&b(ie)}O.page?.type===re.PARTIAL_CYA&&!l.disableTaskSwitch&&q.sections.every(ie=>ie.tasks.every(_e=>_e.pages.includes(B.pageId)&&_e.name!==j.name?(ms(_e,g,$,q,C,oe),!1):!0)),B&&Te.cyaAction(B,I,oe)},lt=w.classBuilder(c,u,h);if(v===ye.TASK){const B=l;B.actions=[W.TYPES.SAVE_AND_CONTINUE,W.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:vn,nonSequential:Fe,...Jr}=q;return d.jsxs("div",{className:lt(),children:[e&&!E&&I===re.HUB&&d.jsx(S.Heading,{size:t,children:e}),O.cya&&d.jsx(md,{pages:Q.getRelevantPages(O,g,j.fullPages),...l,...O.page?.type===re.PARTIAL_CYA&&{actions:O.page.actions?.filter(B=>w.Component.show(B,C))},...O.cya,onAction:B=>{tf(V,B,g,xe,s,r,C,b,n,I,j,J,Ke,v,oe,O,pe,Y)},onRowAction:ve,summaryListClassModifiers:y,hide_title:E,noChangeAction:O.cya.hideChangeActions??p,noGroupAction:O.cya.hideGroupActions??!1,sections:typeof q<"u"?q.sections:[],type:n,hideBlankRows:N}),v===ye.TASK&&O.pageId===re.HUB&&d.jsx(bd,{...Jr,refNumber:C.businessKey,onTaskAction:B=>{ms(B,g,$,q,C,oe)},annotations:q?.taskListAnnotations||[],formData:C}),O.page&&!O.cya&&!O.page.collection&&d.jsx(In,{page:O.page,pages:[...g],onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,I,V,j,b,q,U,Ke,pe,Y,Ee)},onChange:be,hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe,pageId:I}),O.page&&!O.cya&&O.page.collection&&d.jsx(Ed,{page:O.page,pages:g,onCollectionChange:be,onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,I,V,j,b,q,U,Ke,pe,Y,Ee)},hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe})]})};exports.Container=Ln;exports.FormComponent=Ve;exports.FormRenderer=zr;exports.FormTypes=ne;exports.HooksContextProvider=sr;exports.HubFormats=ye;exports.Models=$o;exports.PageActions=_n;exports.SummaryList=cn;exports.Utils=w;exports.ValidationContextProvider=rr;exports.default=zr;
|