@ukhomeoffice/cop-react-form-renderer 8.0.0-alpha.3 → 8.0.0-alpha.4

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.
Files changed (3) hide show
  1. package/dist/index.cjs +8 -4
  2. package/dist/index.js +4789 -4185
  3. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -1,5 +1,9 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const h=require("react/jsx-runtime"),I=require("@ukhomeoffice/cop-react-components"),B=require("react"),ct=require("uuid"),De={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},Si="alert",Ci="autocomplete",gi="calculation",xi="checkboxes",Ii="collection",_i="collection-summary",Pi="container",wi="date",bi="details",Di="email",Oi="file",Li="heading",Ni="html",Ri="inset-text",Fi="list",$i="multifile",Mi="paragraph",Ui="phone-number",ji="radios",Yi="select",Bi="text",ki="textarea",qi="time",Hi="warning",R={ALERT:Si,AUTOCOMPLETE:Ci,CALCULATION:gi,CHECKBOXES:xi,COLLECTION:Ii,COLLECTION_SUMMARY:_i,CONTAINER:Pi,DATE:wi,DETAILS:bi,EMAIL:Di,FILE:Oi,HEADING:Li,HTML:Ni,INSET_TEXT:Ri,LIST:Fi,MULTI_FILE:$i,PARAGRAPH:Mi,PHONE_NUMBER:Ui,RADIOS:ji,SELECT:Yi,TEXT:Bi,TEXT_AREA:ki,TIME:qi,WARNING:Hi},Vi="blur",Gi="submit",Wi="cancel",Te={BLUR:Vi,SUBMIT:Gi,CANCEL:Wi},Ki="cya",zi="hub",Ji="partial-cya",ae={CYA:Ki,HUB:zi,PARTIAL_CYA:Ji},Xi="cya",Qi="form",Zi="form-with-task-list",ea="hub-and-spoke",ta="task-list",ra="task-list-cya",na="wizard",ne={CYA:Xi,FORM:Qi,FORM_WITH_TASK:Zi,HUB:ea,TASK:ta,TASK_CYA:ra,WIZARD:na},sa="CYA",ia="TASK",pe={CYA:sa,TASK:ia},lr="cancel",Xn="collectionAdd",Qn="collectionDuplicate",Zn="collectionRemove",es="navigate",ur="saveAndContinue",cr="saveAndNavigate",dr="saveAndReturn",fr="submit",Ze={CANCEL:lr,COLLECTION_ADD:Xn,COLLECTION_DUPLICATE:Qn,COLLECTION_REMOVE:Zn,NAVIGATE:es,SAVE_AND_CONTINUE:ur,SAVE_AND_NAVIGATE:cr,SAVE_AND_RETURN:dr,SUBMIT:fr},aa={[lr]:{type:lr,validate:!1,label:"Cancel",classModifiers:"secondary"},[Xn]:void 0,[Qn]:void 0,[Zn]:void 0,[es]:void 0,[ur]:{type:ur,validate:!0,label:"Save and continue"},[cr]:{type:cr,validate:!0,label:"Save and continue"},[dr]:{type:dr,validate:!1,label:"Save and return later",classModifiers:"secondary"},[fr]:{type:fr,validate:!0}},X={TYPES:Ze,DEFAULTS:aa},ts="complete",rs="inProgress",ns="notStarted",ss="cannotStartYet",is="skipped",oa={COMPLETE:ts,IN_PROGRESS:rs,NOT_STARTED:ns,CANNOT_START_YET:ss,SKIPPED:is},la={[ts]:{label:"Completed",colour:"dark-blue"},[rs]:{label:"In Progress",colour:"white"},[ns]:{label:"Not Started",colour:"dark-grey"},[ss]:{label:"Cannot Start Yet",colour:"dark-grey"},[is]:{label:"Skipped",colour:"dark-grey"}},z={TYPES:oa,DETAILS:la},ua={CollectionLabels:De,ComponentTypes:R,EventTypes:Te,FormPages:ae,FormTypes:ne,HubFormats:pe,PageAction:X,TaskStates:z},as=e=>{try{const t=ca(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},ca=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return We(e,(r,n)=>r*n);case"divide":return We(e,(r,n)=>r/n);case"plus":return We(e,(r,n)=>r+n);case"minus":return We(e,(r,n)=>r-n);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},We=(e,t)=>{const{args:r}={...e.formula};if(r.length<2)throw new Error("Requires more than one argument for calculation");return da(r.map(n=>fa(n,e.formData)).reduce((n,s,i)=>i===0?s:t(n,s),0),e)},da=(e,t)=>{const r=t.formula.round;if(!r&&r!==0||!e)return e;if(r===0)return parseInt(e,10);const n=Math.pow(10,r);return Math.round((e+Number.EPSILON)*n)/n},fa=(e,t)=>{const r=Object.keys(e);if(r.length===1){const n=r[0],s=e[n];switch(n){case"field":{const i=ha(s,t);return!i&&i!==0?NaN:parseFloat(i)}case"value":return parseFloat(s);case"formula":return as({...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")},ha=(e,t)=>I.Utils.interpolateString("${"+e+"}",t),ma=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const r=e.value.replace("field::","");return fe.getSource(t,r)}return e.value},Ke=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},Cr=(e,t,r)=>{if(e&&typeof e=="object"){const n=ma(e,r);switch(e.op){case"=":case"eq":return n===t;case"!=":case"<>":case"ne":case"neq":return n!==t;case"in":return Array.isArray(n)?n.includes(t):!1;case"nin":return Array.isArray(n)?n.includes(t)===!1:!0;case"<":{const s=Ke(t),i=Ke(n);return s!=null&&i!=null&&s<i}case">":{const s=Ke(t),i=Ke(n);return s!=null&&i!=null&&s>i}case"contains":return t?.toString().toLowerCase().includes(n);case"!contains":return!t?.toString().toLowerCase().includes(n);case"includes":return Array.isArray(t)?t.includes(n):!1;case"!includes":return Array.isArray(t)?!t.includes(n):!0;case"includesObjectProp":return Array.isArray(t)?t.some(s=>s[e.key]===n):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(s=>s[e.key]===n):!0;case"includesAllOf":return Array.isArray(t)?n.every(s=>t.includes(s)):!1;case"!includesAllOf":return Array.isArray(t)?!n.every(s=>t.includes(s)):!0;default:return!1}}return!0},pa=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const r=e.full_path;return t=Array.isArray(t)?t:[t],t.map(n=>{const s=fe.getDataPath(n.field,r);return{...n,field:s}})}},Ea=e=>Array.isArray(e)||!!(e.field&&e.op),os=e=>e&&!Ea(e)?pa(e):e,ls=(e,t,r="and")=>{const n=Array.isArray(e)?e:[e],s=i=>{if(Array.isArray(i.conditions))return ls(i.conditions,t,i.type);const a=i.field.startsWith("interpolate::")?I.Utils.interpolateString(i.field,t).replace("interpolate::",""):i.field,o=fe.getSource(t,a);return Cr(i,o,t)};return r==="and"?n.every(s):n.some(s)},we=(e,t)=>{const r=os(e);return r?ls(r,t):!0},Aa=(e,t)=>{const r=os(e);return r?(Array.isArray(r)?r:[r]).some(s=>{const i=fe.getSource(t,s.field);return Cr(s,i,t)}):!0},le={meetsOne:Aa,meetsAll:we,met:Cr},va=(e,t)=>{const r=e;return t.forEach((n,s)=>{if(n.refdata_match){const i=n.refdata_match,a=Object.keys(i)[0],o=e.findIndex(l=>l[a]===i[a]);o>=0&&(r[o]={...e[o],nested:n.nested})}n.combineWithRefdata&&!r.includes(n)&&(s>0&&typeof t[s-1]=="string"&&r.push(t[s-1]),r.push(n))}),r},ze=(e,t)=>t.map(r=>r.show_when&&!(r.show_when.type==="or"?le.meetsOne(r,e.formData):le.meetsAll(r,e.formData))?null:typeof r=="string"?r:r.value?(e.alternativeHintField&&(r.hint=r[e.alternativeHintField]),{...r,value:I.Utils.interpolateString(r.value,e.formData),label:I.Utils.interpolateString(r.label,e.formData),hint:I.Utils.interpolateString(r.hint,e.formData)}):r.label).filter(r=>r),ya=(e,t)=>{const r=e.formData[t].map(n=>({value:I.Utils.interpolateString(e.item.value,n),label:I.Utils.interpolateString(e.item.label,n),hint:I.Utils.interpolateString(e.item.hint,n)}));return e.data.options?[...r,...e.data.options]:r},us=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const r=ya(e,e?.data?.collection);return t(ze(e,r))}if(e.options&&e?.data?.options&&e?.data?.url){const r=va(e.options,e.data.options);return t(ze(e,r))}if(e.options)return t(ze(e,e.options));if(e.data&&e.data.options)return t(ze(e,e.data.options))}return t([])},Ta=6e3,Sa=(e,t)=>{const r=e===0;let n=0;return r&&(n=1),r||(n=t.substring(e-1).startsWith(" ")?2:3),n},Br=e=>e===0,cs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),Ca=(e,t)=>{let r=0;return e.synonyms.some(s=>cs(s,t))&&(r=4),r},ga=(e,t,r)=>{let n=0;return e.item.extraFieldsToSearch.some(i=>{const a=t[i];return cs(a,r)})&&(n=5),n},xa=(e,t,r,n)=>{const s=r?r(e).toLowerCase():e.label.toLowerCase()||"";let i=0;const a=s.indexOf(t);return a!==-1&&(i=Sa(a,s)),Br(i)&&e.synonyms&&(i=Ca(e,t)),Br(i)&&n.item?.extraFieldsToSearch&&(i=ga(n,e,t)),{score:i,label:s,option:e}},Ia=(e,t,r)=>(n,s)=>{const i=xa(s,e,t,r);return i.score>0&&n.push(i),n},_a=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),Pa=e=>{let t=[];us(e,n=>{t=n});const r=e?.item?I.Utils.itemLabel(e.item):null;return(n,s)=>{const i=typeof n=="string"?n.toLowerCase():"",a=t.reduce(Ia(i,r,e),[]).sort(_a).slice(0,Ta).map(o=>o.option);s(a)}},xe=".",gr="/",ds=`${xe}${xe}`,kr=`${xe}${gr}`,hr=e=>e.join(xe),mr=(e,t=xe)=>e.split(t),wa=e=>e===ds,ba=e=>[xe,ds].indexOf(e)>-1,Da=e=>e&&e.indexOf(xe)===0,Oa=e=>e.indexOf(kr)===0?e:`${kr}${e}`,La=(e,t)=>{const r=Oa(t),n=mr(r,gr).filter(wa).length+1,s=e?mr(e):[];return n>=s.length?"":hr(s.slice(0,-n))},Na=(e,t)=>{const r=mr(t,gr).filter(n=>!ba(n));return e?`${e}.${hr(r)}`:hr(r)},Ra=(e,t)=>Da(e)?Na(La(t,e),e):e,Fa=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},$a=e=>e.includes("["),Ma=e=>e.replace("]","").split("["),se=(e,t)=>{if(t)return t.split(".").reduce((r,n)=>{if(r&&$a(n)){const[s,i]=Ma(n);return Fa(r[s],i)}return r?r[n]:void 0},e)},Ua=(e,t)=>{let r=e.value||e.id,n=e.label||e.name;return t&&(r=e[t.value]||r,n=e[t.label]||n),{value:r?.toString(),label:n}},ja=(e,t)=>Array.isArray(e)?e.map(r=>typeof r=="string"?r:{...r,...Ua(r,t)}):[],Ya=(e,t)=>{const r=Object.keys(e).filter(s=>!(s in t)),n=e;r.forEach(s=>delete n[s])},fs=(e,t,r,n=!1)=>{if(t&&e){const s=n?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),i=s.pop();let a=e;s.forEach(o=>{(!a[o]||typeof a[o]!="object")&&(a[o]={}),a=a[o]}),a[i]=r}return e},hs=(e,t)=>{const r=t;e.source&&(r[e.fieldId]=se(r,e.source.field))},Ba=(e,t)=>{e.forEach(r=>hs(r,t))},ka=(e,t)=>{e.forEach(r=>{r.components.filter(n=>!n.use).forEach(n=>hs(n,t))})},qa=(e,t,r)=>{const n={...r};return Ba(t,n),ka(e,n),n},Ha=(e,t)=>({...e,components:ms(e.components,t)}),Va=(e,t)=>({...e,item:ms(e.item,t)}),ms=(e,t)=>e.map(r=>ps(r,t)),ps=(e,t)=>{if(e){if(e.type===R.CONTAINER)return Ha(e,t);if(e.type===R.COLLECTION)return Va(e,t);if(e.type===R.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:I.Utils.interpolateString(e.data.url,t)}}}return e},fe={applyFormula:as,getAutocompleteSource:Pa,getDataPath:Ra,getOptions:us,getSource:se,refData:{setupUrl:ps,toOptions:ja},deleteValues:Ya,setDataItem:fs,setupForm:qa},Ye=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(r=>r.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"?le.meetsOne(e,t):le.meetsAll(e,t),Be=(e,t)=>{let r=[];return e?.forEach(n=>{r.push(n),Ce(n,t)&&n.data?.options?.forEach(s=>{const i=t?.[n.id]||fe.getSource(t,n.full_path);Array.isArray(s.nested)&&Ye(i,s)&&Ce(s,t)&&(r=r.concat(s.nested))})}),r},qr=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],te=(e,t=[])=>{const r=Array.isArray(t)?[...qr,...t]:qr;return e&&typeof e=="object"?Object.keys(e).reduce((n,s)=>r.includes(s)?n:{...n,[s]:e[s]},{}):{}};function ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Je={exports:{}},yt,Hr;function Es(){return Hr||(Hr=1,yt=function(t,r){return function(){return t.apply(r,arguments)}}),yt}var Tt,Vr;function ie(){if(Vr)return Tt;Vr=1;var e=Es(),t=Object.prototype.toString,r=(function(p){return function(U){var Y=t.call(U);return p[Y]||(p[Y]=Y.slice(8,-1).toLowerCase())}})(Object.create(null));function n(p){return p=p.toLowerCase(),function(Y){return r(Y)===p}}function s(p){return Array.isArray(p)}function i(p){return typeof p>"u"}function a(p){return p!==null&&!i(p)&&p.constructor!==null&&!i(p.constructor)&&typeof p.constructor.isBuffer=="function"&&p.constructor.isBuffer(p)}var o=n("ArrayBuffer");function l(p){var U;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?U=ArrayBuffer.isView(p):U=p&&p.buffer&&o(p.buffer),U}function u(p){return typeof p=="string"}function d(p){return typeof p=="number"}function c(p){return p!==null&&typeof p=="object"}function f(p){if(r(p)!=="object")return!1;var U=Object.getPrototypeOf(p);return U===null||U===Object.prototype}function m(p){return p&&Object.keys(p).length===0&&Object.getPrototypeOf(p)===Object.prototype}var A=n("Date"),T=n("File"),v=n("Blob"),x=n("FileList");function $(p){return t.call(p)==="[object Function]"}function S(p){return c(p)&&$(p.pipe)}function w(p){var U="[object FormData]";return p&&(typeof FormData=="function"&&p instanceof FormData||t.call(p)===U||$(p.toString)&&p.toString()===U)}var b=n("URLSearchParams");function q(p){return p.trim?p.trim():p.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function E(){var p;return typeof navigator<"u"&&((p=navigator.product)==="ReactNative"||p==="NativeScript"||p==="NS")?!1:typeof window<"u"&&typeof document<"u"}function P(p,U){if(!(p===null||typeof p>"u"))if(typeof p!="object"&&(p=[p]),s(p))for(var Y=0,G=p.length;Y<G;Y++)U.call(null,p[Y],Y,p);else for(var V in p)Object.prototype.hasOwnProperty.call(p,V)&&U.call(null,p[V],V,p)}function L(){var p={};function U(V,K){K==="__proto__"||K==="constructor"||K==="prototype"||(f(p[K])&&f(V)?p[K]=L(p[K],V):f(V)?p[K]=L({},V):s(V)?p[K]=V.slice():p[K]=V)}for(var Y=0,G=arguments.length;Y<G;Y++)P(arguments[Y],U);return p}function M(p,U,Y){return P(U,function(V,K){Y&&typeof V=="function"?p[K]=e(V,Y):p[K]=V}),p}function C(p){return p.charCodeAt(0)===65279&&(p=p.slice(1)),p}function H(p,U,Y,G){p.prototype=Object.create(U.prototype,G),p.prototype.constructor=p,Y&&Object.assign(p.prototype,Y)}function D(p,U,Y,G){var V,K,re,me={};if(U=U||{},p==null)return U;do{for(V=Object.getOwnPropertyNames(p),K=V.length;K-- >0;)re=V[K],(!G||G(re,p,U))&&!me[re]&&(U[re]=p[re],me[re]=!0);p=Y!==!1&&Object.getPrototypeOf(p)}while(p&&(!Y||Y(p,U))&&p!==Object.prototype);return U}function y(p,U,Y){p=String(p),(Y===void 0||Y>p.length)&&(Y=p.length),Y-=U.length;var G=p.indexOf(U,Y);return G!==-1&&G===Y}function g(p){if(!p)return null;if(s(p))return p;var U=p.length;if(!d(U))return null;for(var Y=new Array(U);U-- >0;)Y[U]=p[U];return Y}var _=(function(p){return function(U){return p&&U instanceof p}})(typeof Uint8Array<"u"&&Object.getPrototypeOf(Uint8Array));function F(p,U){for(var Y=p&&p[Symbol.iterator],G=Y.call(p),V;(V=G.next())&&!V.done;){var K=V.value;U.call(p,K[0],K[1])}}function O(p,U){for(var Y,G=[];(Y=p.exec(U))!==null;)G.push(Y);return G}var j=n("HTMLFormElement"),k=(function(U){return function(Y,G){return U.call(Y,G)}})(Object.prototype.hasOwnProperty);return Tt={isArray:s,isArrayBuffer:o,isBuffer:a,isFormData:w,isArrayBufferView:l,isString:u,isNumber:d,isObject:c,isPlainObject:f,isEmptyObject:m,isUndefined:i,isDate:A,isFile:T,isBlob:v,isFunction:$,isStream:S,isURLSearchParams:b,isStandardBrowserEnv:E,forEach:P,merge:L,extend:M,trim:q,stripBOM:C,inherits:H,toFlatObject:D,kindOf:r,kindOfTest:n,endsWith:y,toArray:g,isTypedArray:_,isFileList:x,forEachEntry:F,matchAll:O,isHTMLForm:j,hasOwnProperty:k},Tt}var St,Gr;function Ie(){if(Gr)return St;Gr=1;var e=ie();function t(s,i,a,o,l){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",i&&(this.code=i),a&&(this.config=a),o&&(this.request=o),l&&(this.response=l)}e.inherits(t,Error,{toJSON:function(){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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var r=t.prototype,n={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(s){n[s]={value:s}}),Object.defineProperties(t,n),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(s,i,a,o,l,u){var d=Object.create(r);return e.toFlatObject(s,d,function(f){return f!==Error.prototype}),t.call(d,s.message,i,a,o,l),d.cause=s,d.name=s.name,u&&Object.assign(d,u),d},St=t,St}var Ct,Wr;function Ga(){return Wr||(Wr=1,Ct=typeof self=="object"?self.FormData:window.FormData),Ct}var gt,Kr;function Wa(){return Kr||(Kr=1,gt=Ga()),gt}var xt,zr;function dt(){if(zr)return xt;zr=1;var e=ie(),t=Ie(),r=Wa();function n(d){return e.isPlainObject(d)||e.isArray(d)}function s(d){return e.endsWith(d,"[]")?d.slice(0,-2):d}function i(d,c,f){return d?d.concat(c).map(function(A,T){return A=s(A),!f&&T?"["+A+"]":A}).join(f?".":""):c}function a(d){return e.isArray(d)&&!d.some(n)}var o=e.toFlatObject(e,{},null,function(c){return/^is[A-Z]/.test(c)});function l(d){return d&&e.isFunction(d.append)&&d[Symbol.toStringTag]==="FormData"&&d[Symbol.iterator]}function u(d,c,f){if(!e.isObject(d))throw new TypeError("target must be an object");c=c||new(r||FormData),f=e.toFlatObject(f,{metaTokens:!0,dots:!1,indexes:!1},!1,function(L,M){return!e.isUndefined(M[L])});var m=f.metaTokens,A=f.visitor||w,T=f.dots,v=f.indexes,x=f.Blob||typeof Blob<"u"&&Blob,$=x&&l(c);if(!e.isFunction(A))throw new TypeError("visitor must be a function");function S(P){if(P===null)return"";if(e.isDate(P))return P.toISOString();if(!$&&e.isBlob(P))throw new t("Blob is not supported. Use a Buffer instead.");return e.isArrayBuffer(P)||e.isTypedArray(P)?$&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function w(P,L,M){var C=P;if(P&&!M&&typeof P=="object"){if(e.endsWith(L,"{}"))L=m?L:L.slice(0,-2),P=JSON.stringify(P);else if(e.isArray(P)&&a(P)||e.isFileList(P)||e.endsWith(L,"[]")&&(C=e.toArray(P)))return L=s(L),C.forEach(function(D,y){!(e.isUndefined(D)||D===null)&&c.append(v===!0?i([L],y,T):v===null?L:L+"[]",S(D))}),!1}return n(P)?!0:(c.append(i(M,L,T),S(P)),!1)}var b=[],q=Object.assign(o,{defaultVisitor:w,convertValue:S,isVisitable:n});function E(P,L){if(!e.isUndefined(P)){if(b.indexOf(P)!==-1)throw Error("Circular reference detected in "+L.join("."));b.push(P),e.forEach(P,function(C,H){var D=!(e.isUndefined(C)||C===null)&&A.call(c,C,e.isString(H)?H.trim():H,L,q);D===!0&&E(C,L?L.concat(H):[H])}),b.pop()}}if(!e.isObject(d))throw new TypeError("data must be an object");return E(d),c}return xt=u,xt}var It,Jr;function As(){if(Jr)return It;Jr=1;var e=dt();function t(s){var i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'\(\)~]|%20|%00/g,function(o){return i[o]})}function r(s,i){this._pairs=[],s&&e(s,this,i)}var n=r.prototype;return n.append=function(i,a){this._pairs.push([i,a])},n.toString=function(i){var a=i?function(o){return i.call(this,o,t)}:t;return this._pairs.map(function(l){return a(l[0])+"="+a(l[1])},"").join("&")},It=r,It}var _t,Xr;function vs(){if(Xr)return _t;Xr=1;var e=ie(),t=As();function r(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}return _t=function(s,i,a){if(!i)return s;var o=s.indexOf("#");o!==-1&&(s=s.slice(0,o));var l=a&&a.encode||r,u=a&&a.serialize,d;return u?d=u(i,a):d=e.isURLSearchParams(i)?i.toString():new t(i,a).toString(l),d&&(s+=(s.indexOf("?")===-1?"?":"&")+d),s},_t}var Pt,Qr;function Ka(){if(Qr)return Pt;Qr=1;var e=ie();function t(){this.handlers=[]}return t.prototype.use=function(n,s,i){return this.handlers.push({fulfilled:n,rejected:s,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1},t.prototype.eject=function(n){this.handlers[n]&&(this.handlers[n]=null)},t.prototype.clear=function(){this.handlers&&(this.handlers=[])},t.prototype.forEach=function(n){e.forEach(this.handlers,function(i){i!==null&&n(i)})},Pt=t,Pt}var wt,Zr;function ys(){if(Zr)return wt;Zr=1;var e=ie();return wt=function(r,n){e.forEach(r,function(i,a){a!==n&&a.toUpperCase()===n.toUpperCase()&&(r[n]=i,delete r[a])})},wt}var bt,en;function Ts(){return en||(en=1,bt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}),bt}var Dt,tn;function za(){if(tn)return Dt;tn=1;var e=As();return Dt=typeof URLSearchParams<"u"?URLSearchParams:e,Dt}var Ot,rn;function Ja(){return rn||(rn=1,Ot=FormData),Ot}var Lt,nn;function Xa(){return nn||(nn=1,Lt={isBrowser:!0,classes:{URLSearchParams:za(),FormData:Ja(),Blob},protocols:["http","https","file","blob","url","data"]}),Lt}var Nt,sn;function xr(){return sn||(sn=1,Nt=Xa()),Nt}var Rt,an;function Qa(){if(an)return Rt;an=1;var e=ie(),t=dt(),r=xr();return Rt=function(s,i){return t(s,new r.classes.URLSearchParams,Object.assign({visitor:function(a,o,l,u){return r.isNode&&e.isBuffer(a)?(this.append(o,a.toString("base64")),!1):u.defaultVisitor.apply(this,arguments)}},i))},Rt}var Ft,on;function Ss(){if(on)return Ft;on=1;var e=ie();function t(s){return e.matchAll(/\w+|\[(\w*)]/g,s).map(function(i){return i[0]==="[]"?"":i[1]||i[0]})}function r(s){var i={},a=Object.keys(s),o,l=a.length,u;for(o=0;o<l;o++)u=a[o],i[u]=s[u];return i}function n(s){function i(o,l,u,d){var c=o[d++];if(c==="__proto__")return!0;var f=Number.isFinite(+c),m=d>=o.length;if(c=!c&&e.isArray(u)?u.length:c,m)return e.hasOwnProperty(u,c)?u[c]=[u[c],l]:u[c]=l,!f;(!u[c]||!e.isObject(u[c]))&&(u[c]=[]);var A=i(o,l,u[c],d);return A&&e.isArray(u[c])&&(u[c]=r(u[c])),!f}if(e.isFormData(s)&&e.isFunction(s.entries)){var a={};return e.forEachEntry(s,function(o,l){i(t(o),l,a,0)}),a}return null}return Ft=n,Ft}var $t,ln;function Za(){if(ln)return $t;ln=1;var e=Ie();return $t=function(r,n,s){var i=s.config.validateStatus;!s.status||!i||i(s.status)?r(s):n(new e("Request failed with status code "+s.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))},$t}var Mt,un;function eo(){if(un)return Mt;un=1;var e=ie();return Mt=e.isStandardBrowserEnv()?(function(){return{write:function(n,s,i,a,o,l){var u=[];u.push(n+"="+encodeURIComponent(s)),e.isNumber(i)&&u.push("expires="+new Date(i).toGMTString()),e.isString(a)&&u.push("path="+a),e.isString(o)&&u.push("domain="+o),l===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(n){var s=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return s?decodeURIComponent(s[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}})():(function(){return{write:function(){},read:function(){return null},remove:function(){}}})(),Mt}var Ut,cn;function to(){return cn||(cn=1,Ut=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}),Ut}var jt,dn;function ro(){return dn||(dn=1,jt=function(t,r){return r?t.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):t}),jt}var Yt,fn;function Cs(){if(fn)return Yt;fn=1;var e=to(),t=ro();return Yt=function(n,s,i){var a=!e(s);return n&&(a||i===!1)?t(n,s):s},Yt}var Bt,hn;function no(){if(hn)return Bt;hn=1;var e=ie(),t=["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"];return Bt=function(n){var s={},i,a,o;return n&&e.forEach(n.split(`
2
- `),function(u){if(o=u.indexOf(":"),i=e.trim(u.slice(0,o)).toLowerCase(),a=e.trim(u.slice(o+1)),i){if(s[i]&&t.indexOf(i)>=0)return;i==="set-cookie"?s[i]=(s[i]?s[i]:[]).concat([a]):s[i]=s[i]?s[i]+", "+a:a}}),s},Bt}var kt,mn;function so(){if(mn)return kt;mn=1;var e=ie();return kt=e.isStandardBrowserEnv()?(function(){var r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),s;function i(a){var o=a;return r&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return s=i(window.location.href),function(o){var l=e.isString(o)?i(o):o;return l.protocol===s.protocol&&l.host===s.host}})():(function(){return function(){return!0}})(),kt}var qt,pn;function ft(){if(pn)return qt;pn=1;var e=Ie(),t=ie();function r(n,s,i){e.call(this,n??"canceled",e.ERR_CANCELED,s,i),this.name="CanceledError"}return t.inherits(r,e,{__CANCEL__:!0}),qt=r,qt}var Ht,En;function io(){return En||(En=1,Ht=function(t){var r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return r&&r[1]||""}),Ht}var Vt,An;function vn(){if(An)return Vt;An=1;var e=ie(),t=Za(),r=eo(),n=vs(),s=Cs(),i=no(),a=so(),o=Ts(),l=Ie(),u=ft(),d=io(),c=xr();return Vt=function(m){return new Promise(function(T,v){var x=m.data,$=m.headers,S=m.responseType,w=m.withXSRFToken,b;function q(){m.cancelToken&&m.cancelToken.unsubscribe(b),m.signal&&m.signal.removeEventListener("abort",b)}e.isFormData(x)&&e.isStandardBrowserEnv()&&delete $["Content-Type"];var E=new XMLHttpRequest;if(m.auth){var P=m.auth.username||"",L=m.auth.password?unescape(encodeURIComponent(m.auth.password)):"";$.Authorization="Basic "+btoa(P+":"+L)}var M=s(m.baseURL,m.url,m.allowAbsoluteUrls);E.open(m.method.toUpperCase(),n(M,m.params,m.paramsSerializer),!0),E.timeout=m.timeout;function C(){if(E){var y="getAllResponseHeaders"in E?i(E.getAllResponseHeaders()):null,g=!S||S==="text"||S==="json"?E.responseText:E.response,_={data:g,status:E.status,statusText:E.statusText,headers:y,config:m,request:E};t(function(O){T(O),q()},function(O){v(O),q()},_),E=null}}if("onloadend"in E?E.onloadend=C:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(C)},E.onabort=function(){E&&(v(new l("Request aborted",l.ECONNABORTED,m,E)),E=null)},E.onerror=function(){v(new l("Network Error",l.ERR_NETWORK,m,E)),E=null},E.ontimeout=function(){var g=m.timeout?"timeout of "+m.timeout+"ms exceeded":"timeout exceeded",_=m.transitional||o;m.timeoutErrorMessage&&(g=m.timeoutErrorMessage),v(new l(g,_.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,m,E)),E=null},e.isStandardBrowserEnv()&&(w&&e.isFunction(w)&&(w=w(m)),w||w!==!1&&a(M))){var H=m.xsrfHeaderName&&m.xsrfCookieName&&r.read(m.xsrfCookieName);H&&($[m.xsrfHeaderName]=H)}"setRequestHeader"in E&&e.forEach($,function(g,_){typeof x>"u"&&_.toLowerCase()==="content-type"?delete $[_]:E.setRequestHeader(_,g)}),e.isUndefined(m.withCredentials)||(E.withCredentials=!!m.withCredentials),S&&S!=="json"&&(E.responseType=m.responseType),typeof m.onDownloadProgress=="function"&&E.addEventListener("progress",m.onDownloadProgress),typeof m.onUploadProgress=="function"&&E.upload&&E.upload.addEventListener("progress",m.onUploadProgress),(m.cancelToken||m.signal)&&(b=function(y){E&&(v(!y||y.type?new u(null,m,E):y),E.abort(),E=null)},m.cancelToken&&m.cancelToken.subscribe(b),m.signal&&(m.signal.aborted?b():m.signal.addEventListener("abort",b))),!x&&x!==!1&&x!==0&&x!==""&&(x=null);var D=d(M);if(D&&c.protocols.indexOf(D)===-1){v(new l("Unsupported protocol "+D+":",l.ERR_BAD_REQUEST,m));return}E.send(x)})},Vt}var Gt,yn;function Ir(){if(yn)return Gt;yn=1;var e=ie(),t=ys(),r=Ie(),n=Ts(),s=dt(),i=Qa(),a=xr(),o=Ss(),l={"Content-Type":"application/x-www-form-urlencoded"};function u(m,A){!e.isUndefined(m)&&e.isUndefined(m["Content-Type"])&&(m["Content-Type"]=A)}function d(){var m;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(m=vn()),m}function c(m,A,T){if(e.isString(m))try{return(A||JSON.parse)(m),e.trim(m)}catch(v){if(v.name!=="SyntaxError")throw v}return(T||JSON.stringify)(m)}var f={transitional:n,adapter:d(),transformRequest:[function(A,T){t(T,"Accept"),t(T,"Content-Type");var v=T&&T["Content-Type"]||"",x=v.indexOf("application/json")>-1,$=e.isObject(A);$&&e.isHTMLForm(A)&&(A=new FormData(A));var S=e.isFormData(A);if(S)return x?JSON.stringify(o(A)):A;if(e.isArrayBuffer(A)||e.isBuffer(A)||e.isStream(A)||e.isFile(A)||e.isBlob(A))return A;if(e.isArrayBufferView(A))return A.buffer;if(e.isURLSearchParams(A))return u(T,"application/x-www-form-urlencoded;charset=utf-8"),A.toString();var w;if($){if(v.indexOf("application/x-www-form-urlencoded")!==-1)return i(A,this.formSerializer).toString();if((w=e.isFileList(A))||v.indexOf("multipart/form-data")>-1){var b=this.env&&this.env.FormData;return s(w?{"files[]":A}:A,b&&new b,this.formSerializer)}}return $||x?(u(T,"application/json"),c(A)):A}],transformResponse:[function(A){var T=this.transitional||f.transitional,v=T&&T.forcedJSONParsing,x=this.responseType==="json";if(A&&e.isString(A)&&(v&&!this.responseType||x)){var $=T&&T.silentJSONParsing,S=!$&&x;try{return JSON.parse(A)}catch(w){if(S)throw w.name==="SyntaxError"?r.from(w,r.ERR_BAD_RESPONSE,this,null,this.response):w}}return A}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:a.classes.FormData,Blob:a.classes.Blob},validateStatus:function(A){return A>=200&&A<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return e.forEach(["delete","get","head"],function(A){f.headers[A]={}}),e.forEach(["post","put","patch"],function(A){f.headers[A]=e.merge(l)}),Gt=f,Gt}var Wt,Tn;function ao(){if(Tn)return Wt;Tn=1;var e=ie(),t=Ir();return Wt=function(n,s,i,a){var o=this||t;return e.forEach(a,function(u){n=u.call(o,n,s,i)}),n},Wt}var Kt,Sn;function gs(){return Sn||(Sn=1,Kt=function(t){return!!(t&&t.__CANCEL__)}),Kt}var zt,Cn;function oo(){if(Cn)return zt;Cn=1;var e=ie(),t=ao(),r=gs(),n=Ir(),s=ft(),i=ys();function a(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new s}return zt=function(l){a(l),l.headers=l.headers||{},l.data=t.call(l,l.data,l.headers,null,l.transformRequest),i(l.headers,"Accept"),i(l.headers,"Content-Type"),l.headers=e.merge(l.headers.common||{},l.headers[l.method]||{},l.headers),e.forEach(["delete","get","head","post","put","patch","common"],function(c){delete l.headers[c]});var u=l.adapter||n.adapter;return u(l).then(function(c){return a(l),c.data=t.call(l,c.data,c.headers,c.status,l.transformResponse),c},function(c){return r(c)||(a(l),c&&c.response&&(c.response.data=t.call(l,c.response.data,c.response.headers,c.response.status,l.transformResponse))),Promise.reject(c)})},zt}var Jt,gn;function xs(){if(gn)return Jt;gn=1;var e=ie();return Jt=function(r,n){n=n||{};var s={};function i(c,f){return e.isPlainObject(c)&&e.isPlainObject(f)?e.merge(c,f):e.isEmptyObject(f)?e.merge({},c):e.isPlainObject(f)?e.merge({},f):e.isArray(f)?f.slice():f}function a(c){if(e.isUndefined(n[c])){if(!e.isUndefined(r[c]))return i(void 0,r[c])}else return i(r[c],n[c])}function o(c){if(!e.isUndefined(n[c]))return i(void 0,n[c])}function l(c){if(e.isUndefined(n[c])){if(!e.isUndefined(r[c]))return i(void 0,r[c])}else return i(void 0,n[c])}function u(c){if(c in n)return i(r[c],n[c]);if(c in r)return i(void 0,r[c])}var d={url:o,method:o,data:o,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:u};return e.forEach(Object.keys(r).concat(Object.keys(n)),function(f){if(!(f==="__proto__"||f==="constructor"||f==="prototype")){var m=e.hasOwnProperty(d,f)?d[f]:a,A=m(f);e.isUndefined(A)&&m!==u||(s[f]=A)}}),s},Jt}var Xt,xn;function Is(){return xn||(xn=1,Xt={version:"0.30.3"}),Xt}var Qt,In;function lo(){if(In)return Qt;In=1;var e=Is().version,t=Ie(),r={};["object","boolean","number","function","string","symbol"].forEach(function(i,a){r[i]=function(l){return typeof l===i||"a"+(a<1?"n ":" ")+i}});var n={};r.transitional=function(a,o,l){function u(d,c){return"[Axios v"+e+"] Transitional option '"+d+"'"+c+(l?". "+l:"")}return function(d,c,f){if(a===!1)throw new t(u(c," has been removed"+(o?" in "+o:"")),t.ERR_DEPRECATED);return o&&!n[c]&&(n[c]=!0,console.warn(u(c," has been deprecated since v"+o+" and will be removed in the near future"))),a?a(d,c,f):!0}};function s(i,a,o){if(typeof i!="object")throw new t("options must be an object",t.ERR_BAD_OPTION_VALUE);for(var l=Object.keys(i),u=l.length;u-- >0;){var d=l[u],c=a[d];if(c){var f=i[d],m=f===void 0||c(f,d,i);if(m!==!0)throw new t("option "+d+" must be "+m,t.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new t("Unknown option "+d,t.ERR_BAD_OPTION)}}return Qt={assertOptions:s,validators:r},Qt}var Zt,_n;function uo(){if(_n)return Zt;_n=1;var e=ie(),t=vs(),r=Ka(),n=oo(),s=xs(),i=Cs(),a=lo(),o=a.validators;function l(u){this.defaults=u,this.interceptors={request:new r,response:new r}}return l.prototype.request=function(d,c){typeof d=="string"?(c=c||{},c.url=d):c=d||{},c=s(this.defaults,c),c.method?c.method=c.method.toLowerCase():this.defaults.method?c.method=this.defaults.method.toLowerCase():c.method="get";var f=c.transitional;f!==void 0&&a.assertOptions(f,{silentJSONParsing:o.transitional(o.boolean),forcedJSONParsing:o.transitional(o.boolean),clarifyTimeoutError:o.transitional(o.boolean)},!1);var m=c.paramsSerializer;m!=null&&(e.isFunction(m)?c.paramsSerializer={serialize:m}:a.assertOptions(m,{encode:o.function,serialize:o.function},!0));var A=[],T=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(c)===!1||(T=T&&E.synchronous,A.unshift(E.fulfilled,E.rejected))});var v=[];this.interceptors.response.forEach(function(E){v.push(E.fulfilled,E.rejected)});var x;if(!T){var $=[n,void 0];for(Array.prototype.unshift.apply($,A),$=$.concat(v),x=Promise.resolve(c);$.length;)x=x.then($.shift(),$.shift());return x}for(var S=c;A.length;){var w=A.shift(),b=A.shift();try{S=w(S)}catch(q){b(q);break}}try{x=n(S)}catch(q){return Promise.reject(q)}for(;v.length;)x=x.then(v.shift(),v.shift());return x},l.prototype.getUri=function(d){d=s(this.defaults,d);var c=i(d.baseURL,d.url,d.allowAbsoluteUrls);return t(c,d.params,d.paramsSerializer)},e.forEach(["delete","get","head","options"],function(d){l.prototype[d]=function(c,f){return this.request(s(f||{},{method:d,url:c,data:(f||{}).data}))}}),e.forEach(["post","put","patch"],function(d){function c(f){return function(A,T,v){return this.request(s(v||{},{method:d,headers:f?{"Content-Type":"multipart/form-data"}:{},url:A,data:T}))}}l.prototype[d]=c(),l.prototype[d+"Form"]=c(!0)}),Zt=l,Zt}var er,Pn;function co(){if(Pn)return er;Pn=1;var e=ft();function t(r){if(typeof r!="function")throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(a){n=a});var s=this;this.promise.then(function(i){if(s._listeners){for(var a=s._listeners.length;a-- >0;)s._listeners[a](i);s._listeners=null}}),this.promise.then=function(i){var a,o=new Promise(function(l){s.subscribe(l),a=l}).then(i);return o.cancel=function(){s.unsubscribe(a)},o},r(function(a,o,l){s.reason||(s.reason=new e(a,o,l),n(s.reason))})}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},t.prototype.unsubscribe=function(n){if(this._listeners){var s=this._listeners.indexOf(n);s!==-1&&this._listeners.splice(s,1)}},t.source=function(){var n,s=new t(function(a){n=a});return{token:s,cancel:n}},er=t,er}var tr,wn;function fo(){return wn||(wn=1,tr=function(t){return function(n){return t.apply(null,n)}}),tr}var rr,bn;function ho(){if(bn)return rr;bn=1;var e=ie();return rr=function(r){return e.isObject(r)&&r.isAxiosError===!0},rr}var Dn;function mo(){if(Dn)return Je.exports;Dn=1;var e=ie(),t=Es(),r=uo(),n=xs(),s=Ir(),i=Ss();function a(l){var u=new r(l),d=t(r.prototype.request,u);return e.extend(d,r.prototype,u),e.extend(d,u),d.create=function(f){return a(n(l,f))},d}var o=a(s);return o.Axios=r,o.CanceledError=ft(),o.CancelToken=co(),o.isCancel=gs(),o.VERSION=Is().version,o.toFormData=dt(),o.AxiosError=Ie(),o.Cancel=o.CanceledError,o.all=function(u){return Promise.all(u)},o.spread=fo(),o.isAxiosError=ho(),o.formToJSON=function(l){return i(e.isHTMLForm(l)?new FormData(l):l)},Je.exports=o,Je.exports.default=o,Je.exports}var nr,On;function po(){return On||(On=1,nr=mo()),nr}var Eo=po();const _s=ke(Eo),ce={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,r)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,r,n)=>{typeof r=="function"&&r()},onValidate:(e,t)=>t,onCancel:e=>{}},Ln=Object.keys(ce),Ps=B.createContext(),ws=({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[r,n]=B.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}),s=(a,o)=>{Ln.includes(a)&&n(l=>({...l,[a]:o||ce[a]}))},i=a=>{Ln.includes(a)&&n(o=>({...o,[a]:ce[a]}))};return h.jsx(Ps.Provider,{value:{hooks:r,addHook:s,removeHook:i},children:t})},ge=()=>B.useContext(Ps),Ao=()=>{const{hooks:e}=ge(),[t,r]=B.useState({});return B.useEffect(()=>{const n=_s.create({baseURL:"/"});return n.interceptors.request.use(e.onRequest),n.interceptors.response.use(s=>s,async s=>Promise.reject(s)),r({instance:n}),()=>{r({})}},[e]),t.instance},_r=B.createContext(),bs=({children:e=null})=>{const{hooks:t}=ge(),[r,n]=B.useState([]),[s,i]=B.useState([]),a=f=>{i(m=>[...m,...f].filter(A=>!!A))},o=f=>{typeof f=="function"&&i(m=>m.filter(A=>!f(A)))},l=()=>{s.length&&i([])},u=f=>{n(m=>[...m,...f].filter(A=>!!A))},d=()=>{i([]),n([])},c={page:f=>{const m=N.Validate.page(f,s),A=t.onValidate(f,m);return n(A),A},pages:f=>{const m=f.map(T=>N.Validate.page(T,s)),A=f.flatMap((T,v)=>t.onValidate(T,m[v]));return n(A),A}};return h.jsx(_r.Provider,{value:{errors:r,addErrors:u,clearErrors:d,queuedErrors:s,enqueueErrors:a,dequeueErrors:o,clearQueuedErrors:l,validate:c},children:e})},Oe=()=>B.useContext(_r),sr={},ir={},vo="idle",yo="fetching",Ds="fetched",Os="error",To=(e,t=!0)=>{const r=Ao(),n=B.useRef(_s.CancelToken.source()),[s,i]=B.useState(vo),[a,o]=B.useState(null),[l,u]=B.useState(null),d=()=>{n.current&&n.current.cancel()};return B.useEffect(()=>{if(!e||!r)return;(async()=>{try{o(null),i(yo);let f;if(t&&sr[e])f=sr[e];else{if(t&&ir[e])throw ir[e];f=(await r.get(e,{cancelToken:n.current.token}).catch(A=>{throw o(A),A})).data,t&&(sr[e]=f)}u(f),i(Ds)}catch(f){t&&(ir[e]=f),o(f),u(null),i(Os)}})()},[r,e,t]),{status:s,error:a,data:l,cancelRequests:d}},So="loading",et="complete",Co=e=>{const t=e.data;if(t&&!t.options||t?.url)return I.Utils.interpolateString(t.url,e.formData)},go=(e,t)=>{const r=Co({...e,formData:t}),{status:n,data:s}=To(r,e?.data?.useCache),[i,a]=B.useState([]),[o,l]=B.useState(So);return B.useEffect(()=>{r?n===Ds?(s&&a(fe.refData.toOptions(s.data||s,e.item)),l(et)):n===Os&&(a([]),l(et)):(e.data&&e.data.options&&a(fe.refData.toOptions(e.data.options,e.item)),l(et))},[e.id,n,s,r]),{data:i,status:o}},Ue=(e,t)=>{const r=te(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return h.jsx(I.FormGroup,{...r,onChange:null,children:t})},Pr=(e,t,r,n,s={})=>{if(!t)return[];const i=N.CollectionPage.getData(t.collection.name,t.formData)||[];let a=[];return i.forEach(o=>{s={...s,[`${t.collection.name.split(".").pop()}ActiveId`]:o.id};const l=t.childPages?.flatMap(u=>{const d={...u,formData:{...r,...s}};if(u.childPages)return Pr(e,d,r,n,s);const c=N.Validate.page(d);return n.onValidate(d,c)});a=a.concat(l.map(u=>({...u,entryId:o.id,showFor:e.id,raisedBy:e.id})))}),a},wr=({value:e,component:t,formData:r,placeholder:n})=>e?t?h.jsx(Le,{component:{...t,readonly:!0},wrap:!1,value:e,formData:r}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:n)||h.jsx(I.VisuallyHidden,{children:"No answer"}),xo="Continue",pr=({action:e,onAction:t,...r})=>{const n=typeof e=="string"?X.DEFAULTS[e]:e,s=X.DEFAULTS[e.type];return n?h.jsx(I.Button,{...r,className:n.className,classModifiers:n.classModifiers,start:n.start||!1,name:n.label,onClick:n.disabled?()=>{}:()=>t(n),children:n.label||s?.label||xo}):null},Io="hods-form-confirmation",_o="Are you sure?",Po="Confirm",wo=({id:e,message:t,confirmLabel:r,children:n,onConfirm:s,onCancel:i,classModifiers:a=[]})=>{const o=I.Utils.classBuilder(Io,a,"");return h.jsxs("div",{id:e,className:o(),role:"alert",children:[h.jsx("h2",{children:t||_o}),n,h.jsx(I.Button,{classModifiers:"warning",onClick:s,autoFocus:!0,children:r||Po}),h.jsx(I.Button,{classModifiers:"secondary",onClick:i,children:"Cancel"})]})},br=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===R.CONTAINER?br(t):qe.editable(t)?t:null).filter(t=>!!t):[],bo=e=>{const t=e.full_path||e.fieldId;return e.components.map(r=>{const n=t?`${t}.${r.fieldId}`:r.fieldId,s={...r,full_path:n};return r.type===R.CONTAINER?Er(s):(r.type===R.RADIOS&&s.data?.options?.forEach((i,a)=>{i.nested?.forEach((o,l)=>{o.type===R.CONTAINER&&(s.data.options[a].nested[l]=Er(o))})}),s)})},Er=e=>{if(e){const t=bo(e);return{...e,components:t}}return e},Do=(e,t)=>e.some(r=>qe.show(r,t)),Oo=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const r=br(e);return r.length>0?Do(r,t):!0},ht={editableComponents:br,setup:Er,show:Oo},Lo=(e,t)=>e.some(r=>Ce(r,t)),mt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const r=ht.editableComponents(e);return r.length>0?Lo(r,t):!0},No=(e,t,r)=>{if(!e)return null;const n=[];e.childPages.forEach(o=>{!o.summaryQuickEdit||!mt(o,{...t,...r})||o.summaryQuickEdit.forEach(l=>{if(typeof l=="string"){n.push({...o.components.find(c=>c.id===l)});return}const u=o.components.find(c=>c.id===l.use);if(!u)return;const d={...u,...l};if(l.show_when){we(l.show_when,{...t,...r})&&n.push({...d,show_when:u.show_when||[]});return}n.push(d)})});const s={...e.childPages[0],formData:t};s.components=n,s.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:i,...a}=r;return s.formData={...s.formData,...a,[`${e.collection?.name?.split(".").pop()}ActiveId`]:r.id},delete s.title,delete s.collection,s},Dr=({actions:e,onAction:t})=>!e||e.length===0?null:h.jsx(I.ButtonGroup,{children:e.map((r,n)=>h.jsx(pr,{action:r,onAction:t},n))}),Ro=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(r=>r.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?le.meetsOne(t.runWhen?.constraint,e.formData):!1},Ls="hods-form__page",Or=({page:e,pages:t=[],onAction:r,onWrapperChange:n=void 0,onTopLevelChange:s=void 0,onChange:i=void 0,hashLink:a=!1,classBlock:o=Ls,classModifiers:l=[],className:u="",submitting:d=!1,pageId:c})=>{const[f,m]=B.useState({}),{errors:A,validate:T}=Oe(),[v,x]=B.useState({}),[$,S]=B.useState(!1),w=B.useMemo(()=>Ro(e),[e]);B.useEffect(()=>{S(!0)},[]),B.useEffect(()=>{$&&w&&T.page(e)},[c,$]);const b=({target:C})=>{const H=e,{value:D}=C;D?(H.formData[C.name]=D,m(y=>({...y,[C.name]:D})),x(y=>({...y,[C.component]:C.label}))):(delete H.formData[C.name],m(y=>{const{[C.name]:g,..._}=y;return _}),x(y=>{const{[C.component]:g,..._}=y;return _})),typeof i=="function"&&i(e.formData)};B.useEffect(()=>{const C=document.title.replace("Error: ","");document.title=A.length>0?"Error: "+C:C},[A]);const q=N.classBuilder(o,l,u),E=e;E.actions=E.actions?.map(C=>C.label?{...C,label:N.interpolateString(C.label,E.formData)}:C),E.formData=N.Operate.runPageOperations(E,{...E.formData,...f},n||b);const P=e.title?h.jsx(I.Heading,{size:e.titleSize,children:N.FormPage.getTitle(e.title,e.formData)}):h.jsx(I.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),L=e.components.filter(C=>N.Component.show(C,e.formData)).map((C,H)=>h.jsx(Le,{component:C,onAction:D=>r(D,f,v),onChange:n||b,onTopLevelChange:s||b,value:e.formData[C.fieldId]||f[C.fieldId],formData:e.formData,pages:t,submitting:d},H));let M=null;return w&&A?.length>0?M=[{error:e?.customValidation?.[0]?.message}]:A?.length>0&&!w&&(M=A),h.jsxs("div",{className:q(),children:[M&&h.jsx(I.ErrorSummary,{errors:M,hashLink:a}),e.fieldset&&h.jsxs("fieldset",{className:"govuk-fieldset",children:[h.jsx("legend",{className:"govuk-fieldset__legend",children:P}),L]}),!e.fieldset&&h.jsxs(h.Fragment,{children:[P,L]}),h.jsx(Dr,{actions:e.actions?.filter(C=>N.Component.show(C,e.formData)),onAction:C=>r(C,f,v)})]},e.id)},Nn="hods-form-banner-strip",Ns=({id:e,banners:t=[],formData:r,classModifiers:n})=>{const s=N.classBuilder(Nn,n,""),i=t.filter(a=>N.Component.show(a,r));return h.jsx("div",{id:e,className:s(),children:i.map((a,o)=>{const l=`${e}-banner-${o}`;if(typeof a=="string"||a.type==="plain"){const u=typeof a=="string"?a:a.text;return h.jsx("div",{id:l,className:s("banner"),children:h.jsx(I.Markup,{content:N.interpolateString(u,r)})},l)}return h.jsx(I.Tag,{classBlock:`${Nn}__tag`,classModifiers:a.classModifiers,text:N.interpolateString(a.text,r)},l)})})},Fo=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{}},Lr=({row:e})=>{const[t,r]=B.useState({});return B.useEffect(()=>{r(Fo(e))},[e,r]),e.action?h.jsxs(I.Link,{...t,children:[e.action.label,e.action.aria_suffix&&h.jsxs(I.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},Rs=({row:e,classes:t,showAction:r=!1})=>h.jsxs("dl",{className:t("row"),role:"listitem",children:[h.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),h.jsx("dd",{className:t("value"),children:e.value}),r&&h.jsx("dd",{className:t("actions"),children:e.action&&h.jsx(Lr,{row:e})})]}),Fs=({title:e,classes:t})=>h.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:h.jsx(I.SmallHeading,{children:e})}),tt=(e,t,r,n,s)=>{const i={...e,formData:{...e.formData,...n}},a=At(i,t);return t.type==="title"?h.jsx(Fs,{title:t.key,classes:r}):h.jsx(Rs,{row:{key:a.key,value:h.jsx(wr,{value:a.value||t.value,component:a.component,formData:i.formData,placeholder:s}),required:a.required},classes:r},`${a.fieldId}`)},$o="govuk-summary-card",Mo="govuk-summary-list",Xe="Item",Qe="Change",Rn="Delete",Uo="warning",jo=({id:e,entryData:t,config:r,onFullEdit:n,onDelete:s,masterPage:i,classModifiers:a=null,optionalFieldPlaceholder:o=null})=>{const l=I.Utils.classBuilder($o,a,r.className),u=I.Utils.classBuilder(Mo,[]);return h.jsxs("div",{className:l(),id:e,children:[h.jsxs("div",{className:l("title-wrapper",[],"dark"),children:[h.jsxs("div",{className:l("title-content"),children:[h.jsx("h2",{className:l("title"),children:I.Utils.interpolateString(r.title||Xe,{...t,index:t.index+1})}),r.banners&&h.jsx(Ns,{id:`BannerStrip${t.id}`,banners:r.banners,formData:t})]}),h.jsxs("ul",{className:l("actions"),children:[h.jsx("li",{className:l("action"),children:r.changeAction&&typeof n=="function"&&r.changeAction.classModifiers?h.jsx(I.Button,{id:`${e}.changeButton`,onClick:()=>n(r.changeAction.page,t.id),classModifiers:r.changeAction.classModifiers,"aria-label":I.Utils.interpolateString(`${r.changeAction?.label||Qe} ${r.title||Xe}`,{...t,index:t.index+1}),children:r.changeAction?.label||Qe}):h.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>n(r.changeAction.page,t.id),"aria-label":I.Utils.interpolateString(`${r.changeAction?.label||Qe} ${r.title||Xe}`,{...t,index:t.index+1}),children:r.changeAction?.label||Qe})}),h.jsx("li",{className:l("action"),children:r.deleteAction&&typeof s=="function"&&h.jsx(I.Button,{id:`${e}.deleteButton`,onClick:()=>s(t),classModifiers:r.deleteAction.classModifiers||Uo,"aria-label":I.Utils.interpolateString(`${r.deleteAction?.label||Rn} ${r.title||Xe}`,{...t,index:t.index+1}),children:r.deleteAction.label||Rn})})]})]}),h.jsx("div",{className:l("content"),children:h.jsx("dl",{className:u(),role:"list",children:i?.childPages?.flatMap(d=>{const c=d.components.map(f=>N.Component.elevateNested([f],t)).flat().filter(Boolean);return d.summaryLayout?.sections?.flatMap(f=>{const A=f.columns.filter(T=>le.meetsAll(T,{...d.formData,...t})).flatMap(T=>T.fields||[]);return A.length?A.flatMap(T=>{const v=c.find(x=>x.fieldId===T);return v?tt(d,v,u,t,o):null}):null})})})})]})},Yo=({id:e,"data-testid":t,actions:r,onFullEdit:n=null,entryData:s,formData:i,name:a,autoFocus:o})=>Array.isArray(r)?h.jsx(h.Fragment,{children:r.filter(l=>N.Component.show(l,i)).map(l=>h.jsx(I.Button,{id:e,"data-testid":t,onClick:()=>n(l?.page,s.id),classModifiers:l?.classModifiers||$n,"aria-label":N.FormPage.getConditionalText(l?.aria_label,s),name:a,autoFocus:o,children:l?.label||Fn},e))}):h.jsx(I.Button,{id:e,"data-testid":t,onClick:()=>n(r?.page,s.id),classModifiers:r?.classModifiers||$n,"aria-label":N.FormPage.getConditionalText(r?.aria_label,s),name:a,autoFocus:o,children:r?.label||Fn}),Bo=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},pt=(e,t,r)=>{const n=t?.cya_link;return e!==!0&&n?{page:Bo(n)||t.id||"#",label:n.label||"Change",aria_suffix:n.aria_suffix,onAction:r}:null},$s=[R.ALERT,R.COLLECTION_SUMMARY,R.DETAILS,R.HEADING,R.HTML,R.INSET_TEXT],at=(e,t)=>{if(!e||$s.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===R.COLLECTION){if(!se(t,e.full_path||e.fieldId)?.length)return!1}else{const r=se(t,e.fieldId);if(!r&&r!==!1&&r!==0)return!1}return e.type===R.CONTAINER?ht.show(e,t):qe.show(e,t)},Ms=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(r=>$s.includes(r.type)?null:{...r,...!r.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${r.fieldId}`}}).filter(r=>!!r)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),ko=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:pt(!1,e,t)}],qo=(e,t,r,n)=>({id:t.id,fieldId:t.id,type:R.CONTAINER,required:e.required,full_path:n,components:e.item.map(s=>({...s,label:I.Utils.interpolateString(s.label,{...t,index:r}),full_path:`${n}.${s.fieldId}`}))}),Ho=(e,t,r,n,s)=>{const i={...De,...e.labels};return i.item?{pageId:r,fieldId:e.fieldId,full_path:s,key:I.Utils.interpolateString(i.item,{...t,index:n}),type:"title",action:null}:null},Nr=(e,t,r,n,s)=>Array.isArray(r)&&r.length&&at(t,e.formData)?r.flatMap((i,a)=>{const o=(t.countOffset||0)+a+1,l=`${t.full_path||t.fieldId}[${a}]`;let u=qo(t,i,o,l);return u=Ms(u),[Ho(t,i,e.id,o,l),...Ne(e,u,i,n,s)]}).filter(i=>!!i):ko(e,n),Vo="hods-form-summary-card-details",Us=({masterPage:e,childCollections:t=[],formData:r,entryData:n,classModifiers:s,hideChildSectionTitles:i=!1,optionalFieldPlaceholder:a})=>{const o=N.classBuilder(Vo,s),l=B.useMemo(()=>t.map(d=>e.childPages.find(c=>c.collection?.name===d)).filter(d=>!!d),[e,t]),u=(d,c,f)=>{let m=0;return d.flatMap((A,T)=>{let v=0;const x=A.fields?.flatMap(S=>c.filter(b=>b.fieldId===S).map(b=>{if(!b||!Ce(b,{...f.formData,...n}))return null;if(b.type===R.CONTAINER){const q=Ne(f,b,n);return v+=1,h.jsx("div",{className:o("field"),style:{"--column":m+1,"--row":v},role:"list",children:q.map(E=>{const P={...n,[E.fieldId]:n[b.fieldId]?.[E.fieldId]};return tt(f,{...E,label:E.key},o,P,a)})},S)}if(b.type===R.COLLECTION){const q=Nr({...f,formData:{...f.formData,...n}},b,n[b.id]);v+=1;let E=0;return h.jsx("div",{className:o("field"),style:{"--column":m+1,"--row":v},role:"list",children:q.map(P=>{const L={...n,[P.fieldId]:n[b.fieldId]?.[P.fieldId]},M=tt(f,{...P,label:P.key},o,L,a);return P.type==="title"&&(E+=1,E>1)?h.jsx("div",{style:{marginTop:"40px"},children:M}):M})},S)}return v+=1,h.jsx("div",{className:o("field"),style:{"--column":m+1,"--row":v},role:"list",children:tt(f,b,o,n,a)},S)})).filter(S=>!!S);return!(T===d.length-1)&&x.length!==0?(m+=2,[...x,h.jsx("div",{className:o("divider"),style:{"--column":m}},`divider${m}`)]):x}).filter(A=>!!A)};return e?.childPages?.filter(d=>N.FormPage.show(d,{...r,...n})).map(d=>{const c=N.Component.elevateNested(d?.components,n);return d.summaryLayout?.sections.map(f=>{if(f.show_when&&!N.Condition.meetsAll(f.show_when,{...r,...n}))return null;if(f.type==="childCollection"){const A=l.find(v=>v.collection.name===f.collectionName),T=n[f.collectionName.split(".").pop()]||[];return A&&T.length>0?h.jsxs(h.Fragment,{children:[h.jsx("h3",{className:o("section-title"),children:f.title}),T.map(v=>h.jsx(Us,{masterPage:A,childMasterPages:[],formData:{...r,...n,...v},entryData:v,hideChildSectionTitles:!0,optionalFieldPlaceholder:a}))]}):null}const m=f.columns.filter(A=>le.meetsAll(A,{...d.formData,...n}));return h.jsxs("div",{className:o("section"),children:[!i&&h.jsx("h3",{className:o("section-title"),children:N.FormPage.getConditionalText(f.title,{...d.formData,...n})}),h.jsx("dl",{className:o("section-content"),style:{"--dividers":m.length-1},children:u(m,c,d)})]},f.title)})}).filter(d=>!!d)||null},Go="hods-form-summary-card",Fn="Change",Wo="Delete",Ko="Quick Edit",zo="Duplicate",Jo="Full details",$n="secondary",Mn=({id:e,entryData:t,config:r,classModifiers:n,onFullEdit:s,onDelete:i,onDuplicate:a,onQuickEdit:o,parentCollectionName:l,childCollections:u=[],formData:d,masterPage:c,hideDetails:f=!1})=>{const[m,A]=B.useState(!1),T=I.Utils.classBuilder(Go,n,r.className),v=B.useMemo(()=>r.quickEdit?No(c,d,t):null,[c,r,d,t,m]),{addErrors:x,resetQuickEditErrors:$,clearTopLevelErrorsForCard:S,validate:w}=Oe(),{hooks:b}=ge(),q=async(E,P)=>{if(E.type==="cancel"&&(A(L=>!L),$?.()),E.type==="save"&&typeof o=="function"){const L={...v.formData,...P,[`${l}ActiveId`]:t.id},M=w.page({...v,formData:L});if(M.length)return;let C;await b.onSubmit("quickEdit",L,()=>{},D=>{C=D}),C&&x(C);const H=M.concat(C);if(H.length===0||H.length===1&&H[0]===void 0){S();const D=N.CollectionPage.getData(l,d),{isDuplicate:y,...g}=D[t.index];D[t.index]={...g,...P},o({target:{name:l,value:D}}),A(_=>!_)}}};return r.listView?h.jsx(jo,{id:e,entryData:t,config:r,onFullEdit:s,onDelete:i,masterPage:c,classModifiers:n,optionalFieldPlaceholder:r.fullDetails?.optionalFieldPlaceholder}):h.jsxs("div",{className:T(),id:e,children:[h.jsxs("div",{className:T("header"),children:[h.jsxs("div",{className:T("header-content"),children:[r.banners&&h.jsx(Ns,{id:`BannerStrip${t.id}`,banners:r.banners,formData:t}),h.jsx("h2",{id:`${e}.titleText`,className:T("header-content-title"),children:N.FormPage.getTitle(r.title,t)}),r.details&&h.jsx("div",{id:`${e}.titleDetail`,className:T("header-content-detail"),children:N.FormPage.getConditionalText(r.details,t)})]}),h.jsxs("div",{className:T("header-actions"),children:[r.quickEdit&&h.jsx(I.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>A(E=>!E),classModifiers:"primary",disabled:m,name:"QuickEdit",autoFocus:r.focusOn,children:Ko}),r.changeAction&&typeof s=="function"&&h.jsx(Yo,{id:`${e}.changeButton`,"data-testid":"change-button",actions:r.changeAction,onFullEdit:s,entryData:t,formData:d,name:"Change",autoFocus:r.focusOn}),r.deleteAction&&typeof i=="function"&&h.jsx(I.Button,{id:`${e}.deleteButton`,onClick:()=>i(t),classModifiers:"secondary","aria-label":N.FormPage.getConditionalText(r.deleteAction?.aria_label,t),name:"Delete",children:r.deleteAction?.label||Wo}),r.duplicateAction&&typeof a=="function"&&h.jsx(I.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{a(t)},classModifiers:"secondary","aria-label":N.FormPage.getConditionalText(r.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:r.focusOn,children:r.duplicateAction?.label||zo})]})]}),m&&v&&h.jsx(Or,{page:v,onAction:(E,P)=>q(E,P),className:T("editpage")}),h.jsx("div",{className:T("body"),children:!f&&h.jsx(I.Details,{summary:r.detailsTitle||Jo,className:"details",children:h.jsx(Us,{masterPage:c,childCollections:u,formData:d,entryData:t,optionalFieldPlaceholder:r.fullDetails?.optionalFieldPlaceholder})})})]})},Xo=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:r,children:n})=>{const{hooks:s}=ge(),i=t.filter(c=>c.entryId===e)||[],[a,o]=B.useState(null),l=()=>{o(null)},u=c=>{o(f=>(f??[]).concat(c))},d={page:c=>{const f=N.Validate.page(c),m=s.onValidate(c,f);return o(m),m}};return h.jsx(_r.Provider,{value:{addErrors:u,errors:a===null?[...i]:a,resetQuickEditErrors:l,clearTopLevelErrorsForCard:r,validate:d},children:n})},Un="Add",Qo=({config:e,formData:t,onAction:r,onChange:n,onTopLevelChange:s,pages:i=[]})=>{const{hooks:a}=ge(),{errors:o,addErrors:l,clearErrors:u,queuedErrors:d,enqueueErrors:c,dequeueErrors:f}=Oe(),[m,A]=B.useState(null),T=B.useMemo(()=>N.CollectionPage.getData(e.collectionName,t)||[],[t]),v=Array.isArray(T)&&T.length>0?T.reduce((P,L)=>L.isDuplicate&&(!P||L.id>P.id)?L:P,null):null,x=B.useMemo(()=>{const P=e.collectionName.split(".");let L=N.CollectionPage.mergePages(i||[])||[];return P.reduce((M,C,H)=>{const D=H===0?`${M}${C}`:`${M}.${C}`;return H===P.length-1?L?.find(y=>y.collection?.name===D)||null:(L=L.find(y=>y.collection?.name===D)?.childPages||null,D)},"")},[i]),$=B.useMemo(()=>e.card.listView?x.childPages?.reduce((L,M)=>{const C=Be(M.components,{...t,...m});return L.concat(C)},[])||[]:[],[x,t,m,e.card.listView]),S=()=>{d.length>0&&f(L=>L.raisedBy===e.id);const P=Pr(e,x,t,a);P.length>0&&c(P)};B.useEffect(()=>{Array.isArray(T)&&T.length>0&&S()},[T]);const w=(P,L)=>{if(typeof r=="function"){const M=[...T],C=T.findIndex(y=>y.id===L),{isDuplicate:H,...D}=T[C];M[C]={...D},r({type:Ze.SAVE_AND_NAVIGATE,page:P,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:L},{field:e.collectionName,value:M,isCollection:!0}]})}},b=P=>{N.CollectionPage.duplicateEntry(e.collectionName,t,P.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const L=e.collectionName.split(".").shift();typeof s=="function"&&(s({target:{name:L,value:N.CollectionPage.getData(L,t)}}),S())},q=()=>{if(!m)return;N.CollectionPage.removeEntry(e.collectionName,t,m.id);const P=e.collectionName.split(".").shift();typeof s=="function"&&s({target:{name:P,value:N.CollectionPage.getData(P,t)}}),A(null),S()},E=P=>{const L=$.find(C=>C.fieldId===P);if(!L)return null;const M=At({...x,formData:{...t,...m}},L);return h.jsx("div",{className:"confirmation-field-value",children:h.jsx(wr,{value:M.value,component:M.component,formData:M.formData})},P)};return h.jsxs("div",{id:e.fieldId,children:[m&&h.jsx(wo,{id:`${e.fieldId}.confirmation`,message:N.interpolateString(e.confirmation?.message,{...m,index:m.index+1})||null,confirmLabel:N.interpolateString(e.confirmation?.label,m)||null,onConfirm:q,onCancel:()=>A(null),children:e.card.listView?h.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(E)}):h.jsx(Mn,{id:`${e.fieldId}.confirmationChild`,entryData:m,config:e.card?{...e.card,quickEdit:null}:{},masterPage:x,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&h.jsx(pr,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:N.interpolateString(e.addButton.label||Un,{documents:T}),page:e.addButton.page,type:Ze.COLLECTION_ADD,classModifiers:["secondary"]},onAction:r}),h.jsx("ul",{className:"collection-summary-card-list",children:T.map((P,L)=>{const M=o.filter(D=>D.entryId===P.id).length>0,C={...e.card,...P.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...M&&e.errorCard?e.errorCard:{},focusOn:v?.id===P.id},H=`${e.fieldId}.summaryCard${P.id}`;return h.jsx("li",{children:h.jsx(Xo,{entryId:P.id,topLevelErrors:o,clearTopLevelErrorsForCard:()=>{const D=o.filter(y=>y.entryId!==P.id);u(),l(D)},children:h.jsx(Mn,{id:H,entryData:{...P,index:L},masterPage:x,config:C||{},onFullEdit:w,onDuplicate:b,onDelete:()=>A({...P,index:L}),onQuickEdit:D=>(S(),n(D)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:P.id===m?.id?["deleting-summary-card"]:[""],inError:o.filter(D=>D.entryId===P.id).length>0},H)})})})}),e.card.listView&&e.addButton&&h.jsx(pr,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:N.interpolateString(e.addButton.label||Un,{documents:T}),page:e.addButton.page,type:Ze.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:r})]})},Zo="hods-form-collection",el=({config:e,value:t,formData:r,onChange:n=void 0,onTopLevelChange:s=void 0,wrap:i=!1})=>{const[a,o]=B.useState(t),l=T=>{o(T),typeof n=="function"&&n({target:{name:e.fieldId,value:T}})},u=({target:T})=>{if(typeof n=="function")if(T.name===N.Meta.name)n({target:T});else{const v=a.findIndex(x=>x.id===T.name);l([...a.slice(0,v),T.value,...a.slice(v+1)])}},d=async()=>{l([...a,{id:ct.v4()}])},c=async T=>{l(a.filter(v=>v.id!==T.id))},f=T=>T.initial&&!a.length?T.initial:T.add;B.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(a)&&a.length&&(a.length>e.minimumEntries||!e.minimumEntries)){const T=a[a.length-1]?.id,x=document.getElementById(T)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');x&&x.length>0&&x[0].focus()}},[a.length,e.focusOnAdd,e.minimumEntries]),B.useEffect(()=>{e.minimumEntries&&!a.length&&d()},[e.minimumEntries,a.length]);const m={...De,...e.labels},A=N.classBuilder(Zo,[],e.className);return h.jsxs("div",{className:A(),id:e.id,children:[e.label&&h.jsx(I.Label,{id:e.id,required:e.required,className:A("title"),children:e.label}),Array.isArray(a)&&a.map((T,v)=>{const x=`${e.full_path||e.fieldId}[${v}]`,$=(e.countOffset||0)+v+1,S=N.interpolateString(m.item,{...T,index:$}),w=N.interpolateString(m.remove,{...T,index:$}),b=e.disableAddAndRemove||v===0&&e.minimumEntries?"":e.removeLocation??"start",q=v!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return h.jsxs("div",{className:`${A("item")}`,style:q,children:[h.jsxs(I.Label,{id:T.id,required:!0,className:A("item-title"),children:[S,b==="start"&&h.jsx(I.Button,{onClick:()=>c(T),classModifiers:"secondary",children:w})]}),h.jsx(Ur,{container:{id:T.id,fieldId:T.id,type:"container",required:e.required,full_path:x,components:e.item.map(E=>{const{firstOnlyLabel:P,...L}=E;let{hint:M}=E;e.restrictHint&&v>0&&(M=void 0);let{label:C}=E;return v===0&&(C=E.firstOnlyLabel??E.label),{...L,hint:M,readonly:!!(e?.readonly||E.readonly),label:N.interpolateString(C,{...T,index:$}),full_path:`${x}.${E.fieldId}`}})},value:T,formData:r,onChange:u,onTopLevelChange:s,wrap:i}),b==="end"&&h.jsx(I.ButtonGroup,{className:"govuk-!-margin-top-2",children:h.jsx(I.Button,{onClick:()=>c(T),classModifiers:"secondary",children:w})})]},T.id)}),!e.disableAddAndRemove&&h.jsx(I.ButtonGroup,{children:h.jsx(I.Button,{onClick:d,classModifiers:"secondary",children:f(m)})})]})},tl=(e,t,r)=>{const n=e,s=typeof n.value=="object"?n.value?.value:n.value,i=r.find(a=>String(a.id)===s);return n.label=i===void 0?n.value||"":i.label,n.component=t.cya_label,n},rl=(e,t)=>typeof e=="string"?!!I.Utils.interpolateString(e,t):!!e,ar=(e,t)=>{if(Array.isArray(t)){const r=t.find(n=>n.id===(e.full_path||e.id));if(r){const n={error:r.error};return r.properties&&(n.propsInError=r.properties),n}}},nl=[R.RADIOS,R.CHECKBOXES,R.DATE,R.TIME],sl=e=>e.fieldset||nl.includes(e.type),Le=({component:e,value:t=null,formData:r=null,wrap:n=!0,onAction:s,onChange:i,onTopLevelChange:a,pages:o=[],submitting:l=!1,...u})=>{const{hooks:d}=ge(),c=Oe(),{data:f,status:m}=go(e,r),[A,T]=B.useState([]);B.useEffect(()=>{m===et&&T(f)},[e,f,m]);const v=({target:S})=>typeof i=="function"?(e.type===R.EMAIL&&(S.value=S.value.trim()),e.type===R.CHECKBOXES&&Array.isArray(S.value)&&S.value.forEach(w=>{w.children&&w.nested&&(delete w.children,delete w.nested)}),S=tl(S,e,f),e.type===R.SELECT&&S.value===""&&(S.value=null,S.label=null),i({target:S}),!0):!1;if(B.useEffect(()=>{const S=N.Component.defaultValue(e,r);!t&&!r?.[e.fieldId]&&S&&typeof v=="function"&&v({target:{name:e.fieldId,value:S}})},[]),e.type===R.CONTAINER){let S=h.jsx(Ur,{...u,container:e,wrap:n,onChange:v,onTopLevelChange:a,value:t||N.Component.defaultValue(e,r),formData:r});return e.fieldset&&(S=Ue(e,S)),e.additionalValidation&&(S=Ue({...e,...ar(e,c?.errors)},S)),S}if(e.type===R.COLLECTION)return h.jsx(el,{...u,config:e,wrap:n,onChange:v,onTopLevelChange:a,value:t||N.Component.defaultValue(e,r),formData:r});if(e.type===R.COLLECTION_SUMMARY)return Ue({...e,...ar(e,c?.errors)},h.jsx(Qo,{...u,config:e,formData:r,onAction:s,onChange:i,onTopLevelChange:a,pages:o}));const x=S=>{let w=e.full_path||e.fieldId;if(e.pageCollection){const b=N.CollectionPage.getActiveIndex(e.pageCollection.name,r);w=`${`${e.pageCollection.name}[${b}]`}.${w}`}a({target:{name:N.Meta.name,value:N.Meta.documents.setForField(S,r,w,e.allowMultiple)}})},$=({target:S})=>{if(v({target:S})){if(e.type===R.FILE)x([S.value]);else if(e.type===R.MULTI_FILE){const w=S.value.map((b,q)=>({...b,indexInField:q}));x(w)}}};return N.Component.get({...u,...e,id:e.full_path||e.id,...ar(e,c?.errors),fieldset:sl(e),disabled:rl(e.disabled,r),label:N.interpolateString(e.label,r),content:N.interpolateString(e.content,r),hint:N.interpolateString(e.hint,r),cya_label:N.interpolateString(e.cya_label,r),suffix:N.interpolateString(e.suffix,r),options:A,value:t,onChange:$,onTopLevelChange:a,formData:r,onAction:s,submitting:l},n,d.onGetComponent)},il=[R.AUTOCOMPLETE,R.CALCULATION,R.CHECKBOXES,R.COLLECTION_SUMMARY,R.DATE,R.EMAIL,R.FILE,R.MULTI_FILE,R.PHONE_NUMBER,R.RADIOS,R.SELECT,R.TEXT,R.TEXT_AREA,R.TIME],js=e=>il.includes(e?.type)||e?.isEditable||!1,al="govuk-list",ol="govuk-body",ll=e=>{const t=te(e),r=I.Utils.interpolateString(e.heading,e.formData),n=I.Utils.interpolateString(e.text,e.formData);return h.jsx(I.Alert,{...t,heading:r,children:n})},ul=e=>{const t=te(e),r=fe.getAutocompleteSource(e);return h.jsx(I.Autocomplete,{...t,source:r})},cl=e=>{let t=[];fe.getOptions(e,n=>{t=n}),t=t.map(n=>Array.isArray(n.nested)?{...n,children:Ys(e,n.nested)}:n);const r=te(e);return h.jsx(I.Checkboxes,{...r,options:t})},dl=e=>{const t=fe.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const r=te(e,["formula"]);return h.jsx(I.TextInput,{...r,readonly:!0})},fl=e=>{const t=te(e);return h.jsx(I.DateInput,{...t})},hl=e=>{const t=te(e,["tagName"]),r=Et(e);return h.jsx(I.Details,{...t,children:r})},ml=e=>{const t=te(e);return h.jsx(I.FileUpload,{...t})},pl=e=>{const t=te(e);return h.jsx(I.MultiFileUpload,{...t})},El=e=>{const t=te(e);return h.jsx(I.Heading,{...t,children:e.content})},Et=e=>{const t=te(e);return h.jsx(I.Markup,{...t})},Al=e=>{const t=te(e);return h.jsx(I.InsetText,{...t,children:e.content})},vl=e=>{const t=te(e,["ordered"]),r=e.ordered?"ol":"ul",n=e.ordered?"number":"bullet",s=I.Utils.classBuilder(al,n),i=t.items?.map(a=>`<li>${a}</li>`).join("");return Et({...t,className:s(),tagName:r,content:i,type:R.HTML})},yl=e=>{const t=te(e);return Et({className:ol,...t,tagName:"p",type:R.HTML})},Tl=e=>{let t=[];fe.getOptions(e,n=>{t=n}),t=t.map(n=>Array.isArray(n.nested)?{...n,children:Ys(e,n.nested)}:n);const r=te(e);return h.jsx(I.Radios,{...r,options:t})},Sl=e=>{const t=te(e);return h.jsx(I.TextArea,{...t})},Cl=e=>{const t=te(e);return h.jsx(I.TextInput,{...t})},gl=e=>{const t=te(e);return h.jsx(I.TimeInput,{...t})},xl=e=>{let t=[];fe.getOptions(e,n=>{t=n});const r=te(e);return h.jsx(I.Select,{...r,options:t})},Il=e=>{const t=te(e);return h.jsx(I.WarningText,{...t,children:e.content})},_l=e=>{switch(e.type){case R.HTML:return Et(e);case R.HEADING:return El(e);case R.INSET_TEXT:return Al(e);case R.TEXT:case R.EMAIL:case R.PHONE_NUMBER:return Cl(e);case R.TEXT_AREA:return Sl(e);case R.AUTOCOMPLETE:return ul(e);case R.RADIOS:return Tl(e);case R.CHECKBOXES:return cl(e);case R.DATE:return fl(e);case R.TIME:return gl(e);case R.FILE:return ml(e);case R.MULTI_FILE:return pl(e);case R.WARNING:return Il(e);case R.SELECT:return xl(e);case R.DETAILS:return hl(e);case R.CALCULATION:return dl(e);case R.ALERT:return ll(e);case R.PARAGRAPH:return yl(e);case R.LIST:return vl(e);default:return null}},Pl=(e,t)=>{const r={...t};if(e.full_path){const n=e.full_path.split(".");n.pop(),n.push(r.fieldId),r.full_path=n.join(".")}return e.formData&&(r.value=e.formData[r.fieldId]||fe.getSource(e.formData,r.full_path)||""),"readonly"in r&&delete r.readonly,e.readonly?(r.readonly=e.readonly,h.jsx("div",{children:Bs(r,!1)})):h.jsx(Le,{component:r,value:r.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},r.key)},Ys=(e,t)=>{const r=t.filter(n=>!(n.show_when&&!le.meetsAll(n.show_when,e.formData))).map(n=>h.jsx(h.Fragment,{children:Pl(e,n)},n.id));return r.length>0?r:null},Bs=(e,t=!0,r=void 0)=>{if(typeof r=="function"){const s=r(e,t);if(s)return s}const n=_l(e);return n&&t&&js(e)?Ue(e,n):n};var rt={exports:{}},wl=rt.exports,jn;function bl(){return jn||(jn=1,(function(e,t){(function(r,n){e.exports=n()})(wl,(function(){var r=1e3,n=6e4,s=36e5,i="millisecond",a="second",o="minute",l="hour",u="day",d="week",c="month",f="quarter",m="year",A="date",T="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,x=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,$={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(y){var g=["th","st","nd","rd"],_=y%100;return"["+y+(g[(_-20)%10]||g[_]||g[0])+"]"}},S=function(y,g,_){var F=String(y);return!F||F.length>=g?y:""+Array(g+1-F.length).join(_)+y},w={s:S,z:function(y){var g=-y.utcOffset(),_=Math.abs(g),F=Math.floor(_/60),O=_%60;return(g<=0?"+":"-")+S(F,2,"0")+":"+S(O,2,"0")},m:function y(g,_){if(g.date()<_.date())return-y(_,g);var F=12*(_.year()-g.year())+(_.month()-g.month()),O=g.clone().add(F,c),j=_-O<0,k=g.clone().add(F+(j?-1:1),c);return+(-(F+(_-O)/(j?O-k:k-O))||0)},a:function(y){return y<0?Math.ceil(y)||0:Math.floor(y)},p:function(y){return{M:c,y:m,w:d,d:u,D:A,h:l,m:o,s:a,ms:i,Q:f}[y]||String(y||"").toLowerCase().replace(/s$/,"")},u:function(y){return y===void 0}},b="en",q={};q[b]=$;var E="$isDayjsObject",P=function(y){return y instanceof H||!(!y||!y[E])},L=function y(g,_,F){var O;if(!g)return b;if(typeof g=="string"){var j=g.toLowerCase();q[j]&&(O=j),_&&(q[j]=_,O=j);var k=g.split("-");if(!O&&k.length>1)return y(k[0])}else{var p=g.name;q[p]=g,O=p}return!F&&O&&(b=O),O||!F&&b},M=function(y,g){if(P(y))return y.clone();var _=typeof g=="object"?g:{};return _.date=y,_.args=arguments,new H(_)},C=w;C.l=L,C.i=P,C.w=function(y,g){return M(y,{locale:g.$L,utc:g.$u,x:g.$x,$offset:g.$offset})};var H=(function(){function y(_){this.$L=L(_.locale,null,!0),this.parse(_),this.$x=this.$x||_.x||{},this[E]=!0}var g=y.prototype;return g.parse=function(_){this.$d=(function(F){var O=F.date,j=F.utc;if(O===null)return new Date(NaN);if(C.u(O))return new Date;if(O instanceof Date)return new Date(O);if(typeof O=="string"&&!/Z$/i.test(O)){var k=O.match(v);if(k){var p=k[2]-1||0,U=(k[7]||"0").substring(0,3);return j?new Date(Date.UTC(k[1],p,k[3]||1,k[4]||0,k[5]||0,k[6]||0,U)):new Date(k[1],p,k[3]||1,k[4]||0,k[5]||0,k[6]||0,U)}}return new Date(O)})(_),this.init()},g.init=function(){var _=this.$d;this.$y=_.getFullYear(),this.$M=_.getMonth(),this.$D=_.getDate(),this.$W=_.getDay(),this.$H=_.getHours(),this.$m=_.getMinutes(),this.$s=_.getSeconds(),this.$ms=_.getMilliseconds()},g.$utils=function(){return C},g.isValid=function(){return this.$d.toString()!==T},g.isSame=function(_,F){var O=M(_);return this.startOf(F)<=O&&O<=this.endOf(F)},g.isAfter=function(_,F){return M(_)<this.startOf(F)},g.isBefore=function(_,F){return this.endOf(F)<M(_)},g.$g=function(_,F,O){return C.u(_)?this[F]:this.set(O,_)},g.unix=function(){return Math.floor(this.valueOf()/1e3)},g.valueOf=function(){return this.$d.getTime()},g.startOf=function(_,F){var O=this,j=!!C.u(F)||F,k=C.p(_),p=function(he,ee){var de=C.w(O.$u?Date.UTC(O.$y,ee,he):new Date(O.$y,ee,he),O);return j?de:de.endOf(u)},U=function(he,ee){return C.w(O.toDate()[he].apply(O.toDate("s"),(j?[0,0,0,0]:[23,59,59,999]).slice(ee)),O)},Y=this.$W,G=this.$M,V=this.$D,K="set"+(this.$u?"UTC":"");switch(k){case m:return j?p(1,0):p(31,11);case c:return j?p(1,G):p(0,G+1);case d:var re=this.$locale().weekStart||0,me=(Y<re?Y+7:Y)-re;return p(j?V-me:V+(6-me),G);case u:case A:return U(K+"Hours",0);case l:return U(K+"Minutes",1);case o:return U(K+"Seconds",2);case a:return U(K+"Milliseconds",3);default:return this.clone()}},g.endOf=function(_){return this.startOf(_,!1)},g.$set=function(_,F){var O,j=C.p(_),k="set"+(this.$u?"UTC":""),p=(O={},O[u]=k+"Date",O[A]=k+"Date",O[c]=k+"Month",O[m]=k+"FullYear",O[l]=k+"Hours",O[o]=k+"Minutes",O[a]=k+"Seconds",O[i]=k+"Milliseconds",O)[j],U=j===u?this.$D+(F-this.$W):F;if(j===c||j===m){var Y=this.clone().set(A,1);Y.$d[p](U),Y.init(),this.$d=Y.set(A,Math.min(this.$D,Y.daysInMonth())).$d}else p&&this.$d[p](U);return this.init(),this},g.set=function(_,F){return this.clone().$set(_,F)},g.get=function(_){return this[C.p(_)]()},g.add=function(_,F){var O,j=this;_=Number(_);var k=C.p(F),p=function(G){var V=M(j);return C.w(V.date(V.date()+Math.round(G*_)),j)};if(k===c)return this.set(c,this.$M+_);if(k===m)return this.set(m,this.$y+_);if(k===u)return p(1);if(k===d)return p(7);var U=(O={},O[o]=n,O[l]=s,O[a]=r,O)[k]||1,Y=this.$d.getTime()+_*U;return C.w(Y,this)},g.subtract=function(_,F){return this.add(-1*_,F)},g.format=function(_){var F=this,O=this.$locale();if(!this.isValid())return O.invalidDate||T;var j=_||"YYYY-MM-DDTHH:mm:ssZ",k=C.z(this),p=this.$H,U=this.$m,Y=this.$M,G=O.weekdays,V=O.months,K=O.meridiem,re=function(ee,de,ue,Ae){return ee&&(ee[de]||ee(F,j))||ue[de].slice(0,Ae)},me=function(ee){return C.s(p%12||12,ee,"0")},he=K||function(ee,de,ue){var Ae=ee<12?"AM":"PM";return ue?Ae.toLowerCase():Ae};return j.replace(x,(function(ee,de){return de||(function(ue){switch(ue){case"YY":return String(F.$y).slice(-2);case"YYYY":return C.s(F.$y,4,"0");case"M":return Y+1;case"MM":return C.s(Y+1,2,"0");case"MMM":return re(O.monthsShort,Y,V,3);case"MMMM":return re(V,Y);case"D":return F.$D;case"DD":return C.s(F.$D,2,"0");case"d":return String(F.$W);case"dd":return re(O.weekdaysMin,F.$W,G,2);case"ddd":return re(O.weekdaysShort,F.$W,G,3);case"dddd":return G[F.$W];case"H":return String(p);case"HH":return C.s(p,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return he(p,U,!0);case"A":return he(p,U,!1);case"m":return String(U);case"mm":return C.s(U,2,"0");case"s":return String(F.$s);case"ss":return C.s(F.$s,2,"0");case"SSS":return C.s(F.$ms,3,"0");case"Z":return k}return null})(ee)||k.replace(":","")}))},g.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},g.diff=function(_,F,O){var j,k=this,p=C.p(F),U=M(_),Y=(U.utcOffset()-this.utcOffset())*n,G=this-U,V=function(){return C.m(k,U)};switch(p){case m:j=V()/12;break;case c:j=V();break;case f:j=V()/3;break;case d:j=(G-Y)/6048e5;break;case u:j=(G-Y)/864e5;break;case l:j=G/s;break;case o:j=G/n;break;case a:j=G/r;break;default:j=G}return O?j:C.a(j)},g.daysInMonth=function(){return this.endOf(c).$D},g.$locale=function(){return q[this.$L]},g.locale=function(_,F){if(!_)return this.$L;var O=this.clone(),j=L(_,F,!0);return j&&(O.$L=j),O},g.clone=function(){return C.w(this.$d,this)},g.toDate=function(){return new Date(this.valueOf())},g.toJSON=function(){return this.isValid()?this.toISOString():null},g.toISOString=function(){return this.$d.toISOString()},g.toString=function(){return this.$d.toUTCString()},y})(),D=H.prototype;return M.prototype=D,[["$ms",i],["$s",a],["$m",o],["$H",l],["$W",u],["$M",c],["$y",m],["$D",A]].forEach((function(y){D[y[1]]=function(g){return this.$g(g,y[0],y[1])}})),M.extend=function(y,g){return y.$i||(y(g,H,M),y.$i=!0),M},M.locale=L,M.isDayjs=P,M.unix=function(y){return M(1e3*y)},M.en=q[b],M.Ls=q,M.p={},M}))})(rt)),rt.exports}var Dl=bl();const J=ke(Dl),Ol=e=>e.defaultValue||e.defaultObjectValue,Ll=e=>{const r=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?J().format("DD-MM-YYYY"):r},Nl=(e,t)=>{const r={...e};let n=null;return!r.literal&&!r.sourced&&(r.sourced={...r}),r.literal&&(n={...r.literal}),r.sourced&&(n=n??{},Object.keys(r.sourced).every(s=>{const i=typeof r.sourced[s]=="string"&&se(t,r.sourced[s]);return i===void 0&&r.skipIfSourceInvalid?(n=null,!1):(n[s]=i||r.sourced[s],!0)})),n},ks=(e,t)=>Ol(e)?e.type===R.DATE?Ll(e):(e.defaultObjectValue?Nl(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Rl={[R.COLLECTION]:[],[R.CONTAINER]:{}},Fl=(e,t)=>e&&(ks(e,t)||Rl[e.type])||"",qe={clean:te,defaultValue:Fl,defaultValueFromConfig:ks,editable:js,elevateNested:Be,get:Bs,setupContainerPaths:Ms,show:Ce,wrap:Ue},$l=(e,t)=>{e.data?.options?.forEach(r=>{Array.isArray(r.nested)&&Ye(t.formData[e.id],r)&&r.nested.forEach(n=>{const s=n;s.value=t.formData[s.id]})})},At=(e,t,r)=>{let n="";return e.formData&&t.fieldId&&(n=e.formData[t.fieldId],$l(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:I.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:qe.editable(t)?t:void 0,value:n||"",action:e.cya_link?.singleChangeLink?null:pt(t.readonly,e,r)}},Ne=(e,t,r,n,s)=>at(t,{...e.formData,...r})?Be(t.components.filter(a=>a.show_on_cya===void 0||a.show_on_cya),r).filter(a=>at(a,{...e.formData,...r})).flatMap(a=>{const o=r?r[a.fieldId]:void 0;if(typeof s=="function"){const l=s({...e,formData:r},a,n);if(l)return l}return a.type===R.CONTAINER?Ne(e,a,{...o,...r},n,s):a.type===R.COLLECTION?Nr(e,a,o,n,s):At({...e,formData:r},a,n)}):null,Ml=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(r=>{N.Condition.met(r.condition,e.formData[r.condition.field])&&(t=Object.assign(t,r.properties))}),t},Yn=(e,t,r="text")=>{if(typeof e=="string")return I.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const n=e.find(s=>typeof s=="string"?!0:we(s.show_when,t));return typeof n=="string"?I.Utils.interpolateString(n,t):I.Utils.interpolateString(n[r],t)},Ul=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},jl=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return X.DEFAULTS[t];if(t&&typeof t=="object"){const r=t;return X.DEFAULTS[r.type]?.validate&&!r.hasOwnProperty("validate")&&(r.validate=!0),Ul(r)}}).filter(t=>!!t)},Yl=e=>({type:R.HTML,tagName:"p",content:e}),Bl=(e,t)=>{const r=e.use.split("."),n=r.shift();let s=JSON.parse(JSON.stringify({...t.find(o=>o.id===n)})),i=s,a=s;for(;i&&r.length>0;){const o=r.shift();Array.isArray(i.components)?(a=i,a.components=a.components.filter(l=>l.id===o),a.components.length>0?i=a.components[0]:i=void 0):i=void 0}if(i)return i={cya_label:i.label,...i,...e},a&&a.id!==i.id?a.components=[i]:s=i,i.item&&Array.isArray(i.item)&&(i.item=i.item.map(o=>o.use?Ar(o,t):o)),s},Ar=(e,t)=>{if(e){const r=Bl(e,t);if(r)return r}return{...e}},qs=(e,t,r)=>{if(!e)return null;const n=e.components.map(i=>{if(typeof i=="string")return Yl(i);let a;return i.type===R.CONTAINER&&(i.components=i.components.map(o=>o.use?Ar(o,t):o)),i.use?a=Ar(i,t):a={...i},r?fe.refData.setupUrl(a,r):a}),s=jl(e);return ht.setup({...e,formData:r,components:n,actions:s})},kl=(e,t,r)=>Array.isArray(e)?e.map((n,s)=>({...qs(n,t,r),index:s})):[],Hs=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:mt(e,t),He={applyConditionalProperties:Ml,getConditionalText:Yn,get:qs,getAll:kl,getTitle:(e,t)=>Yn(e,t,"title"),show:mt,showCYA:Hs},ql=(e,t)=>{if(!e)return null;if(!t)return e;const r={...e};return r.show_when?Array.isArray(t)?r.show_when=Array.isArray(r.show_when)?[...t,...r.show_when]:[...t,r.show_when]:r.show_when=Array.isArray(r.show_when)?[...r.show_when,t]:[r.show_when,t]:r.show_when=t,r},Hl=(e,t)=>{const r=e.split(".").pop();t[`${r}ActiveId`]=null},vt=(e,t)=>{const r=e.split(".").pop();return t[`${r}ActiveId`]||null},Vl=e=>typeof e=="number"&&e>=0,Vs=(e,t,r)=>{const n=e[0];if(e.length===1)return t[n]||null;const s=r?.[`${n}ActiveId`]||null;if(!s)return null;const i=t[n]?.findIndex(a=>a.id===s);return Vl(i)?(e.shift(),Vs(e,t[n][i],r)):null},Re=(e,t)=>{const r=e.split(".");return Vs(r,t,t)},Gs=(e,t,r,n=[],s={})=>{const i=Re(e,t),a=i?.find(d=>d.id===r);if(!a)return null;const o=ct.v4(),l={...a,...s,id:o};n.forEach(d=>delete l[d]);const u=i.findIndex(d=>d.id===r)+1;return u===-1?i.push(l):i.splice(u,0,l),t[`${e.split(".").pop()}ActiveId`]=l.id,o},Gl=(e,t)=>{const r=vt(e,t);return Gs(e,t,r)},Wl=e=>typeof e=="number"&&e>=0,Ws=(e,t,r)=>{const n=e[0],s=r?.[`${n}ActiveId`]||null;if(!s)return null;const i=t[n]?.findIndex(a=>a.id===s);return Wl(i)?e.length===1?i:(e.shift(),Ws(e,t[n][i],r)):null},Ks=(e,t)=>{const r=e.split(".");return Ws(r,t,t)},Kl=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]}),zl=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Jl=(e,t)=>{const r=e.collection.name.split(".");if(r.length===1)return!1;r.pop();const n=r.join("."),s=t[n]||null;return s?(s.childPages.push(e),s.childPages.sort((i,a)=>i.orderInForm-a.orderInForm),!0):!1},zs=e=>{const t={};return e.map((n,s)=>{if(n.orderInForm=s,n?.collection?.name){if(!t[n.collection.name]){const i=Kl(n);return t[n.collection.name]=i,i}return zl(n,t[n.collection.name]),null}return n}).filter(n=>!!n).map(n=>n.collection?.masterPage&&Jl(n,t)?null:n).filter(n=>!!n)},Xl=(e,t,r)=>{const n=Re(e,t);if(!n)return null;const s=n.findIndex(o=>o.id===r);if(s===-1)return null;const i=n[s];n.splice(s,1);const a=t;return a[`${e}ActiveId`]=n.length>0?n[0].id:null,i},Ql=e=>typeof e=="number"&&e>=0,Rr=(e,t,r)=>{const n=e.split("."),s=n[n.length-1];let i=r;n.some(a=>{if(i[a]||(i[a]=[]),!i[a].find(u=>u.id===r[`${a}ActiveId`])){const u=ct.v4();r[`${a}ActiveId`]=r[`${a}ActiveId`]||u,i[a].push({id:r[`${a}ActiveId`]})}if(a===s)return i[s]=t,!0;const o=r[`${a}ActiveId`],l=i[a]?.findIndex(u=>u.id===o);return Ql(l)?(i=i[a][l],!1):!0})},ot={addEntry:Hl,duplicateActiveEntry:Gl,duplicateEntry:Gs,getActiveId:vt,getActiveIndex:Ks,getData:Re,getErrorsForCollection:Pr,mergePages:zs,removeEntry:Xl,setData:Rr},Zl=e=>typeof e=="number"&&e>=0,eu=(e,t,r,n,s,i)=>{const a=s?.label||De.remove;return{pageId:e.id,fieldId:`delete${n}`,key:`delete${n}`,type:"action",action:{onAction:()=>{r(null,l=>{const u=l;if(!i)return u;Object.entries(i).forEach(f=>{const[m,A]=f;u[m]=A});const d=ot.getData(e.collection.name,u),c=d?.findIndex(f=>f.id===t.id);return Zl(c)&&d.splice(c,1),u})},label:I.Utils.interpolateString(a,{...t,index:n})}}},tu=(e,t,r,n,s,i={})=>{const a=s?.label||De.change;return{pageId:e.id,fieldId:`change${n}${s.page}`,key:`change${n}${s.page}`,type:"action",action:{onAction:o=>{const l=u=>{const d=u;return Object.entries(i).forEach(c=>{const[f,m]=c;d[f]=m}),d};r(s.page?{pageId:s.page}:o,l)},label:I.Utils.interpolateString(a,{...t,index:n})}}},ru=(e,t)=>t.show_when?we(t.show_when,e):!0,nu=(e,t,r,n)=>({id:t.id,fieldId:t.id,type:R.CONTAINER,required:!0,full_path:n,components:e.components.map(s=>({...s,label:I.Utils.interpolateString(s.label,{...t,index:r}),full_path:`${n}.${s.fieldId}`}))}),su=(e,t,r,n,s)=>{const i={...De,...e.collection.labels};return{pageId:r,fieldId:"Title",full_path:`${s}.Title`,key:I.Utils.interpolateString(i.item,{...t,index:n}),type:"heading",size:e.collection.titleSize||"s"}},iu=(e,t,r,n,s)=>e.text===""?null:{pageId:t,fieldId:`heading${r}`,full_path:`heading${r}`,key:I.Utils.interpolateString(e.text,s),type:n===null?"heading":"headingWithAction",size:e.size||"s",action:n===null?null:{onAction:n,label:"Change"}},au=(e,t,r,n)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:r?.text||t.charAt(0).toUpperCase()+t.slice(1),type:n==null?"heading":"headingWithAction",size:r?.size||"m",action:n===null?null:{onAction:n,label:"Change"}}),ou=(e,t,r,n,s,i={})=>e.collection?.actions?.filter(a=>ru(s,a)).map(a=>a.type==="remove"?eu(e,t,r,n,a,i):a.type==="change"?tu(e,t,r,n,a,i):null).filter(a=>!!a),Js=(e,t,r={})=>()=>{const n=s=>{const i=s;return Object.entries(r).forEach(a=>{const[o,l]=a;i[o]=l}),i};t({pageId:e.id},n)},lu=(e,t,r,n,s,i,a)=>{let o=[];return e.forEach(l=>{let u=l;if(u.collection.masterPage)o=o.concat(Xs(u,r,n,t,a));else if(u.collection.route&&(u=ql(u,u.collection.route)||u),Hs(u,{...u.formData,...t})){const d=Js(u,r,a);if(u.collection.heading){const m=u.collection.heading.changeLink?d:null,A=iu(u.collection.heading,u.id,s,m,t);o=o.concat(A)}const c=nu(u,t,s,i),f=Ne({...u,formData:{...u.formData,...t}},c,{...u.formData,...t},d,n);o=o.concat(f)}}),o},Xs=(e,t,r,n,s={})=>{const i=e.collection.name.split(".").pop();let a=n[i]||null;const o=n[`${i}ActiveId`];if(!a||a.length===0)return[];let l=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?Js({id:e.collection.collectionHeading.changeLinkPage},t,s):null;l.push(au(e,i,e.collection.collectionHeading,f))}let u=0;const d=Array.isArray(e.collection.hideItemTitles)?we(e.collection.hideItemTitles,n):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?we(e.collection.onlyShowActiveEntryOnCYA,n):e.collection.onlyShowActiveEntryOnCYA)&&(a=[a.find((m,A)=>(u=A,m.id===o))]),a.forEach(f=>{if(!f)return;s={...s,[`${i}ActiveId`]:f.id};const m=u+1,A=e.collection?.actionPosition||"top",T=`${e.collection.name}[${u}]`,v=ou(e,f,t,m,n,s);if(!d){const x=su(e,f,e.id,m,T);l=l.concat(x)}A==="top"&&(l=l.concat(v)),l=l.concat(lu(e.childPages,f,t,r,m,T,s)),A==="bottom"&&(l=l.concat(v)),u+=1}),l.filter(f=>!!f)},uu=e=>e.value?e.component?h.jsx("div",{children:h.jsx(Le,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,cu=(e,t)=>{let r=-1;return{value:h.jsx(h.Fragment,{children:e.components.map(s=>{const i=t.findIndex(a=>a.id===s);return r<0&&(r=i),i>-1?uu(t[i]):null})}),firstComponentIndex:r}},du=(e,t,r,n)=>{const{value:s,firstComponentIndex:i}=cu(t,r);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:s,action:pt(!1,e,n)},insertAt:i}},fu=(e,t,r=null)=>{if(He.showCYA(e,e.formData)){if(e.collection)return Xs(e,t,r,e.formData);const s=Be(e.components,e.formData).filter(i=>at(i,e.formData)).flatMap(i=>{if(typeof r=="function"){const a=r(e,i,t);if(a)return a}switch(i.type){case R.CONTAINER:return Ne(e,i,e.formData[i.fieldId],t,r);case R.COLLECTION:return Nr(e,i,e.formData[i.fieldId],t,r);default:return At(e,i,t)}});if(e.groups?.length>0){e.groups.forEach(a=>{const{row:o,insertAt:l}=du(e,a,s,t);l>-1?s.splice(l,0,o):s.push(o)});const i=e.groups.flatMap(a=>a.components);return s.filter(a=>!i.includes(a.id))}return s}return[]},hu={getRows:fu,getCYARowsForContainer:Ne},Qs=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},Zs=(e,t,r)=>{const n=t;e.format&&e.format.on===r&&(n[e.fieldId]=Qs(e.format,n[e.fieldId]))},ei=(e,t,r)=>{e.forEach(n=>Zs(n,t,r))},ti=(e,t,r)=>{ei(e.components,t,r)},mu=(e,t,r)=>{e.forEach(n=>ti(n,t,r))},pu=(e,t,r)=>{const n={...t};return ei(e.components,n,r),mu(e.pages,n,r),n},Eu={component:Zs,data:Qs,form:pu,page:ti},Au=(e,t,r,n)=>{if(e===ne.HUB&&t){if(t.format===pe.CYA)return pe.CYA;if(t.components)return He.get(t,r,n)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return pe.TASK},vu={get:Au},Fr="meta",$r="documents",vr=e=>e?.[Fr]?.[$r]||[],yu=(e,t,r,n)=>{const s=n?vr(t):vr(t).filter(a=>a.field!==r);return Array.isArray(e)&&e.forEach(a=>{s.push({...a,field:r})}),{...t?t[Fr]:void 0,[$r]:s}},Tu={setForField:yu,get:vr,name:$r},Su={documents:Tu,name:Fr},Cu=(e,t)=>{if(e?.field){const r=I.Utils.interpolateString(e.field,t);return!!se(t,r)}return!1},or=(e,t)=>{if(e?.value)return e.value;const r=I.Utils.interpolateString(e?.field,t);return se(t,r)},gu=(e,t)=>{if(!e||!t)return null;const r=I.Utils.interpolateString(e.target,t),n=se(t,r),s=or(e,t),i=or(e.cutoff,t),a=or(e.ignore,t);let o=null;return n&&s&&Array.isArray(n)&&n.every((l,u)=>u===i?!1:u===a?!0:l===s||e.key&&se(l,e.key)===s?(o=u,!1):!0),typeof o=="number"?o.toString():o},xu=(e,t,r)=>{let n;if(e?.field){const s=I.Utils.interpolateString(e.field,t);n=se(t,s)}else n=e?.value;n!=null&&e.name&&t[e.name]!==n&&r({target:{name:e.name,value:n}})},Iu=(e,t)=>{if(e?.field){const r=I.Utils.interpolateString(e.field,t);return se(t,r)||null}return e?.value||null},_u=(e,t,r)=>{const n=t;e?.field&&e?.component&&(delete n[e.field],r({target:{name:e.field,value:null,component:e.component}}))},Pu=(e,t)=>{if(e?.condition){const r=e,n=I.Utils.interpolateString(r.field,t),s=se(t,n);switch(r.condition){case"changes":{const i=`${n}LastValue`,a=r[i]||null;return a===null?(r[i]=s,!1):s!==a?(r[i]=s,!0):!1}case"isTruthy":return!!s;case"isFalsy":return!s;default:return!1}}return!0},wu=(e,t)=>{if(e?.fields){let r;return e.fields.find(n=>{const s=I.Utils.interpolateString(n,t),i=se(t,s);return i?(r=i,!0):!1}),r||(e.fallback?I.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},bu=(e,t)=>{if(!e||!t)return null;const r=e.target.split(".");let n="";r.forEach(a=>{if(n!==""&&(n+="."),a.slice(-2)==="[]"){const o=a.slice(0,-2),l=Ks(o,t);n+=`${o}[${l}]`}else n+=a});const s=I.Utils.interpolateString(n,t);return se(t,s)?.length||0},Du=(e,t)=>{const r=I.Utils.interpolateString(e.target,t),n=se(t,r);return n&&Array.isArray(n)?n.some(s=>e.key?se(s,e.key)===e.value:s===e.value):n&&typeof n=="object"?se(n,e.key)===e.value:!1},Ou={checkValueIsTruthy:Cu,getIndexOfMatchingValueIn:gu,doesContainValue:Du,persistValueInFormData:xu,setValueInFormData:Iu,deleteValueInFormData:_u,getLength:bu,getFirstOf:wu},Lu=(e,t,r)=>{const n=Ou[e.function];if(typeof n=="function")return n(e,t,r)},Nu=(e,t,r)=>(e?.operations&&t&&e.operations.forEach(n=>{if(Pu(n.run_when,t)){const s=Lu(n,t,r);if(n.output){const i=I.Utils.interpolateString(n.output,t).replace("[",".").replace("]","");fs(t,i,s)}}}),t),Ru={runPageOperations:Nu},Fu=(e,t,r,n)=>!(e!==t.base&&n[t.check]),$u=(e,t,r)=>{const n=e[r.id]?.[t.base],s=e[r.id]?.[t.check],i=s&&s?.length>0;return!!(n||i)};var nt={exports:{}},Mu=nt.exports,Bn;function Uu(){return Bn||(Bn=1,(function(e,t){(function(r,n){e.exports=n()})(Mu,(function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},n=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,s=/\d/,i=/\d\d/,a=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,l={},u=function(v){return(v=+v)+(v>68?1900:2e3)},d=function(v){return function(x){this[v]=+x}},c=[/[+-]\d\d:?(\d\d)?|Z/,function(v){(this.zone||(this.zone={})).offset=(function(x){if(!x||x==="Z")return 0;var $=x.match(/([+-]|\d\d)/g),S=60*$[1]+(+$[2]||0);return S===0?0:$[0]==="+"?-S:S})(v)}],f=function(v){var x=l[v];return x&&(x.indexOf?x:x.s.concat(x.f))},m=function(v,x){var $,S=l.meridiem;if(S){for(var w=1;w<=24;w+=1)if(v.indexOf(S(w,0,x))>-1){$=w>12;break}}else $=v===(x?"pm":"PM");return $},A={A:[o,function(v){this.afternoon=m(v,!1)}],a:[o,function(v){this.afternoon=m(v,!0)}],Q:[s,function(v){this.month=3*(v-1)+1}],S:[s,function(v){this.milliseconds=100*+v}],SS:[i,function(v){this.milliseconds=10*+v}],SSS:[/\d{3}/,function(v){this.milliseconds=+v}],s:[a,d("seconds")],ss:[a,d("seconds")],m:[a,d("minutes")],mm:[a,d("minutes")],H:[a,d("hours")],h:[a,d("hours")],HH:[a,d("hours")],hh:[a,d("hours")],D:[a,d("day")],DD:[i,d("day")],Do:[o,function(v){var x=l.ordinal,$=v.match(/\d+/);if(this.day=$[0],x)for(var S=1;S<=31;S+=1)x(S).replace(/\[|\]/g,"")===v&&(this.day=S)}],w:[a,d("week")],ww:[i,d("week")],M:[a,d("month")],MM:[i,d("month")],MMM:[o,function(v){var x=f("months"),$=(f("monthsShort")||x.map((function(S){return S.slice(0,3)}))).indexOf(v)+1;if($<1)throw new Error;this.month=$%12||$}],MMMM:[o,function(v){var x=f("months").indexOf(v)+1;if(x<1)throw new Error;this.month=x%12||x}],Y:[/[+-]?\d+/,d("year")],YY:[i,function(v){this.year=u(v)}],YYYY:[/\d{4}/,d("year")],Z:c,ZZ:c};function T(v){var x,$;x=v,$=l&&l.formats;for(var S=(v=x.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(M,C,H){var D=H&&H.toUpperCase();return C||$[H]||r[H]||$[D].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(y,g,_){return g||_.slice(1)}))}))).match(n),w=S.length,b=0;b<w;b+=1){var q=S[b],E=A[q],P=E&&E[0],L=E&&E[1];S[b]=L?{regex:P,parser:L}:q.replace(/^\[|\]$/g,"")}return function(M){for(var C={},H=0,D=0;H<w;H+=1){var y=S[H];if(typeof y=="string")D+=y.length;else{var g=y.regex,_=y.parser,F=M.slice(D),O=g.exec(F)[0];_.call(C,O),M=M.replace(O,"")}}return(function(j){var k=j.afternoon;if(k!==void 0){var p=j.hours;k?p<12&&(j.hours+=12):p===12&&(j.hours=0),delete j.afternoon}})(C),C}}return function(v,x,$){$.p.customParseFormat=!0,v&&v.parseTwoDigitYear&&(u=v.parseTwoDigitYear);var S=x.prototype,w=S.parse;S.parse=function(b){var q=b.date,E=b.utc,P=b.args;this.$u=E;var L=P[1];if(typeof L=="string"){var M=P[2]===!0,C=P[3]===!0,H=M||C,D=P[2];C&&(D=P[2]),l=this.$locale(),!M&&D&&(l=$.Ls[D]),this.$d=(function(F,O,j,k){try{if(["x","X"].indexOf(O)>-1)return new Date((O==="X"?1e3:1)*F);var p=T(O)(F),U=p.year,Y=p.month,G=p.day,V=p.hours,K=p.minutes,re=p.seconds,me=p.milliseconds,he=p.zone,ee=p.week,de=new Date,ue=G||(U||Y?1:de.getDate()),Ae=U||de.getFullYear(),_e=0;U&&!Y||(_e=Y>0?Y-1:de.getMonth());var Pe,Ve=V||0,Ge=K||0,$e=re||0,W=me||0;return he?new Date(Date.UTC(Ae,_e,ue,Ve,Ge,$e,W+60*he.offset*1e3)):j?new Date(Date.UTC(Ae,_e,ue,Ve,Ge,$e,W)):(Pe=new Date(Ae,_e,ue,Ve,Ge,$e,W),ee&&(Pe=k(Pe).week(ee).toDate()),Pe)}catch{return new Date("")}})(q,L,E,$),this.init(),D&&D!==!0&&(this.$L=this.locale(D).$L),H&&q!=this.format(L)&&(this.$d=new Date("")),l={}}else if(L instanceof Array)for(var y=L.length,g=1;g<=y;g+=1){P[1]=L[g-1];var _=$.apply(this,P);if(_.isValid()){this.$d=_.$d,this.$L=_.$L,this.init();break}g===y&&(this.$d=new Date(""))}else w.call(this,b)}}}))})(nt)),nt.exports}var ju=Uu();const Fe=ke(ju),Yu=e=>/^-?\d+$/.test(e),lt=e=>Yu(e)?e.padStart(2,"0"):"",ye=e=>{const[t,r,n]=e.split("-");return`${lt(t)}-${lt(r)}-${n}`},ri=e=>{const[t,r]=e.split(":");return`${lt(t)}:${lt(r)}`},ve="DD-MM-YYYY";J.extend(Fe);const Bu=(e,t)=>{const r=t.date?J(ye(t.date),ve):J().add(t.value,t.unit);return J(ye(e),ve).isAfter(r)};J.extend(Fe);const ku=(e,t)=>{const r=t.date?J(ye(t.date),ve):J().add(t.value,t.unit);return J(ye(e),ve).isBefore(r)};J.extend(Fe);const qu=(e,t,r)=>{const n=r.components?.find(u=>u.fieldId===t.date),s=r.components?.find(u=>u.fieldId===t.time);if(!n||!s||!e)return!1;const i=e[r.fieldId]?.[t.date],a=e[r.fieldId]?.[t.time];if(!i||!a||je(n,e[r.fieldId],e[r.fieldId])||je(s,e[r.fieldId],e[r.fieldId]))return!0;const o=ye(e[r.fieldId]?.[t.date]),l=ri(e[r.fieldId]?.[t.time]);return J(`${o} ${l}`,`${ve} HH:mm`).isBefore(J())};var st={exports:{}},Hu=st.exports,kn;function Vu(){return kn||(kn=1,(function(e,t){(function(r,n){e.exports=n()})(Hu,(function(){return function(r,n,s){n.prototype.isToday=function(){var i="YYYY-MM-DD",a=s();return this.format(i)===a.format(i)}}}))})(st)),st.exports}var Gu=Vu();const Mr=ke(Gu);J.extend(Fe);J.extend(Mr);const Wu=(e,t)=>{const r=J(ye(e),ve).isBefore(J()),n=J(ye(e),ve).isToday();return r&&!n?!0:n&&!!t?.todayAllowed};J.extend(Fe);J.extend(Mr);const Ku=(e,t)=>J(ye(e),ve).isAfter(J())?!0:!!t?.todayAllowed&&J(ye(e),ve).isToday(),zu=(e,t)=>e?e.length>t.value:!0,Ju=(e,t)=>e?e.length<t.value:!0,Xu=(e,t)=>{if(!e)return!0;const r=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(r)>t.value},Qu=(e,t)=>{if(!e)return!0;const r=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(r)<t.value},Zu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,ec=(e,t)=>e?t.array.includes(e):!0,tc=(e,t,r,n)=>{if(!e||!n)return!0;const s=vt(t.collectionPath,n);return!Re(t.collectionPath,n)?.some(o=>o.id===s?!1:t.caseInsensitive&&typeof e=="string"&&typeof o[r.id]=="string"?o[r.id].toUpperCase()===e.toUpperCase():o[r.id]===e)},rc=(e,t,r)=>r.components?.some(n=>!!e[r.id]?.[n.id]),nc=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,sc=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,ic=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!sc.test(t)}return!1},ac=(e,t,r)=>r.components?.reduce((s,i)=>e[r.id]?.[i.id]?Array.isArray(e[r.id][i.id])&&e[r.id][i.id].length===0?s:s+1:s,0)<2,oc={conditionallyPermittedChange:Fu,conditionallyRequired:$u,mustBeAfter:Bu,mustBeBefore:ku,mustBeEarlierDateTime:qu,mustBeGreaterThan:Xu,mustBeInTheFuture:Ku,mustBeInThePast:Wu,mustBeLessThan:Qu,mustBeLongerThan:zu,mustBeNumbersOnly:Zu,mustBeOneOf:ec,mustBeShorterThan:Ju,mustBeUniqueInCollection:tc,mustEnterAtLeastOne:rc,mustHaveLessThanDecimalPlaces:nc,mustNotContainSql:ic,mustSelectOnlyOne:ac},lc=(e,t,r,n)=>{const s=oc[t.function],i=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof s=="function")return s(i,t,r,n)?void 0:t.message},ni=(e,t,r)=>{if(t&&Array.isArray(e.additionalValidation)){let n;return e.additionalValidation.forEach(s=>{n||(n=lc(t,s,e,r))}),n}},ut=(e,t,r)=>{if(!e)return[];const n=r||t,s=ni(e,n);if(s)return{id:e.id,error:s};const i=[];if(Array.isArray(e.components)){const a=t&&e.fieldId?t[e.fieldId]:t;Be(e.components,a).forEach(l=>{const u=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${l.fieldId}`:l.fieldId;i.push(je({...l,full_path:u},a,n))})}return i.flat(1).filter(a=>!!a)},uc=(e,t,r)=>{const n=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((s,i)=>{const a=(e.countOffset||0)+i+1,o=`${e.full_path||e.fieldId}[${i}]`,l={full_path:o,components:e.item.map(u=>{const d={...u,full_path:`${o}.${u.fieldId}`};return u.custom_errors&&Array.isArray(u.custom_errors)&&(d.custom_errors=u.custom_errors.map(c=>({...c,message:I.Utils.interpolateString(i===0&&c.firstOnlyMessage?c.firstOnlyMessage:c.message,{index:a})}))),d})};n.push(ut(l,s,r))}),n.filter(s=>!!s).flat()};var it={exports:{}},cc=it.exports,qn;function dc(){return qn||(qn=1,(function(e,t){(function(r,n){e.exports=n()})(cc,(function(){return function(r,n){n.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}}))})(it)),it.exports}var fc=dc();const hc=ke(fc);J.extend(Fe);J.extend(Mr);J.extend(hc);const mc=(e,t)=>e==="02"?J().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,si=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ye(e),[r,n,s]=t.split("-"),i=parseInt(r,10),a=parseInt(n,10),o=[],l=[];if(s.length===0?(o.push("year"),l.push("Date must include a year")):s.length!==4&&(o.push("year"),l.push("Year must be 4 numbers")),n.length===0?(o.push("month"),l.push("Date must include a month")):(a>12||a<1)&&(o.push("month"),l.push("Month must be between 1 and 12")),r.length===0)o.push("day"),l.push("Date must include a day");else{const u=mc(n,s);(i>u||i<1)&&(o.push("day"),l.push(`Day must be between 1 and ${u}`))}if(o.length>0){const u={};return o.includes("day")&&(u.day=!0),o.includes("month")&&(u.month=!0),o.includes("year")&&(u.year=!0),{message:o.length===1?l[0]:"Enter a valid date",propsInError:u}}return J(t,ve).format(ve)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},pc=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,Ec=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,ii=(e,t="",r=[])=>{if(e){const n=t?t.toLowerCase():"email address";if(typeof e=="string"&&(pc.test(e)||Ec.test(e)))return;if(Array.isArray(r)){const s=r.filter(i=>i.type==="format");if(s&&s.length>0&&s[0].message)return s[0].message}return`Enter ${n} in the correct format, like jane.doe@homeoffice.gov.uk`}},Ac="Invalid files must be deleted",ai=(e,t)=>{if(!e)return;let r=!1;if(e.every(n=>(r=n.error,!r)),r){if(Array.isArray(t)){const n=t.filter(s=>s.type==="invalidFile");if(n&&n.length>0&&n[0].message)return n[0].message}return Ac}},oi=(e,t,r,n)=>{if(e){if(typeof e=="string"){if(new RegExp(r).test(e))return;if(Array.isArray(n)){const i=n.filter(a=>a.type==="pattern");if(i?.[0]?.message)return i[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},li=(e,t,r)=>{let n=!1;if((e||e===!1||e===0)&&(n=!0,typeof e=="string"?n=e.trim().length>0:Array.isArray(e)&&(n=e.length>0)),!n){if(Array.isArray(r)){const i=r.filter(a=>a.type==="required");if(i&&i.length>0&&i[0].message)return i[0].message}return`${t||"Field"} is required`}},ui=(e,t,r,n,s,i=1e3)=>{if(!r||!s&&!t)return;if(s&&!t||t.length>i){if(Array.isArray(n)){const o=n.filter(l=>l.type==="length");if(o&&o.length>0&&o[0].message)return o[0].message}return`${e} must be ${i} characters or less`}},ci=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ri(e),[r,n]=t.split(":"),s=parseInt(r,10),i=parseInt(n,10),a=[],o=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(a.push("invalid"),o.push("Enter a valid time")),r.length===0?(a.push("hour"),o.push("Time must include a hour")):(s>23||s<0)&&(a.push("hour"),o.push("Hour must be between 0 and 23")),n.length===0?(a.push("minute"),o.push("Time must include a minute")):(i>59||i<0)&&(a.push("minute"),o.push("Minute must be between 0 and 59")),a.length>0){const u={};return a.includes("hour")&&(u.hour=!0),a.includes("minute")&&(u.minute=!0),a.includes("invalid")&&(u.invalid=!0),{message:a.length>1?"Enter a valid time":o[0],propsInError:u}}return{message:void 0,propsInError:void 0}},vc=(e,t)=>e?.type==="or"?le.meetsOne(e.conditions,t):le.meetsAll(e.conditions,t),je=(e,t,r)=>{const n=r||t;if(!Ce(e,{...n,...t}))return;if(e.type===R.CONTAINER)return ut(e,t,n);let s,i,o=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===R.COLLECTION_SUMMARY&&(o=Re(e.collectionName,n)),e.required&&(!e.requiredOverrideConditions||!vc(e.requiredOverrideConditions,n))&&(s=li(o,e.label,e.custom_errors)),!s){switch(e.type){case R.COLLECTION:return uc(e,o,n);case R.EMAIL:s=ii(o,e.label,e.custom_errors);break;case R.DATE:case R.TIME:{const l=e.type===R.DATE?si:ci,{message:u,propsInError:d}=l(o);i=d,s=u;break}case R.CHECKBOXES:case R.RADIOS:{let l=[];if(e.data.options?.forEach(u=>{u.nested&&Ye(r[e.id],u)&&(l=l.concat(ut({components:u.nested},r)))}),l.length>0)return l;break}case R.MULTI_FILE:s=ai(o,e.custom_errors);break;case R.TEXT_AREA:s=ui(e.label,o,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!s&&e.pattern&&(s=oi(o,e.label,e.pattern,e.custom_errors)),!s&&e.additionalValidation&&(s=ni(e,o,r),e.type===R.DATE&&s&&(i={day:!0,month:!0,year:!0}))}if(s)return{id:e.full_path||e.id,error:s,properties:i}},yc=(e,t=[])=>{let r=e.formData;if(e.collection){const n=ot.getActiveIndex(e.collection.name,e.formData);n!==null&&(r={...e.formData,...ot.getData(e.collection.name,e.formData)?.[n]})}return mt(e,r)&&Array.isArray(e.components)?e.components.reduce((s,i)=>{if(!Ce(i,r))return s;const o=(t.length>0?t.filter(l=>l.showFor?l.showFor===i.id:l.id===i.id):[]).concat(je(i,r,r));return s.concat(o).flat().map(l=>l&&{...l,error:I.Utils.interpolateString(l.error,r)})},[]).filter(s=>!!s).flat():[]},Tc={component:je,container:ut,email:ii,date:si,multifile:ai,page:yc,regex:oi,required:li,textarea:ui,time:ci},N={CheckYourAnswers:hu,CollectionPage:ot,Component:qe,Condition:le,Container:ht,Data:fe,Format:Eu,FormPage:He,Hub:vu,Meta:Su,Operate:Ru,Validate:Tc,...I.Utils},Sc="hods-form-container",Ur=({container:e,value:t=void 0,formData:r,onChange:n=void 0,wrap:s=!0,onTopLevelChange:i=void 0,...a})=>{const o=({target:c})=>{if(typeof n=="function")if(c.name===N.Meta.name)n({target:c});else{const f={...t,[c.name]:c.value};n({target:{name:e.fieldId,value:f}})}},l=c=>{const f=`${e.full_path||e.fieldId}.${c.fieldId}`;return c.type===R.CONTAINER?N.Container.show({...c,full_path:f},r):N.Component.show({...c,full_path:f},{...r,...se(r,e.full_path)})},u=N.classBuilder(Sc,[],e.className),d=I.Utils.cleanHtmlAttributes(a);return h.jsxs("div",{...d,className:u(),id:e.id,children:[e.title&&h.jsx(I.MediumHeading,{children:e.title}),e.components&&e.components.filter(l).map((c,f)=>{const m=c.type===R.FILE?{}:"",A=t?t[c.fieldId]:m,T=`${e.full_path||e.fieldId}.${c.fieldId}`;return h.jsx(Le,{...a,component:{...c,full_path:T,readonly:!!(e.readonly||c.readonly)},formData:r,value:A||m,wrap:s,onChange:o,onTopLevelChange:i},f)})]})},Cc=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{}},Hn=({group:e})=>{const[t,r]=B.useState({});return B.useEffect(()=>{r(Cc(e))},[e,r]),e?.action?h.jsxs(I.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&h.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},gc=({title:e,size:t="m",classes:r})=>h.jsxs("div",{className:`${r("heading")}`,role:"listitem",children:[t==="s"&&h.jsx(I.SmallHeading,{children:e}),t==="m"&&h.jsx(I.MediumHeading,{children:e})]}),xc=({row:e,classes:t,noChangeAction:r=!1})=>h.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[h.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&h.jsx(I.SmallHeading,{children:e.key}),e.size==="m"&&h.jsx(I.MediumHeading,{children:e.key})]}),h.jsx("td",{className:"heading-action",children:!r&&h.jsx(Lr,{row:{action:e.action}})})]}),Ic="govuk-summary-list",yr=({rows:e,noChangeAction:t=!1,noGroupAction:r=!1,isGroup:n=!1,classBlock:s=Ic,classModifiers:i=[],className:a="",showGroupAction:o=!0,...l})=>{const u=I.Utils.classBuilder(s,i,a),d=I.Utils.cleanHtmlAttributes(l);let c=null;if(n){const f=e.filter(m=>!!m.action);c=f?.length?f[0]:null}return h.jsx("div",{className:"group-of-rows",children:h.jsxs("div",{...d,className:u(),role:"list",children:[e.map(f=>{const m=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?h.jsx(Fs,{title:f.key,classes:u},m):f.type==="heading"?h.jsx(gc,{title:f.key,size:f.size||"s",classes:u},m):f.type==="headingWithAction"?h.jsx(xc,{row:f,classes:u,noChangeAction:t},m):f.type==="action"?t?null:h.jsx("div",{children:h.jsx(Hn,{group:f})},`${m}-actions`):h.jsx(Rs,{row:f,classes:u,showAction:!t},m)}).filter(f=>!!f),o&&n&&!r&&h.jsx("div",{className:"change-group-button",children:h.jsx(Hn,{group:c})})]})})},_c="hods-check-your-answers",Pc="Check your answers",Vn=9,wc=({title:e=Pc,titleSize:t="l",pages:r,actions:n=[],onAction:s,onRowAction:i,hide_page_titles:a=!1,hide_actions:o=!1,hide_title:l=!1,summaryListClassModifiers:u,noChangeAction:d,noGroupAction:c,groups:f,sections:m=[],type:A,hideBlankRows:T=!1,optionalFieldPlaceholder:v})=>{const[x,$]=B.useState([]),[S,w]=B.useState([]),{errors:b}=Oe(),{hooks:q}=ge();B.useEffect(()=>{const y=(F,O)=>N.CheckYourAnswers.getRows(F,i,q.onGetCYARows).map((k,p)=>({...k,value:h.jsx(wr,{value:k.value,component:k.component,formData:F.formData,placeholder:v},`${O}_${p}`)})),_=N.CollectionPage.mergePages(r).map((F,O)=>{const j=y(F,O);return j?.length?{...F,rows:j}:null}).filter(F=>!!F);$(_)},[r,i,$]);const E=a?0:Vn,P=y=>y===x.length-1;B.useEffect(()=>{(()=>{const g=Array.isArray(f)?f.map(_=>_.pageId):[];w(g)})()},[w,f]);const L=q.onGetCYA({title:e,pages:r,actions:n,onAction:s,onRowAction:i,hidePageTitles:a,hideActions:o,hideTitle:l,summaryListClassModifiers:u,noChangeAction:d,noGroupAction:c,groups:f,errors:b,sections:m,type:A});if(L)return L;const M=y=>S.includes(y),C=y=>f?.find(g=>g.pageId===y),H=(y,g)=>{if(!y.cya_link?.singleChangeLink||d)return h.jsxs(h.Fragment,{children:[g==="s"&&h.jsx(I.SmallHeading,{children:N.FormPage.getTitle(y.title,y.formData)}),g==="m"&&h.jsx(I.MediumHeading,{children:N.FormPage.getTitle(y.title,y.formData)})]});const _=pt(!1,y,i);return h.jsxs("div",{className:"heading-with-action",children:[h.jsxs("div",{className:"heading-text",children:[g==="s"&&h.jsx(I.SmallHeading,{children:N.FormPage.getTitle(y.title,y.formData)}),g==="m"&&h.jsx(I.MediumHeading,{children:N.FormPage.getTitle(y.title,y.formData)})]}),h.jsx("div",{className:"heading-action",children:h.jsx(Lr,{row:{action:_}})})]})},D=()=>Array.from(new Set(b.map(g=>g.id))).map(g=>b.find(_=>_.id===g));return h.jsxs("div",{className:_c,children:[e&&!l&&h.jsx(I.Heading,{size:t,children:e},"heading"),b&&b.length>0&&h.jsx(I.ErrorSummary,{errors:D()}),A===ne.TASK_CYA&&x.length>0&&m&&m.map(y=>y.tasks.filter(g=>g.state!==z.TYPES.SKIPPED).map((g,_)=>{const F=x.filter(O=>g.pages.some(j=>j===O.name));return h.jsxs(B.Fragment,{children:[h.jsx(I.MediumHeading,{children:F.length>0&&(g.displayName||g.name)}),F.map((O,j)=>{const k=M(O.id)||d,p=!a&&O.title&&!M(O.id);return h.jsxs(B.Fragment,{children:[p&&H(O,"s"),h.jsx(yr,{rows:O.rows,classModifiers:u,noChangeAction:k,noGroupAction:c,isGroup:M(O.id)})]},j)})]},_)})),A!==ne.TASK_CYA&&x&&x.map((y,g,_)=>{const F=!T||y.collection?y.rows:y.rows.filter(Y=>Y?.value?.props?.value);if(F.length===0)return null;const O=!a&&y.title&&!M(y.id),j=P(g)||M(_[g].id)||_.length>g+1&&M(_[g+1].id)?Vn:E,k=M(y.id)?C(y.id):void 0,p=`govuk-!-margin-bottom-${j}`,U=M(y.id)||d;return h.jsxs(B.Fragment,{children:[O&&H(y,"m"),k&&h.jsx("div",{className:"group-title",children:h.jsx(I.MediumHeading,{children:k.title||N.FormPage.getTitle(y.title,y.formData)})}),h.jsx(yr,{className:p,rows:F,classModifiers:u,noChangeAction:U,noGroupAction:c,isGroup:M(y.id)})]},g)}),!o&&h.jsx(Dr,{actions:n?.filter(y=>N.Component.show(y,r[r.length-1].formData)),onAction:y=>s(y)})]})},bc=Ls,Dc=({page:e,pages:t,onCollectionChange:r=void 0,onAction:n,hashLink:s=!1,classBlock:i=bc,classModifiers:a=[],className:o="",submitting:l=!1})=>{const[u,d]=B.useState({});let c=N.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let m=N.CollectionPage.getActiveIndex(e.collection.name,e.formData);const A=e,T=({target:b})=>{N.CollectionPage.setData(A.collection.name,b.value,e.formData),c=b.value;const q=e.collection.name.split(".").shift();d(E=>({...E,[q]:N.CollectionPage.getData(q,e.formData)}))},v=({target:b})=>{A.formData[b.name]=b.value,d(q=>({...q,[b.name]:b.value}))},x=b=>{T({target:{value:b}}),typeof r=="function"&&r(e.formData)},$=b=>{m=c.length,v({target:{name:`${f}ActiveId`,value:b}})},S=b=>{n(b,u,{})},w=({target:b})=>{if(m===null){const q=ct.v4();$(q),x([...c,{id:q,[b.name]:b.value}])}else x([...c.slice(0,m),{...c[m],[b.name]:b.value},...c.slice(m+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:h.jsx(Or,{page:{...e,formData:{...e.formData,...c[m],[`${f}ActiveIndex`]:m,[`${f}NumberedIndex`]:typeof m=="number"?m+1:null},components:e.components.map(b=>({...b,pageCollection:{...e.collection}}))},pages:t,onAction:S,onWrapperChange:w,onTopLevelChange:v,hashLink:s,classBlock:i,classModifiers:a,className:o,submitting:l})},Oc="hods-task-list",Lc=({state:e=z.TYPES.CANNOT_START_YET})=>{const t=I.Utils.classBuilder(Oc,void 0,void 0),r=z.DETAILS[e]||z.DETAILS.cannotStartYet;return h.jsx(I.Tag,{classModifiers:r.colour,className:t("tag"),children:r.label})},Nc="hods-task-list",Rc=({task:e,onClick:t})=>{const r=I.Utils.classBuilder(Nc,void 0,void 0),[n,s]=B.useState(e.state!==z.TYPES.CANNOT_START_YET),[i,a]=B.useState(e.state);B.useEffect(()=>{s(e.state!==z.TYPES.CANNOT_START_YET),a(e.state)},[e.state,s,a]);const o=e.displayName||e.name;return h.jsxs("li",{className:r("item"),children:[h.jsx("span",{className:r("task-name"),children:n?h.jsx(I.Link,{onClick:()=>t(e),onKeyPress:l=>{l.key==="Enter"&&t(e)},tabIndex:0,children:o}):o}),h.jsx(Lc,{state:i})]})},Fc="hods-task-list",$c="Incomplete form",Mc=({id:e="",refTitle:t,refNumber:r,notes:n={},incompleteTitle:s=$c,showCompletionOverview:i=!0,sections:a,fieldId:o="",onTaskAction:l,classBlock:u=Fc,classModifiers:d=[],className:c="",formData:f={},annotations:m=[],...A})=>{const T=I.Utils.classBuilder(u,d,c),v=I.Utils.cleanHtmlAttributes(A),[x,$]=a.filter(E=>!E.skipped).reduce((E,P)=>[E[0]+(P.tasks?.filter(L=>L.state===z.TYPES.COMPLETE).length??0),E[1]+(P.tasks?.filter(L=>L.state!==z.TYPES.SKIPPED).length??0)],[0,0]),S=`${e}Notes`,{title:w,text:b}=n&&n||{},q=E=>{typeof l=="function"&&l(E)};return h.jsxs("div",{...v,id:e,className:T(),children:[r&&t&&h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:h.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),h.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${r}`})]}),m.length>0&&m.map(E=>h.jsxs("div",{className:T("annotation"),children:[h.jsx("p",{className:`${T("annotation-key")} govuk-body`,children:I.Utils.interpolateString(E.key,f)}),h.jsx("p",{className:`${T("annotation-value")} govuk-body`,children:I.Utils.interpolateString(E.value,f)})]},E.key)),i&&$!==x&&h.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:h.jsx("strong",{className:"tasklist-summary",children:s})}),i&&h.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${x} of ${$} sections`}),w&&b&&Ce(n,f)&&h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:h.jsx("strong",{className:"tasklist-summary",children:I.Utils.interpolateString(w,f)})}),h.jsx(I.TextArea,{id:S,fieldId:S,readOnly:!0,value:I.Utils.interpolateString(b,f)})]}),a.filter(E=>!E.skipped).map((E,P)=>h.jsxs(B.Fragment,{children:[h.jsxs("h2",{className:T("section"),children:[a.length>1?`${P+1}. `:" ",E.name]}),E.label&&h.jsx(I.Hint,{children:E.label}),h.jsx("ol",{className:T("items"),children:E.tasks.filter(L=>L.state!==z.TYPES.SKIPPED).map(L=>h.jsx(Rc,{task:L,onClick:q},`${E.name}-${L.name}`))})]},`${E.name}`))]})},di=(e,t)=>e?.page||t,Uc=(e,t,r)=>{const n=di(e.action,e.pageId);n!==t&&r(n)},jc=(e,t,r,n=void 0)=>{const s=di(e,t);s!==t&&r(s,n)},Yc=(e,t)=>{t(e)},Ee={cyaAction:Uc,navigate:jc,submissionError:Yc},Bc=(e,t,r,n)=>e.validate?e.checkPreexistingErrors&&n.length!==0?!1:r(t).length===0:!0,kc=(e,t)=>t(e).length===0,qc=["radios","checkboxes"],Hc=(e,t)=>{const r=e.split("."),n={};return r.forEach(s=>{n[`${s}ActiveId`]=t[`${s}ActiveId`]}),n};function Vc(e,t){const r=[];return e?.data?.options?.forEach(n=>{!Ye(t,n)&&n.nested&&n.nested.forEach(s=>{r.push(s.id)})}),r}const fi=(e,t)=>{let r=e;if(t.components.forEach(n=>{if(!qc.includes(n.type))return;Vc(n,r[n.id]).forEach(i=>{delete r[i]})}),t.collection){r={...Hc(t.collection.name,t.formData),...r};const n=Re(t.collection.name,r);if(n){const s=vt(t.collection.name,r),i=n.map(a=>a.id===s?fi(a,{...t,collection:void 0}):a);Rr(t.collection.name,i,r)}}return r},Gc=(e,t,r)=>{if(e===ae.HUB&&r===pe.CYA)return{title:""};if(e===ae.CYA)return{};const n=t?.find(s=>s.id===e);if(n?.type===ae.PARTIAL_CYA){const s=N.FormPage.applyConditionalProperties(n);return{title:s.title,hideChangeActions:s.hideChangeActions,hideGroupActions:s.hideGroupActions}}},hi=(e,t,r)=>{if(e)return e===ae.HUB?r===pe.CYA||r===pe.TASK?void 0:r:t.find(n=>n.id===e)},Wc=(e,t,r)=>({pageId:e,cya:Gc(e,t,r),page:hi(e,t,r)}),Gn=(e,t)=>e.slice(0,e.findIndex(r=>r?.id===t)),Kc=(e,t,r)=>e.page?.type===ae.PARTIAL_CYA?Gn(r||t,e.pageId):r||t,Wn=(e,t,r,n,s)=>{if(!t&&s===ne.FORM_WITH_TASK){if(n?.formStatus?.taskPage){const a=r.find(o=>o.id===n.formStatus.taskPage);return a?.type==="pre-task-list"?a.id:ae.HUB}return r.length>0?r[0].id:void 0}let i;return e?.pages?.forEach(a=>{He.show({show_when:a.show_when},n)&&(i=a.pageId)}),i||e?.page||ae.HUB},mi=(e,t,r)=>{let n=e.findIndex(i=>i.id===t)+1,s=e[n];for(;s&&!He.show(s,r);)n+=1,s=e[n];return s?.id||void 0},zc=(e,t,r)=>mi(e,t,r)||ae.CYA,Jc=e=>e.length>0?e[0].id:void 0,Tr=(e,t,r,n,s)=>{if(n){if(n.type===X.TYPES.NAVIGATE)return t.find(i=>i.id===n.page)?n.page:void 0;if(n.type===X.TYPES.SAVE_AND_RETURN)return e===ne.HUB?ae.HUB:void 0}switch(e){case ne.HUB:return Wn(n);case ne.CYA:return zc(t,r,s);case ne.FORM_WITH_TASK:case ne.TASK:return Wn(n,r,t,s,e);case ne.WIZARD:return mi(t,r,s);default:return Jc(t)}},Xc=(e,t,r,n,s,i,a,o)=>{if(e===ne.TASK||e===ne.FORM_WITH_TASK){const l=s.formStatus||{};return l.tasks=l.tasks||{},l.tasks[i.name]=l.tasks[i.name]||{},r===(ae.CYA||"submitForm")&&a?l.tasks[i.name].complete=!0:i.name?n?.type===X.TYPES.SAVE_AND_NAVIGATE?l.tasks[i.name]={complete:!1,currentPage:Tr(e,t,r,n,s)}:i.pages?.includes(r)&&(l.tasks[i.name]={complete:!!n?.complete,currentPage:r}):o&&o.forEach(u=>{u.tasks.forEach(d=>{const c=d.pages[d.pages.length-1];(c===r||c.id===r)&&a&&d?.type==="pre-task-list"?l.tasks[d.name]={complete:a,currentPage:r}:d.pages.includes(r)&&d?.type==="pre-task-list"&&(l.tasks[d.name]={complete:!1,currentPage:r})})}),l.taskPage=l.tasks[i.name].currentPage,l}return n?.type===X.TYPES.SAVE_AND_RETURN?{page:r}:{page:Tr(e,t,r,n,s)}},Qc=({complete:e,currentPage:t},r=z.TYPES.NOT_STARTED)=>e?z.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?z.TYPES.IN_PROGRESS:r,Zc=(e,t,r=!1)=>t.reduce((n,s)=>{const i=e[s];return r&&i?.state===z.TYPES.SKIPPED?n:n&&i?.complete},!0),pi=(e,t)=>{const r=e[t-1].state;return r===z.TYPES.COMPLETE?!0:r===z.TYPES.SKIPPED?t-1===0?!0:pi(e,t-1):!1},ed=(e,t,r,n,s=!1,i=!0)=>{if(n[e.name])return Qc(n[e.name],e.state);if(s)return e.depends_on&&!Zc(n,e.depends_on,e.ignoreSkipped)?z.TYPES.CANNOT_START_YET:z.TYPES.NOT_STARTED;let a=i;return t&&(a=pi(r,t)),a?z.TYPES.NOT_STARTED:z.TYPES.CANNOT_START_YET},td=(e,t,r,n)=>{const s=e.tasks.map(i=>({...i}));return s.filter(i=>i.state!==z.TYPES.SKIPPED).forEach((i,a)=>{const o=i;o.state=ed(o,a,s,t,r,n)}),s},Ei=(e,t)=>{const r=e[t-1]?.tasks.slice(-1)[0]?.state;return r===z.TYPES.COMPLETE?!0:r===z.TYPES.SKIPPED?t-1===0?!0:Ei(e,t-1):!1},rd=(e,t,r=!1,n=null)=>{const s=e.map(a=>{const o=a.show_when?[a.show_when].flat():[];return n&&!N.Condition.meetsAll(o,n)?{...a,skipped:!0,tasks:a.tasks.map(l=>({...l,state:z.TYPES.SKIPPED}))}:{...a}});s.forEach(a=>{const o=a;o.tasks=o.tasks.map(l=>{const u=l.show_when?[l.show_when].flat():[];return n&&!N.Condition.meetsAll(u,n)?{...l,state:z.TYPES.SKIPPED}:{...l}})});const i={...t};return s.forEach(a=>{a.tasks.filter(o=>o.state===z.TYPES.SKIPPED).forEach(o=>{i[o.name]={...i[o.name],state:z.TYPES.SKIPPED}})}),s.forEach((a,o)=>{const l=a,u=o===0||Ei(s,o);l.tasks=td(l,i,r,u)}),s},nd=(e,t,r)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)},be=(e,t)=>{if(Array.isArray(e))for(let s=0;s<e.length;s+=1)be(e[s],t);const r=t.split(".");let n=e;for(let s=0;s<r.length-1;s+=1)if(n=n[r[s]],n===void 0)return;n[r[r.length-1]]&&delete n[r[r.length-1]]},Ai=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},jr=(e,t)=>{const r=Ai(e);return r?`${r}.${t}`:t},sd=e=>{for(let t=e.length-1;t>=0;t-=1){const r=e[t];Object.keys(r).length===1&&Object.keys(r)[0]==="id"&&e.splice(t,1)}},id=e=>{const t=(r,n)=>(typeof r=="object"&&r!==null&&(Array.isArray(r)?r.forEach(s=>{t(s,n)}):Object.keys(r).forEach(s=>{s==="field"&&n.push(r[s]),t(r[s],n)})),n);return e.show_when?new Set(t(e.show_when,[])||[]):null},ad=(e,t)=>{const r=e.split(".");for(let n=r.length;n>0;n-=1){const s=r.slice(0,n).join("."),i=t.get(s);if(i)return i}return null},Me=(e,t)=>e.show_when?e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t):!0,vi=(e,t,r)=>{const n=t.get(e.use)??r.get(e.use)??e,s=JSON.parse(JSON.stringify(n));return e.use&&e.show_when&&(s.show_when=e.show_when),s},od=(e,t,r)=>{const{meta:{documents:n}}=r,s=t[e.fieldId];if(!n||!s)return;const i=Array.isArray(s)?s:[s];for(let a=i.length-1;a>=0;a-=1){const o=n.findIndex(l=>l.url===i[a].url);o!==-1&&n.splice(o,1)}},Sr=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):Sr(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]):Sr(e[t])})},yi=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(r=>{r.nested?.forEach(t)})},ld=(e,t,r,n)=>{if(n[t]>1)n[t]-=1;else{if(r.preserveInPayload)return;be(e,t),yi(r,s=>{const i=jr(t,s.fieldId);n[i]>1?n[i]-=1:be(e,i)})}},ud=(e,t,r,n)=>{t.forEach(s=>{if(!e.has(s.fieldId)){if(s.type==="multifile"&&od(s,r,n),s.preserveInPayload)return;be(r,s.fieldId),yi(s,i=>{const a=jr(s.fieldId,i.fieldId);e.has(a)||be(r,a)})}})},Kn=e=>Array.isArray(e)?e:[e],cd=(e,t,r,n)=>{const s=new Map,i={},a=[],o=new Map,l=(u,d,c)=>{d.fieldId&&(c=c?`${c}.${d.fieldId}`:d.fieldId,i[c]=(i[c]||0)+1,d.path=c,u.show_when&&(d.show_when=d.show_when?[...Kn(u.show_when),...Kn(d.show_when)]:u.show_when),nd(c,d,s),d.components?d.components.forEach(f=>{l(u,f,c)}):d?.data?.options&&d?.data?.options?.forEach(f=>{if(f.nested){const m=!Ye(se(n,c),f),A=f.show_when;f.nested.forEach(T=>{m&&a.push(jr(c,T.fieldId)),A&&(T.show_when=A),l(u,T,Ai(c))})}}))};return e?.forEach(u=>{u.childPages?o.set(u.collection.name,u):u.components?.forEach(d=>{const c=vi(d,t,r);l(u,c,null)})}),a.forEach(u=>{i[u]>1?i[u]-=1:be(n,u)}),{allComponents:s,componentsToKeep:i,allCollections:o}},dd=e=>{const t=new Map;return e?.forEach(r=>{r?.forEach(n=>{if(!n.fieldId)return;const s=id(n);if(s)if(t.has(n.path)){const i=t.get(n.path);s.forEach(a=>i.add(a))}else t.set(n.path,new Set(s))})}),t},fd=(e,t,r,n,s,i)=>{const a=(l,u,d)=>{if(l.has(u))return;l.add(u),d.get(u.path)?.forEach(f=>{const m=ad(f,t);if(m)m.forEach(A=>{l.has(A)||a(l,A,d)});else{const A=/([a-zA-Z_$][\w$]*)\[\d+\]/,T=f.match(A);if(T){const v=T[1],x=n.get(v);x&&x.childPages?.forEach($=>{if($.show_when){const S=JSON.stringify($.show_when),w=`It is not possible to reliably clean hidden data when a component is dependent on a
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),C=require("@ukhomeoffice/cop-react-components"),j=require("react"),Ot=require("uuid"),ke={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},no="alert",ro="autocomplete",so="calculation",oo="checkboxes",io="collection",ao="collection-summary",lo="container",co="date",uo="details",fo="email",ho="file",mo="heading",po="html",Eo="inset-text",Ao="list",yo="multifile",So="paragraph",To="phone-number",go="radios",Co="select",wo="text",bo="textarea",_o="time",xo="warning",N={ALERT:no,AUTOCOMPLETE:ro,CALCULATION:so,CHECKBOXES:oo,COLLECTION:io,COLLECTION_SUMMARY:ao,CONTAINER:lo,DATE:co,DETAILS:uo,EMAIL:fo,FILE:ho,HEADING:mo,HTML:po,INSET_TEXT:Eo,LIST:Ao,MULTI_FILE:yo,PARAGRAPH:So,PHONE_NUMBER:To,RADIOS:go,SELECT:Co,TEXT:wo,TEXT_AREA:bo,TIME:_o,WARNING:xo},Io="blur",Po="submit",vo="cancel",Ie={BLUR:Io,SUBMIT:Po,CANCEL:vo},Oo="cya",Do="hub",No="partial-cya",ie={CYA:Oo,HUB:Do,PARTIAL_CYA:No},Ro="cya",Lo="form",Fo="form-with-task-list",$o="hub-and-spoke",Mo="task-list",jo="task-list-cya",Uo="wizard",se={CYA:Ro,FORM:Lo,FORM_WITH_TASK:Fo,HUB:$o,TASK:Mo,TASK_CYA:jo,WIZARD:Uo},ko="CYA",Yo="TASK",Ae={CYA:ko,TASK:Yo},Jt="cancel",gr="collectionAdd",Cr="collectionDuplicate",wr="collectionRemove",br="navigate",Xt="saveAndContinue",Qt="saveAndNavigate",Zt="saveAndReturn",en="submit",pt={CANCEL:Jt,COLLECTION_ADD:gr,COLLECTION_DUPLICATE:Cr,COLLECTION_REMOVE:wr,NAVIGATE:br,SAVE_AND_CONTINUE:Xt,SAVE_AND_NAVIGATE:Qt,SAVE_AND_RETURN:Zt,SUBMIT:en},Bo={[Jt]:{type:Jt,validate:!1,label:"Cancel",classModifiers:"secondary"},[gr]:void 0,[Cr]:void 0,[wr]:void 0,[br]:void 0,[Xt]:{type:Xt,validate:!0,label:"Save and continue"},[Qt]:{type:Qt,validate:!0,label:"Save and continue"},[Zt]:{type:Zt,validate:!1,label:"Save and return later",classModifiers:"secondary"},[en]:{type:en,validate:!0}},Q={TYPES:pt,DEFAULTS:Bo},_r="complete",xr="inProgress",Ir="notStarted",Pr="cannotStartYet",vr="skipped",Ho={COMPLETE:_r,IN_PROGRESS:xr,NOT_STARTED:Ir,CANNOT_START_YET:Pr,SKIPPED:vr},Vo={[_r]:{label:"Completed",colour:"dark-blue"},[xr]:{label:"In Progress",colour:"white"},[Ir]:{label:"Not Started",colour:"dark-grey"},[Pr]:{label:"Cannot Start Yet",colour:"dark-grey"},[vr]:{label:"Skipped",colour:"dark-grey"}},J={TYPES:Ho,DETAILS:Vo},qo={CollectionLabels:ke,ComponentTypes:N,EventTypes:Ie,FormPages:ie,FormTypes:se,HubFormats:Ae,PageAction:Q,TaskStates:J},Or=e=>{try{const t=Go(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},Go=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return ct(e,(n,r)=>n*r);case"divide":return ct(e,(n,r)=>n/r);case"plus":return ct(e,(n,r)=>n+r);case"minus":return ct(e,(n,r)=>n-r);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},ct=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return Ko(n.map(r=>Wo(r,e.formData)).reduce((r,s,o)=>o===0?s:t(r,s),0),e)},Ko=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const r=Math.pow(10,n);return Math.round((e+Number.EPSILON)*r)/r},Wo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const r=n[0],s=e[r];switch(r){case"field":{const o=zo(s,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(s);case"formula":return Or({...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")},zo=(e,t)=>C.Utils.interpolateString("${"+e+"}",t),Jo=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return he.getSource(t,n)}return e.value},ut=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},pn=(e,t,n)=>{if(e&&typeof e=="object"){const r=Jo(e,n);switch(e.op){case"=":case"eq":return r===t;case"!=":case"<>":case"ne":case"neq":return r!==t;case"in":return Array.isArray(r)?r.includes(t):!1;case"nin":return Array.isArray(r)?r.includes(t)===!1:!0;case"<":{const s=ut(t),o=ut(r);return s!=null&&o!=null&&s<o}case">":{const s=ut(t),o=ut(r);return s!=null&&o!=null&&s>o}case"contains":return t?.toString().toLowerCase().includes(r);case"!contains":return!t?.toString().toLowerCase().includes(r);case"includes":return Array.isArray(t)?t.includes(r):!1;case"!includes":return Array.isArray(t)?!t.includes(r):!0;case"includesObjectProp":return Array.isArray(t)?t.some(s=>s[e.key]===r):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(s=>s[e.key]===r):!0;case"includesAllOf":return Array.isArray(t)?r.every(s=>t.includes(s)):!1;case"!includesAllOf":return Array.isArray(t)?!r.every(s=>t.includes(s)):!0;default:return!1}}return!0},Xo=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(r=>{const s=he.getDataPath(r.field,n);return{...r,field:s}})}},Qo=e=>Array.isArray(e)||!!(e.field&&e.op),Dr=e=>e&&!Qo(e)?Xo(e):e,Nr=(e,t,n="and")=>{const r=Array.isArray(e)?e:[e],s=o=>{if(Array.isArray(o.conditions))return Nr(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?C.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,a=he.getSource(t,i);return pn(o,a,t)};return n==="and"?r.every(s):r.some(s)},Me=(e,t)=>{const n=Dr(e);return n?Nr(n,t):!0},Zo=(e,t)=>{const n=Dr(e);return n?(Array.isArray(n)?n:[n]).some(s=>{const o=he.getSource(t,s.field);return pn(s,o,t)}):!0},le={meetsOne:Zo,meetsAll:Me,met:pn},ei=(e,t)=>{const n=e;return t.forEach((r,s)=>{if(r.refdata_match){const o=r.refdata_match,i=Object.keys(o)[0],a=e.findIndex(l=>l[i]===o[i]);a>=0&&(n[a]={...e[a],nested:r.nested})}r.combineWithRefdata&&!n.includes(r)&&(s>0&&typeof t[s-1]=="string"&&n.push(t[s-1]),n.push(r))}),n},dt=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?le.meetsOne(n,e.formData):le.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:C.Utils.interpolateString(n.value,e.formData),label:C.Utils.interpolateString(n.label,e.formData),hint:C.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),ti=(e,t)=>{const n=e.formData[t].map(r=>({value:C.Utils.interpolateString(e.item.value,r),label:C.Utils.interpolateString(e.item.label,r),hint:C.Utils.interpolateString(e.item.hint,r)}));return e.data.options?[...n,...e.data.options]:n},Rr=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=ti(e,e?.data?.collection);return t(dt(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=ei(e.options,e.data.options);return t(dt(e,n))}if(e.options)return t(dt(e,e.options));if(e.data&&e.data.options)return t(dt(e,e.data.options))}return t([])},ni=6e3,ri=(e,t)=>{const n=e===0;let r=0;return n&&(r=1),n||(r=t.substring(e-1).startsWith(" ")?2:3),r},Mn=e=>e===0,Lr=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),si=(e,t)=>{let n=0;return e.synonyms.some(s=>Lr(s,t))&&(n=4),n},oi=(e,t,n)=>{let r=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return Lr(i,n)})&&(r=5),r},ii=(e,t,n,r)=>{const s=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=s.indexOf(t);return i!==-1&&(o=ri(i,s)),Mn(o)&&e.synonyms&&(o=si(e,t)),Mn(o)&&r.item?.extraFieldsToSearch&&(o=oi(r,e,t)),{score:o,label:s,option:e}},ai=(e,t,n)=>(r,s)=>{const o=ii(s,e,t,n);return o.score>0&&r.push(o),r},li=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),ci=e=>{let t=[];Rr(e,r=>{t=r});const n=e?.item?C.Utils.itemLabel(e.item):null;return(r,s)=>{const o=typeof r=="string"?r.toLowerCase():"",i=t.reduce(ai(o,n,e),[]).sort(li).slice(0,ni).map(a=>a.option);s(i)}},Re=".",En="/",Fr=`${Re}${Re}`,jn=`${Re}${En}`,tn=e=>e.join(Re),nn=(e,t=Re)=>e.split(t),ui=e=>e===Fr,di=e=>[Re,Fr].indexOf(e)>-1,fi=e=>e&&e.indexOf(Re)===0,hi=e=>e.indexOf(jn)===0?e:`${jn}${e}`,mi=(e,t)=>{const n=hi(t),r=nn(n,En).filter(ui).length+1,s=e?nn(e):[];return r>=s.length?"":tn(s.slice(0,-r))},pi=(e,t)=>{const n=nn(t,En).filter(r=>!di(r));return e?`${e}.${tn(n)}`:tn(n)},Ei=(e,t)=>fi(e)?pi(mi(t,e),e):e,Ai=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},yi=e=>e.includes("["),Si=e=>e.replace("]","").split("["),oe=(e,t)=>{if(t)return t.split(".").reduce((n,r)=>{if(n&&yi(r)){const[s,o]=Si(r);return Ai(n[s],o)}return n?n[r]:void 0},e)},Ti=(e,t)=>{let n=e.value||e.id,r=e.label||e.name;return t&&(n=e[t.value]||n,r=e[t.label]||r),{value:n?.toString(),label:r}},gi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...Ti(n,t)}):[],Ci=(e,t)=>{const n=Object.keys(e).filter(s=>!(s in t)),r=e;n.forEach(s=>delete r[s])},$r=(e,t,n,r=!1)=>{if(t&&e){const s=r?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=s.pop();let i=e;s.forEach(a=>{(!i[a]||typeof i[a]!="object")&&(i[a]={}),i=i[a]}),i[o]=n}return e},Mr=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=oe(n,e.source.field))},wi=(e,t)=>{e.forEach(n=>Mr(n,t))},bi=(e,t)=>{e.forEach(n=>{n.components.filter(r=>!r.use).forEach(r=>Mr(r,t))})},_i=(e,t,n)=>{const r={...n};return wi(t,r),bi(e,r),r},xi=(e,t)=>({...e,components:jr(e.components,t)}),Ii=(e,t)=>({...e,item:jr(e.item,t)}),jr=(e,t)=>e.map(n=>Ur(n,t)),Ur=(e,t)=>{if(e){if(e.type===N.CONTAINER)return xi(e,t);if(e.type===N.COLLECTION)return Ii(e,t);if(e.type===N.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:C.Utils.interpolateString(e.data.url,t)}}}return e},he={applyFormula:Or,getAutocompleteSource:ci,getDataPath:Ei,getOptions:Rr,getSource:oe,refData:{setupUrl:Ur,toOptions:gi},deleteValues:Ci,setDataItem:$r,setupForm:_i},Qe=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,ve=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t),Ze=(e,t)=>{let n=[];return e?.forEach(r=>{n.push(r),ve(r,t)&&r.data?.options?.forEach(s=>{const o=t?.[r.id]||he.getSource(t,r.full_path);Array.isArray(s.nested)&&Qe(o,s)&&ve(s,t)&&(n=n.concat(s.nested))})}),n},Un=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],re=(e,t=[])=>{const n=Array.isArray(t)?[...Un,...t]:Un;return e&&typeof e=="object"?Object.keys(e).reduce((r,s)=>n.includes(s)?r:{...r,[s]:e[s]},{}):{}};function kr(e,t){return function(){return e.apply(t,arguments)}}const{toString:Pi}=Object.prototype,{getPrototypeOf:An}=Object,{iterator:Dt,toStringTag:Yr}=Symbol,Nt=(e=>t=>{const n=Pi.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),be=e=>(e=e.toLowerCase(),t=>Nt(t)===e),Rt=e=>t=>typeof t===e,{isArray:Ye}=Array,je=Rt("undefined");function et(e){return e!==null&&!je(e)&&e.constructor!==null&&!je(e.constructor)&&pe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Br=be("ArrayBuffer");function vi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Br(e.buffer),t}const Oi=Rt("string"),pe=Rt("function"),Hr=Rt("number"),tt=e=>e!==null&&typeof e=="object",Di=e=>e===!0||e===!1,Et=e=>{if(Nt(e)!=="object")return!1;const t=An(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Yr in e)&&!(Dt in e)},Ni=e=>{if(!tt(e)||et(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ri=be("Date"),Li=be("File"),Fi=be("Blob"),$i=be("FileList"),Mi=e=>tt(e)&&pe(e.pipe),ji=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||pe(e.append)&&((t=Nt(e))==="formdata"||t==="object"&&pe(e.toString)&&e.toString()==="[object FormData]"))},Ui=be("URLSearchParams"),[ki,Yi,Bi,Hi]=["ReadableStream","Request","Response","Headers"].map(be),Vi=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 r,s;if(typeof e!="object"&&(e=[e]),Ye(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(et(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let a;for(r=0;r<i;r++)a=o[r],t.call(null,e[a],a,e)}}function Vr(e,t){if(et(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const De=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qr=e=>!je(e)&&e!==De;function rn(){const{caseless:e,skipUndefined:t}=qr(this)&&this||{},n={},r=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&Vr(n,o)||o;Et(n[i])&&Et(s)?n[i]=rn(n[i],s):Et(s)?n[i]=rn({},s):Ye(s)?n[i]=s.slice():(!t||!je(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&nt(arguments[s],r);return n}const qi=(e,t,n,{allOwnKeys:r}={})=>(nt(t,(s,o)=>{n&&pe(s)?Object.defineProperty(e,o,{value:kr(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Gi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ki=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),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)},Wi=(e,t,n,r)=>{let s,o,i;const a={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&An(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},zi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Ji=e=>{if(!e)return null;if(Ye(e))return e;let t=e.length;if(!Hr(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Xi=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&An(Uint8Array)),Qi=(e,t)=>{const r=(e&&e[Dt]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zi=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ea=be("HTMLFormElement"),ta=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),kn=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),na=be("RegExp"),Gr=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};nt(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},ra=e=>{Gr(e,(t,n)=>{if(pe(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(pe(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},sa=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Ye(e)?r(e):r(String(e).split(t)),n},oa=()=>{},ia=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function aa(e){return!!(e&&pe(e.append)&&e[Yr]==="FormData"&&e[Dt])}const la=e=>{const t=new Array(10),n=(r,s)=>{if(tt(r)){if(t.indexOf(r)>=0)return;if(et(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Ye(r)?[]:{};return nt(r,(i,a)=>{const l=n(i,s+1);!je(l)&&(o[a]=l)}),t[s]=void 0,o}}return r};return n(e,0)},ca=be("AsyncFunction"),ua=e=>e&&(tt(e)||pe(e))&&pe(e.then)&&pe(e.catch),Kr=((e,t)=>e?setImmediate:t?((n,r)=>(De.addEventListener("message",({source:s,data:o})=>{s===De&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),De.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",pe(De.postMessage)),da=typeof queueMicrotask<"u"?queueMicrotask.bind(De):typeof process<"u"&&process.nextTick||Kr,fa=e=>e!=null&&pe(e[Dt]),A={isArray:Ye,isArrayBuffer:Br,isBuffer:et,isFormData:ji,isArrayBufferView:vi,isString:Oi,isNumber:Hr,isBoolean:Di,isObject:tt,isPlainObject:Et,isEmptyObject:Ni,isReadableStream:ki,isRequest:Yi,isResponse:Bi,isHeaders:Hi,isUndefined:je,isDate:Ri,isFile:Li,isBlob:Fi,isRegExp:na,isFunction:pe,isStream:Mi,isURLSearchParams:Ui,isTypedArray:Xi,isFileList:$i,forEach:nt,merge:rn,extend:qi,trim:Vi,stripBOM:Gi,inherits:Ki,toFlatObject:Wi,kindOf:Nt,kindOfTest:be,endsWith:zi,toArray:Ji,forEachEntry:Qi,matchAll:Zi,isHTMLForm:ea,hasOwnProperty:kn,hasOwnProp:kn,reduceDescriptors:Gr,freezeMethods:ra,toObjectSet:sa,toCamelCase:ta,noop:oa,toFiniteNumber:ia,findKey:Vr,global:De,isContextDefined:qr,isSpecCompliantForm:aa,toJSONObject:la,isAsyncFn:ca,isThenable:ua,setImmediate:Kr,asap:da,isIterable:fa};let V=class Wr extends Error{static from(t,n,r,s,o,i){const a=new Wr(t.message,n||t.code,r,s,o);return a.cause=t,a.name=t.name,i&&Object.assign(a,i),a}constructor(t,n,r,s,o){super(t),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),s&&(this.request=s),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:A.toJSONObject(this.config),code:this.code,status:this.status}}};V.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";V.ERR_BAD_OPTION="ERR_BAD_OPTION";V.ECONNABORTED="ECONNABORTED";V.ETIMEDOUT="ETIMEDOUT";V.ERR_NETWORK="ERR_NETWORK";V.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";V.ERR_DEPRECATED="ERR_DEPRECATED";V.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";V.ERR_BAD_REQUEST="ERR_BAD_REQUEST";V.ERR_CANCELED="ERR_CANCELED";V.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";V.ERR_INVALID_URL="ERR_INVALID_URL";const ha=null;function sn(e){return A.isPlainObject(e)||A.isArray(e)}function zr(e){return A.endsWith(e,"[]")?e.slice(0,-2):e}function Yn(e,t,n){return e?e.concat(t).map(function(s,o){return s=zr(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function ma(e){return A.isArray(e)&&!e.some(sn)}const pa=A.toFlatObject(A,{},null,function(t){return/^is[A-Z]/.test(t)});function Lt(e,t,n){if(!A.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=A.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,p){return!A.isUndefined(p[E])});const r=n.metaTokens,s=n.visitor||u,o=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&A.isSpecCompliantForm(t);if(!A.isFunction(s))throw new TypeError("visitor must be a function");function c(m){if(m===null)return"";if(A.isDate(m))return m.toISOString();if(A.isBoolean(m))return m.toString();if(!l&&A.isBlob(m))throw new V("Blob is not supported. Use a Buffer instead.");return A.isArrayBuffer(m)||A.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function u(m,E,p){let _=m;if(m&&!p&&typeof m=="object"){if(A.endsWith(E,"{}"))E=r?E:E.slice(0,-2),m=JSON.stringify(m);else if(A.isArray(m)&&ma(m)||(A.isFileList(m)||A.endsWith(E,"[]"))&&(_=A.toArray(m)))return E=zr(E),_.forEach(function(T,P){!(A.isUndefined(T)||T===null)&&t.append(i===!0?Yn([E],P,o):i===null?E:E+"[]",c(T))}),!1}return sn(m)?!0:(t.append(Yn(p,E,o),c(m)),!1)}const f=[],h=Object.assign(pa,{defaultVisitor:u,convertValue:c,isVisitable:sn});function y(m,E){if(!A.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(m),A.forEach(m,function(_,U){(!(A.isUndefined(_)||_===null)&&s.call(t,_,A.isString(U)?U.trim():U,E,h))===!0&&y(_,E?E.concat(U):[U])}),f.pop()}}if(!A.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Bn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function yn(e,t){this._pairs=[],e&&Lt(e,this,t)}const Jr=yn.prototype;Jr.append=function(t,n){this._pairs.push([t,n])};Jr.toString=function(t){const n=t?function(r){return t.call(this,r,Bn)}:Bn;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Ea(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Xr(e,t,n){if(!t)return e;const r=n&&n.encode||Ea,s=A.isFunction(n)?{serialize:n}:n,o=s&&s.serialize;let i;if(o?i=o(t,s):i=A.isURLSearchParams(t)?t.toString():new yn(t,s).toString(r),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){A.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Sn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Aa=typeof URLSearchParams<"u"?URLSearchParams:yn,ya=typeof FormData<"u"?FormData:null,Sa=typeof Blob<"u"?Blob:null,Ta={isBrowser:!0,classes:{URLSearchParams:Aa,FormData:ya,Blob:Sa},protocols:["http","https","file","blob","url","data"]},Tn=typeof window<"u"&&typeof document<"u",on=typeof navigator=="object"&&navigator||void 0,ga=Tn&&(!on||["ReactNative","NativeScript","NS"].indexOf(on.product)<0),Ca=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wa=Tn&&window.location.href||"http://localhost",ba=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Tn,hasStandardBrowserEnv:ga,hasStandardBrowserWebWorkerEnv:Ca,navigator:on,origin:wa},Symbol.toStringTag,{value:"Module"})),de={...ba,...Ta};function _a(e,t){return Lt(e,new de.classes.URLSearchParams,{visitor:function(n,r,s,o){return de.isNode&&A.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function xa(e){return A.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ia(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function Qr(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=o>=n.length;return i=!i&&A.isArray(s)?s.length:i,l?(A.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!a):((!s[i]||!A.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&A.isArray(s[i])&&(s[i]=Ia(s[i])),!a)}if(A.isFormData(e)&&A.isFunction(e.entries)){const n={};return A.forEachEntry(e,(r,s)=>{t(xa(r),s,n,0)}),n}return null}function Pa(e,t,n){if(A.isString(e))try{return(t||JSON.parse)(e),A.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const rt={transitional:Sn,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=A.isObject(t);if(o&&A.isHTMLForm(t)&&(t=new FormData(t)),A.isFormData(t))return s?JSON.stringify(Qr(t)):t;if(A.isArrayBuffer(t)||A.isBuffer(t)||A.isStream(t)||A.isFile(t)||A.isBlob(t)||A.isReadableStream(t))return t;if(A.isArrayBufferView(t))return t.buffer;if(A.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return _a(t,this.formSerializer).toString();if((a=A.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lt(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Pa(t)):t}],transformResponse:[function(t){const n=this.transitional||rt.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(A.isResponse(t)||A.isReadableStream(t))return t;if(t&&A.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?V.from(a,V.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:de.classes.FormData,Blob:de.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};A.forEach(["delete","get","head","post","put","patch"],e=>{rt.headers[e]={}});const va=A.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"]),Oa=e=>{const t={};let n,r,s;return e&&e.split(`
2
+ `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&va[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Vn=Symbol("internals");function We(e){return e&&String(e).trim().toLowerCase()}function At(e){return e===!1||e==null?e:A.isArray(e)?e.map(At):String(e)}function Da(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Na=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ht(e,t,n,r,s){if(A.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!A.isString(t)){if(A.isString(r))return t.indexOf(r)!==-1;if(A.isRegExp(r))return r.test(t)}}function Ra(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function La(e,t){const n=A.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let Ee=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(a,l,c){const u=We(l);if(!u)throw new Error("header name must be a non-empty string");const f=A.findKey(s,u);(!f||s[f]===void 0||c===!0||c===void 0&&s[f]!==!1)&&(s[f||l]=At(a))}const i=(a,l)=>A.forEach(a,(c,u)=>o(c,u,l));if(A.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(A.isString(t)&&(t=t.trim())&&!Na(t))i(Oa(t),n);else if(A.isObject(t)&&A.isIterable(t)){let a={},l,c;for(const u of t){if(!A.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?A.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}i(a,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=We(t),t){const r=A.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Da(s);if(A.isFunction(n))return n.call(this,s,r);if(A.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=We(t),t){const r=A.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ht(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=We(i),i){const a=A.findKey(r,i);a&&(!n||Ht(r,r[a],a,n))&&(delete r[a],s=!0)}}return A.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||Ht(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return A.forEach(this,(s,o)=>{const i=A.findKey(r,o);if(i){n[i]=At(s),delete n[o];return}const a=t?Ra(o):String(o).trim();a!==o&&delete n[o],n[a]=At(s),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return A.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&A.isArray(r)?r.join(", "):r)}),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 r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Vn]=this[Vn]={accessors:{}}).accessors,s=this.prototype;function o(i){const a=We(i);r[a]||(La(s,i),r[a]=!0)}return A.isArray(t)?t.forEach(o):o(t),this}};Ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);A.reduceDescriptors(Ee.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});A.freezeMethods(Ee);function Vt(e,t){const n=this||rt,r=t||n,s=Ee.from(r.headers);let o=r.data;return A.forEach(e,function(a){o=a.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Zr(e){return!!(e&&e.__CANCEL__)}let st=class extends V{constructor(t,n,r){super(t??"canceled",V.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function es(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new V("Request failed with status code "+n.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Fa(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $a(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),u=r[o];i||(i=c),n[s]=l,r[s]=c;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),c-i<t)return;const y=u&&c-u;return y?Math.round(h*1e3/y):void 0}}function Ma(e,t){let n=0,r=1e3/t,s,o;const i=(c,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),f=u-n;f>=r?i(c,u):(s=c,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const _t=(e,t,n=3)=>{let r=0;const s=$a(50,250);return Ma(o=>{const i=o.loaded,a=o.lengthComputable?o.total:void 0,l=i-r,c=s(l),u=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},qn=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Gn=e=>(...t)=>A.asap(()=>e(...t)),ja=de.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,de.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(de.origin),de.navigator&&/(msie|trident)/i.test(de.navigator.userAgent)):()=>!0,Ua=de.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];A.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),A.isString(r)&&a.push(`path=${r}`),A.isString(s)&&a.push(`domain=${s}`),o===!0&&a.push("secure"),A.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.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 ka(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ya(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ts(e,t,n){let r=!ka(t);return e&&(r||n==!1)?Ya(e,t):t}const Kn=e=>e instanceof Ee?{...e}:e;function Le(e,t){t=t||{};const n={};function r(c,u,f,h){return A.isPlainObject(c)&&A.isPlainObject(u)?A.merge.call({caseless:h},c,u):A.isPlainObject(u)?A.merge({},u):A.isArray(u)?u.slice():u}function s(c,u,f,h){if(A.isUndefined(u)){if(!A.isUndefined(c))return r(void 0,c,f,h)}else return r(c,u,f,h)}function o(c,u){if(!A.isUndefined(u))return r(void 0,u)}function i(c,u){if(A.isUndefined(u)){if(!A.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,f){if(f in t)return r(c,u);if(f in e)return r(void 0,c)}const l={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:a,headers:(c,u,f)=>s(Kn(c),Kn(u),f,!0)};return A.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const f=A.hasOwnProp(l,u)?l[u]:s,h=f(e[u],t[u],u);A.isUndefined(h)&&f!==a||(n[u]=h)}),n}const ns=e=>{const t=Le({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:a}=t;if(t.headers=i=Ee.from(i),t.url=Xr(ts(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),A.isFormData(n)){if(de.hasStandardBrowserEnv||de.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(A.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([u,f])=>{c.includes(u.toLowerCase())&&i.set(u,f)})}}if(de.hasStandardBrowserEnv&&(r&&A.isFunction(r)&&(r=r(t)),r||r!==!1&&ja(t.url))){const l=s&&o&&Ua.read(o);l&&i.set(s,l)}return t},Ba=typeof XMLHttpRequest<"u",Ha=Ba&&function(e){return new Promise(function(n,r){const s=ns(e);let o=s.data;const i=Ee.from(s.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=s,u,f,h,y,m;function E(){y&&y(),m&&m(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function _(){if(!p)return;const T=Ee.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),v={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:T,config:e,request:p};es(function(S){n(S),E()},function(S){r(S),E()},v),p=null}"onloadend"in p?p.onloadend=_:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(_)},p.onabort=function(){p&&(r(new V("Request aborted",V.ECONNABORTED,e,p)),p=null)},p.onerror=function(P){const v=P&&P.message?P.message:"Network Error",B=new V(v,V.ERR_NETWORK,e,p);B.event=P||null,r(B),p=null},p.ontimeout=function(){let P=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const v=s.transitional||Sn;s.timeoutErrorMessage&&(P=s.timeoutErrorMessage),r(new V(P,v.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&A.forEach(i.toJSON(),function(P,v){p.setRequestHeader(v,P)}),A.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),a&&a!=="json"&&(p.responseType=s.responseType),c&&([h,m]=_t(c,!0),p.addEventListener("progress",h)),l&&p.upload&&([f,y]=_t(l),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(u=T=>{p&&(r(!T||T.type?new st(null,e,p):T),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const U=Fa(s.url);if(U&&de.protocols.indexOf(U)===-1){r(new V("Unsupported protocol "+U+":",V.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Va=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(c){if(!s){s=!0,a();const u=c instanceof Error?c:this.reason;r.abort(u instanceof V?u:new st(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new V(`timeout of ${t}ms exceeded`,V.ETIMEDOUT))},t);const a=()=>{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:l}=r;return l.unsubscribe=()=>A.asap(a),l}},qa=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Ga=async function*(e,t){for await(const n of Ka(e))yield*qa(n,t)},Ka=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Wn=(e,t,n,r)=>{const s=Ga(e,t);let o=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await s.next();if(c){a(),l.close();return}let f=u.byteLength;if(n){let h=o+=f;n(h)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),s.return()}},{highWaterMark:2})},zn=64*1024,{isFunction:ft}=A,Wa=(({Request:e,Response:t})=>({Request:e,Response:t}))(A.global),{ReadableStream:Jn,TextEncoder:Xn}=A.global,Qn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},za=e=>{e=A.merge.call({skipUndefined:!0},Wa,e);const{fetch:t,Request:n,Response:r}=e,s=t?ft(t):typeof fetch=="function",o=ft(n),i=ft(r);if(!s)return!1;const a=s&&ft(Jn),l=s&&(typeof Xn=="function"?(m=>E=>m.encode(E))(new Xn):async m=>new Uint8Array(await new n(m).arrayBuffer())),c=o&&a&&Qn(()=>{let m=!1;const E=new n(de.origin,{body:new Jn,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!E}),u=i&&a&&Qn(()=>A.isReadableStream(new r("").body)),f={stream:u&&(m=>m.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(E,p)=>{let _=E&&E[m];if(_)return _.call(E);throw new V(`Response type '${m}' is not supported`,V.ERR_NOT_SUPPORT,p)})});const h=async m=>{if(m==null)return 0;if(A.isBlob(m))return m.size;if(A.isSpecCompliantForm(m))return(await new n(de.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(A.isArrayBufferView(m)||A.isArrayBuffer(m))return m.byteLength;if(A.isURLSearchParams(m)&&(m=m+""),A.isString(m))return(await l(m)).byteLength},y=async(m,E)=>{const p=A.toFiniteNumber(m.getContentLength());return p??h(E)};return async m=>{let{url:E,method:p,data:_,signal:U,cancelToken:T,timeout:P,onDownloadProgress:v,onUploadProgress:B,responseType:S,headers:L,withCredentials:F="same-origin",fetchOptions:$}=ns(m),x=t||fetch;S=S?(S+"").toLowerCase():"text";let H=Va([U,T&&T.toAbortSignal()],P),O=null;const g=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let b;try{if(B&&c&&p!=="get"&&p!=="head"&&(b=await y(L,_))!==0){let Y=new n(E,{method:"POST",body:_,duplex:"half"}),q;if(A.isFormData(_)&&(q=Y.headers.get("content-type"))&&L.setContentType(q),Y.body){const[G,W]=qn(b,_t(Gn(B)));_=Wn(Y.body,zn,G,W)}}A.isString(F)||(F=F?"include":"omit");const w=o&&"credentials"in n.prototype,R={...$,signal:H,method:p.toUpperCase(),headers:L.normalize().toJSON(),body:_,duplex:"half",credentials:w?F:void 0};O=o&&new n(E,R);let I=await(o?x(O,$):x(E,R));const M=u&&(S==="stream"||S==="response");if(u&&(v||M&&g)){const Y={};["status","statusText","headers"].forEach(z=>{Y[z]=I[z]});const q=A.toFiniteNumber(I.headers.get("content-length")),[G,W]=v&&qn(q,_t(Gn(v),!0))||[];I=new r(Wn(I.body,zn,G,()=>{W&&W(),g&&g()}),Y)}S=S||"text";let k=await f[A.findKey(f,S)||"text"](I,m);return!M&&g&&g(),await new Promise((Y,q)=>{es(Y,q,{data:k,headers:Ee.from(I.headers),status:I.status,statusText:I.statusText,config:m,request:O})})}catch(w){throw g&&g(),w&&w.name==="TypeError"&&/Load failed|fetch/i.test(w.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,m,O,w&&w.response),{cause:w.cause||w}):V.from(w,w&&w.code,m,O,w&&w.response)}}},Ja=new Map,rs=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,a=i,l,c,u=Ja;for(;a--;)l=o[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:za(t)),u=c;return c};rs();const gn={http:ha,xhr:Ha,fetch:{get:rs}};A.forEach(gn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Zn=e=>`- ${e}`,Xa=e=>A.isFunction(e)||e===null||e===!1;function Qa(e,t){e=A.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let a;if(s=r,!Xa(r)&&(s=gn[(a=String(r)).toLowerCase()],s===void 0))throw new V(`Unknown adapter '${a}'`);if(s&&(A.isFunction(s)||(s=s.get(t))))break;o[a||"#"+i]=s}if(!s){const i=Object.entries(o).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
4
+ `+i.map(Zn).join(`
5
+ `):" "+Zn(i[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}const ss={getAdapter:Qa,adapters:gn};function qt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new st(null,e)}function er(e){return qt(e),e.headers=Ee.from(e.headers),e.data=Vt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ss.getAdapter(e.adapter||rt.adapter,e)(e).then(function(r){return qt(e),r.data=Vt.call(e,e.transformResponse,r),r.headers=Ee.from(r.headers),r},function(r){return Zr(r)||(qt(e),r&&r.response&&(r.response.data=Vt.call(e,e.transformResponse,r.response),r.response.headers=Ee.from(r.response.headers))),Promise.reject(r)})}const os="1.13.5",Ft={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ft[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const tr={};Ft.transitional=function(t,n,r){function s(o,i){return"[Axios v"+os+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,a)=>{if(t===!1)throw new V(s(i," has been removed"+(n?" in "+n:"")),V.ERR_DEPRECATED);return n&&!tr[i]&&(tr[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,a):!0}};Ft.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Za(e,t,n){if(typeof e!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const a=e[o],l=a===void 0||i(a,o,e);if(l!==!0)throw new V("option "+o+" must be "+l,V.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new V("Unknown option "+o,V.ERR_BAD_OPTION)}}const yt={assertOptions:Za,validators:Ft},Te=yt.validators;let Ne=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(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Le(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&yt.assertOptions(r,{silentJSONParsing:Te.transitional(Te.boolean),forcedJSONParsing:Te.transitional(Te.boolean),clarifyTimeoutError:Te.transitional(Te.boolean),legacyInterceptorReqResOrdering:Te.transitional(Te.boolean)},!1),s!=null&&(A.isFunction(s)?n.paramsSerializer={serialize:s}:yt.assertOptions(s,{encode:Te.function,serialize:Te.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),yt.assertOptions(n,{baseUrl:Te.spelling("baseURL"),withXsrfToken:Te.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&A.merge(o.common,o[n.method]);o&&A.forEach(["delete","get","head","post","put","patch","common"],m=>{delete o[m]}),n.headers=Ee.concat(i,o);const a=[];let l=!0;this.interceptors.request.forEach(function(E){if(typeof E.runWhen=="function"&&E.runWhen(n)===!1)return;l=l&&E.synchronous;const p=n.transitional||Sn;p&&p.legacyInterceptorReqResOrdering?a.unshift(E.fulfilled,E.rejected):a.push(E.fulfilled,E.rejected)});const c=[];this.interceptors.response.forEach(function(E){c.push(E.fulfilled,E.rejected)});let u,f=0,h;if(!l){const m=[er.bind(this),void 0];for(m.unshift(...a),m.push(...c),h=m.length,u=Promise.resolve(n);f<h;)u=u.then(m[f++],m[f++]);return u}h=a.length;let y=n;for(;f<h;){const m=a[f++],E=a[f++];try{y=m(y)}catch(p){E.call(this,p);break}}try{u=er.call(this,y)}catch(m){return Promise.reject(m)}for(f=0,h=c.length;f<h;)u=u.then(c[f++],c[f++]);return u}getUri(t){t=Le(this.defaults,t);const n=ts(t.baseURL,t.url,t.allowAbsoluteUrls);return Xr(n,t.params,t.paramsSerializer)}};A.forEach(["delete","get","head","options"],function(t){Ne.prototype[t]=function(n,r){return this.request(Le(r||{},{method:t,url:n,data:(r||{}).data}))}});A.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,a){return this.request(Le(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Ne.prototype[t]=n(),Ne.prototype[t+"Form"]=n(!0)});let el=class is{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 r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(a=>{r.subscribe(a),o=a}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,a){r.reason||(r.reason=new st(o,i,a),n(r.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=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new is(function(s){t=s}),cancel:t}}};function tl(e){return function(n){return e.apply(null,n)}}function nl(e){return A.isObject(e)&&e.isAxiosError===!0}const an={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(an).forEach(([e,t])=>{an[t]=e});function as(e){const t=new Ne(e),n=kr(Ne.prototype.request,t);return A.extend(n,Ne.prototype,t,{allOwnKeys:!0}),A.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return as(Le(e,s))},n}const te=as(rt);te.Axios=Ne;te.CanceledError=st;te.CancelToken=el;te.isCancel=Zr;te.VERSION=os;te.toFormData=Lt;te.AxiosError=V;te.Cancel=te.CanceledError;te.all=function(t){return Promise.all(t)};te.spread=tl;te.isAxiosError=nl;te.mergeConfig=Le;te.AxiosHeaders=Ee;te.formToJSON=e=>Qr(A.isHTMLForm(e)?new FormData(e):e);te.getAdapter=ss.getAdapter;te.HttpStatusCode=an;te.default=te;const{Axios:lf,AxiosError:cf,CanceledError:uf,isCancel:df,CancelToken:ff,VERSION:hf,all:mf,Cancel:pf,isAxiosError:Ef,spread:Af,toFormData:yf,AxiosHeaders:Sf,HttpStatusCode:Tf,formToJSON:gf,getAdapter:Cf,mergeConfig:wf}=te,ue={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,r)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},nr=Object.keys(ue),ls=j.createContext(),cs=({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,r]=j.useState({onAction:e?.onAction||ue.onAction,onChange:e?.onChange||ue.onChange,onFormComplete:e?.onFormComplete||ue.onFormComplete,onFormLoad:e?.onFormLoad||ue.onFormLoad,onGetComponent:e?.onGetComponent||ue.onGetComponent,onGetCYA:e?.onGetCYA||ue.onGetCYA,onGetCYARows:e?.onGetCYARows||ue.onGetCYARows,onGoingBack:e?.onGoingBack||ue.onGoingBack,onPageChange:e?.onPageChange||ue.onPageChange,onRequest:e?.onRequest||ue.onRequest,onSubmit:e?.onSubmit||ue.onSubmit,onValidate:e?.onValidate||ue.onValidate,onCancel:e?.onCancel||ue.onCancel}),s=(i,a)=>{nr.includes(i)&&r(l=>({...l,[i]:a||ue[i]}))},o=i=>{nr.includes(i)&&r(a=>({...a,[i]:ue[i]}))};return d.jsx(ls.Provider,{value:{hooks:n,addHook:s,removeHook:o},children:t})},Oe=()=>j.useContext(ls),rl=()=>{const{hooks:e}=Oe(),[t,n]=j.useState({});return j.useEffect(()=>{const r=te.create({baseURL:"/"});return r.interceptors.request.use(e.onRequest),r.interceptors.response.use(s=>s,async s=>Promise.reject(s)),n({instance:r}),()=>{n({})}},[e]),t.instance},Cn=j.createContext(),us=({children:e=null})=>{const{hooks:t}=Oe(),[n,r]=j.useState([]),[s,o]=j.useState([]),i=h=>{o(y=>[...y,...h].filter(m=>!!m))},a=h=>{typeof h=="function"&&o(y=>y.filter(m=>!h(m)))},l=()=>{s.length&&o([])},c=h=>{r(y=>[...y,...h].filter(m=>!!m))},u=()=>{o([]),r([])},f={page:h=>{const y=D.Validate.page(h,s),m=t.onValidate(h,y);return r(m),m},pages:h=>{const y=h.map(E=>D.Validate.page(E,s)),m=h.flatMap((E,p)=>t.onValidate(E,y[p]));return r(m),m}};return d.jsx(Cn.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:s,enqueueErrors:i,dequeueErrors:a,clearQueuedErrors:l,validate:f},children:e})},Be=()=>j.useContext(Cn),Gt={},Kt={},sl="idle",ol="fetching",ds="fetched",fs="error",il=(e,t=!0)=>{const n=rl(),r=j.useRef(te.CancelToken.source()),[s,o]=j.useState(sl),[i,a]=j.useState(null),[l,c]=j.useState(null),u=()=>{r.current&&r.current.cancel()};return j.useEffect(()=>{if(!e||!n)return;(async()=>{try{a(null),o(ol);let h;if(t&&Gt[e])h=Gt[e];else{if(t&&Kt[e])throw Kt[e];h=(await n.get(e,{cancelToken:r.current.token}).catch(m=>{throw a(m),m})).data,t&&(Gt[e]=h)}c(h),o(ds)}catch(h){t&&(Kt[e]=h),a(h),c(null),o(fs)}})()},[n,e,t]),{status:s,error:i,data:l,cancelRequests:u}},al="loading",St="complete",ll=e=>{const t=e.data;if(t&&!t.options||t?.url)return C.Utils.interpolateString(t.url,e.formData)},cl=(e,t)=>{const n=ll({...e,formData:t}),{status:r,data:s}=il(n,e?.data?.useCache),[o,i]=j.useState([]),[a,l]=j.useState(al);return j.useEffect(()=>{n?r===ds?(s&&i(he.refData.toOptions(s.data||s,e.item)),l(St)):r===fs&&(i([]),l(St)):(e.data&&e.data.options&&i(he.refData.toOptions(e.data.options,e.item)),l(St))},[e.id,r,s,n]),{data:o,status:a}},Je=(e,t)=>{const n=re(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(C.FormGroup,{...n,onChange:null,children:t})},wn=(e,t,n,r,s={})=>{if(!t)return[];const o=D.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(a=>{s={...s,[`${t.collection.name.split(".").pop()}ActiveId`]:a.id};const l=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...s}};if(c.childPages)return wn(e,u,n,r,s);const f=D.Validate.page(u);return r.onValidate(u,f)});i=i.concat(l.map(c=>({...c,entryId:a.id,showFor:e.id,raisedBy:e.id})))}),i},bn=({value:e,component:t,formData:n,placeholder:r})=>e?t?d.jsx(He,{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:r)||d.jsx(C.VisuallyHidden,{children:"No answer"}),ul="Continue",ln=({action:e,onAction:t,...n})=>{const r=typeof e=="string"?Q.DEFAULTS[e]:e,s=Q.DEFAULTS[e.type];return r?d.jsx(C.Button,{...n,className:r.className,classModifiers:r.classModifiers,start:r.start||!1,name:r.label,onClick:r.disabled?()=>{}:()=>t(r),children:r.label||s?.label||ul}):null},dl="hods-form-confirmation",fl="Are you sure?",hl="Confirm",ml=({id:e,message:t,confirmLabel:n,children:r,onConfirm:s,onCancel:o,classModifiers:i=[]})=>{const a=C.Utils.classBuilder(dl,i,"");return d.jsxs("div",{id:e,className:a(),role:"alert",children:[d.jsx("h2",{children:t||fl}),r,d.jsx(C.Button,{classModifiers:"warning",onClick:s,autoFocus:!0,children:n||hl}),d.jsx(C.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},_n=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===N.CONTAINER?_n(t):ot.editable(t)?t:null).filter(t=>!!t):[],pl=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const r=t?`${t}.${n.fieldId}`:n.fieldId,s={...n,full_path:r};return n.type===N.CONTAINER?cn(s):(n.type===N.RADIOS&&s.data?.options?.forEach((o,i)=>{o.nested?.forEach((a,l)=>{a.type===N.CONTAINER&&(s.data.options[i].nested[l]=cn(a))})}),s)})},cn=e=>{if(e){const t=pl(e);return{...e,components:t}}return e},El=(e,t)=>e.some(n=>ot.show(n,t)),Al=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=_n(e);return n.length>0?El(n,t):!0},$t={editableComponents:_n,setup:cn,show:Al},yl=(e,t)=>e.some(n=>ve(n,t)),Mt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t);const n=$t.editableComponents(e);return n.length>0?yl(n,t):!0},Sl=(e,t,n)=>{if(!e)return null;const r=[];e.childPages.forEach(a=>{!a.summaryQuickEdit||!Mt(a,{...t,...n})||a.summaryQuickEdit.forEach(l=>{if(typeof l=="string"){r.push({...a.components.find(f=>f.id===l)});return}const c=a.components.find(f=>f.id===l.use);if(!c)return;const u={...c,...l};if(l.show_when){Me(l.show_when,{...t,...n})&&r.push({...u,show_when:c.show_when||[]});return}r.push(u)})});const s={...e.childPages[0],formData:t};s.components=r,s.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return s.formData={...s.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete s.title,delete s.collection,s},xn=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(C.ButtonGroup,{children:e.map((n,r)=>d.jsx(ln,{action:n,onAction:t},r))}),Tl=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?le.meetsOne(t.runWhen?.constraint,e.formData):!1},hs="hods-form__page",In=({page:e,pages:t=[],onAction:n,onWrapperChange:r=void 0,onTopLevelChange:s=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:a=hs,classModifiers:l=[],className:c="",submitting:u=!1,pageId:f})=>{const[h,y]=j.useState({}),{errors:m,validate:E}=Be(),[p,_]=j.useState({}),[U,T]=j.useState(!1),P=j.useMemo(()=>Tl(e),[e]);j.useEffect(()=>{T(!0)},[]),j.useEffect(()=>{U&&P&&E.page(e)},[f,U]);const v=({target:x})=>{const H=e,{value:O}=x;O?(H.formData[x.name]=O,y(g=>({...g,[x.name]:O})),_(g=>({...g,[x.component]:x.label}))):(delete H.formData[x.name],y(g=>{const{[x.name]:b,...w}=g;return w}),_(g=>{const{[x.component]:b,...w}=g;return w})),typeof o=="function"&&o(e.formData)};j.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=m.length>0?"Error: "+x:x},[m]);const B=D.classBuilder(a,l,c),S=e;S.actions=S.actions?.map(x=>x.label?{...x,label:D.interpolateString(x.label,S.formData)}:x),S.formData=D.Operate.runPageOperations(S,{...S.formData,...h},r||v);const L=e.title?d.jsx(C.Heading,{size:e.titleSize,children:D.FormPage.getTitle(e.title,e.formData)}):d.jsx(C.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),F=e.components.filter(x=>D.Component.show(x,e.formData)).map((x,H)=>d.jsx(He,{component:x,onAction:O=>n(O,h,p),onChange:r||v,onTopLevelChange:s||v,value:e.formData[x.fieldId]||h[x.fieldId],formData:e.formData,pages:t,submitting:u},H));let $=null;return P&&m?.length>0?$=[{error:e?.customValidation?.[0]?.message}]:m?.length>0&&!P&&($=m),d.jsxs("div",{className:B(),children:[$&&d.jsx(C.ErrorSummary,{errors:$,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:L}),F]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[L,F]}),d.jsx(xn,{actions:e.actions?.filter(x=>D.Component.show(x,e.formData)),onAction:x=>n(x,h,p)})]},e.id)},rr="hods-form-banner-strip",ms=({id:e,banners:t=[],formData:n,classModifiers:r})=>{const s=D.classBuilder(rr,r,""),o=t.filter(i=>D.Component.show(i,n));return d.jsx("div",{id:e,className:s(),children:o.map((i,a)=>{const l=`${e}-banner-${a}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:l,className:s("banner"),children:d.jsx(C.Markup,{content:D.interpolateString(c,n)})},l)}return d.jsx(C.Tag,{classBlock:`${rr}__tag`,classModifiers:i.classModifiers,text:D.interpolateString(i.text,n)},l)})})},gl=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]=j.useState({});return j.useEffect(()=>{n(gl(e))},[e,n]),e.action?d.jsxs(C.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(C.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},ps=({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})})]}),Es=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(C.SmallHeading,{children:e})}),Tt=(e,t,n,r,s)=>{const o={...e,formData:{...e.formData,...r}},i=Yt(o,t);return t.type==="title"?d.jsx(Es,{title:t.key,classes:n}):d.jsx(ps,{row:{key:i.key,value:d.jsx(bn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:s}),required:i.required},classes:n},`${i.fieldId}`)},Cl="govuk-summary-card",wl="govuk-summary-list",ht="Item",mt="Change",sr="Delete",bl="warning",_l=({id:e,entryData:t,config:n,onFullEdit:r,onDelete:s,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:a=null})=>{const l=C.Utils.classBuilder(Cl,i,n.className),c=C.Utils.classBuilder(wl,[]);return d.jsxs("div",{className:l(),id:e,children:[d.jsxs("div",{className:l("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:l("title-content"),children:[d.jsx("h2",{className:l("title"),children:C.Utils.interpolateString(n.title||ht,{...t,index:t.index+1})}),n.banners&&d.jsx(ms,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:l("actions"),children:[d.jsx("li",{className:l("action"),children:n.changeAction&&typeof r=="function"&&n.changeAction.classModifiers?d.jsx(C.Button,{id:`${e}.changeButton`,onClick:()=>r(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":C.Utils.interpolateString(`${n.changeAction?.label||mt} ${n.title||ht}`,{...t,index:t.index+1}),children:n.changeAction?.label||mt}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>r(n.changeAction.page,t.id),"aria-label":C.Utils.interpolateString(`${n.changeAction?.label||mt} ${n.title||ht}`,{...t,index:t.index+1}),children:n.changeAction?.label||mt})}),d.jsx("li",{className:l("action"),children:n.deleteAction&&typeof s=="function"&&d.jsx(C.Button,{id:`${e}.deleteButton`,onClick:()=>s(t),classModifiers:n.deleteAction.classModifiers||bl,"aria-label":C.Utils.interpolateString(`${n.deleteAction?.label||sr} ${n.title||ht}`,{...t,index:t.index+1}),children:n.deleteAction.label||sr})})]})]}),d.jsx("div",{className:l("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const f=u.components.map(h=>D.Component.elevateNested([h],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(h=>{const m=h.columns.filter(E=>le.meetsAll(E,{...u.formData,...t})).flatMap(E=>E.fields||[]);return m.length?m.flatMap(E=>{const p=f.find(_=>_.fieldId===E);return p?Tt(u,p,c,t,a):null}):null})})})})]})},xl=({id:e,"data-testid":t,actions:n,onFullEdit:r=null,entryData:s,formData:o,name:i,autoFocus:a})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(l=>D.Component.show(l,o)).map(l=>d.jsx(C.Button,{id:e,"data-testid":t,onClick:()=>r(l?.page,s.id),classModifiers:l?.classModifiers||ir,"aria-label":D.FormPage.getConditionalText(l?.aria_label,s),name:i,autoFocus:a,children:l?.label||or},e))}):d.jsx(C.Button,{id:e,"data-testid":t,onClick:()=>r(n?.page,s.id),classModifiers:n?.classModifiers||ir,"aria-label":D.FormPage.getConditionalText(n?.aria_label,s),name:i,autoFocus:a,children:n?.label||or}),Il=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},jt=(e,t,n)=>{const r=t?.cya_link;return e!==!0&&r?{page:Il(r)||t.id||"#",label:r.label||"Change",aria_suffix:r.aria_suffix,onAction:n}:null},As=[N.ALERT,N.COLLECTION_SUMMARY,N.DETAILS,N.HEADING,N.HTML,N.INSET_TEXT],xt=(e,t)=>{if(!e||As.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===N.COLLECTION){if(!oe(t,e.full_path||e.fieldId)?.length)return!1}else{const n=oe(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===N.CONTAINER?$t.show(e,t):ot.show(e,t)},ys=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>As.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}`}})}),Pl=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:jt(!1,e,t)}],vl=(e,t,n,r)=>({id:t.id,fieldId:t.id,type:N.CONTAINER,required:e.required,full_path:r,components:e.item.map(s=>({...s,label:C.Utils.interpolateString(s.label,{...t,index:n}),full_path:`${r}.${s.fieldId}`}))}),Ol=(e,t,n,r,s)=>{const o={...ke,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:s,key:C.Utils.interpolateString(o.item,{...t,index:r}),type:"title",action:null}:null},vn=(e,t,n,r,s)=>Array.isArray(n)&&n.length&&xt(t,e.formData)?n.flatMap((o,i)=>{const a=(t.countOffset||0)+i+1,l=`${t.full_path||t.fieldId}[${i}]`;let c=vl(t,o,a,l);return c=ys(c),[Ol(t,o,e.id,a,l),...Ve(e,c,o,r,s)]}).filter(o=>!!o):Pl(e,r),Dl="hods-form-summary-card-details",Ss=({masterPage:e,childCollections:t=[],formData:n,entryData:r,classModifiers:s,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const a=D.classBuilder(Dl,s),l=j.useMemo(()=>t.map(u=>e.childPages.find(f=>f.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,f,h)=>{let y=0;return u.flatMap((m,E)=>{let p=0;const _=m.fields?.flatMap(T=>f.filter(v=>v.fieldId===T).map(v=>{if(!v||!ve(v,{...h.formData,...r}))return null;if(v.type===N.CONTAINER){const B=Ve(h,v,r);return p+=1,d.jsx("div",{className:a("field"),style:{"--column":y+1,"--row":p},role:"list",children:B.map(S=>{const L={...r,[S.fieldId]:r[v.fieldId]?.[S.fieldId]};return Tt(h,{...S,label:S.key},a,L,i)})},T)}if(v.type===N.COLLECTION){const B=vn({...h,formData:{...h.formData,...r}},v,r[v.id]);p+=1;let S=0;return d.jsx("div",{className:a("field"),style:{"--column":y+1,"--row":p},role:"list",children:B.map(L=>{const F={...r,[L.fieldId]:r[v.fieldId]?.[L.fieldId]},$=Tt(h,{...L,label:L.key},a,F,i);return L.type==="title"&&(S+=1,S>1)?d.jsx("div",{style:{marginTop:"40px"},children:$}):$})},T)}return p+=1,d.jsx("div",{className:a("field"),style:{"--column":y+1,"--row":p},role:"list",children:Tt(h,v,a,r,i)},T)})).filter(T=>!!T);return!(E===u.length-1)&&_.length!==0?(y+=2,[..._,d.jsx("div",{className:a("divider"),style:{"--column":y}},`divider${y}`)]):_}).filter(m=>!!m)};return e?.childPages?.filter(u=>D.FormPage.show(u,{...n,...r})).map(u=>{const f=D.Component.elevateNested(u?.components,r);return u.summaryLayout?.sections.map(h=>{if(h.show_when&&!D.Condition.meetsAll(h.show_when,{...n,...r}))return null;if(h.type==="childCollection"){const m=l.find(p=>p.collection.name===h.collectionName),E=r[h.collectionName.split(".").pop()]||[];return m&&E.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:a("section-title"),children:h.title}),E.map(p=>d.jsx(Ss,{masterPage:m,childMasterPages:[],formData:{...n,...r,...p},entryData:p,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const y=h.columns.filter(m=>le.meetsAll(m,{...u.formData,...r}));return d.jsxs("div",{className:a("section"),children:[!o&&d.jsx("h3",{className:a("section-title"),children:D.FormPage.getConditionalText(h.title,{...u.formData,...r})}),d.jsx("dl",{className:a("section-content"),style:{"--dividers":y.length-1},children:c(y,f,u)})]},h.title)})}).filter(u=>!!u)||null},Nl="hods-form-summary-card",or="Change",Rl="Delete",Ll="Quick Edit",Fl="Duplicate",$l="Full details",ir="secondary",ar=({id:e,entryData:t,config:n,classModifiers:r,onFullEdit:s,onDelete:o,onDuplicate:i,onQuickEdit:a,parentCollectionName:l,childCollections:c=[],formData:u,masterPage:f,hideDetails:h=!1})=>{const[y,m]=j.useState(!1),E=C.Utils.classBuilder(Nl,r,n.className),p=j.useMemo(()=>n.quickEdit?Sl(f,u,t):null,[f,n,u,t,y]),{addErrors:_,resetQuickEditErrors:U,clearTopLevelErrorsForCard:T,validate:P}=Be(),{hooks:v}=Oe(),B=async(S,L)=>{if(S.type==="cancel"&&(m(F=>!F),U?.()),S.type==="save"&&typeof a=="function"){const F={...p.formData,...L,[`${l}ActiveId`]:t.id},$=P.page({...p,formData:F});if($.length)return;let x;await v.onSubmit("quickEdit",F,()=>{},O=>{x=O}),x&&_(x);const H=$.concat(x);if(H.length===0||H.length===1&&H[0]===void 0){T();const O=D.CollectionPage.getData(l,u),{isDuplicate:g,...b}=O[t.index];O[t.index]={...b,...L},a({target:{name:l,value:O}}),m(w=>!w)}}};return n.listView?d.jsx(_l,{id:e,entryData:t,config:n,onFullEdit:s,onDelete:o,masterPage:f,classModifiers:r,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:E(),id:e,children:[d.jsxs("div",{className:E("header"),children:[d.jsxs("div",{className:E("header-content"),children:[n.banners&&d.jsx(ms,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:E("header-content-title"),children:D.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:E("header-content-detail"),children:D.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:E("header-actions"),children:[n.quickEdit&&d.jsx(C.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>m(S=>!S),classModifiers:"primary",disabled:y,name:"QuickEdit",autoFocus:n.focusOn,children:Ll}),n.changeAction&&typeof s=="function"&&d.jsx(xl,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:s,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(C.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":D.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Rl}),n.duplicateAction&&typeof i=="function"&&d.jsx(C.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":D.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||Fl})]})]}),y&&p&&d.jsx(In,{page:p,onAction:(S,L)=>B(S,L),className:E("editpage")}),d.jsx("div",{className:E("body"),children:!h&&d.jsx(C.Details,{summary:n.detailsTitle||$l,className:"details",children:d.jsx(Ss,{masterPage:f,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Ml=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:r})=>{const{hooks:s}=Oe(),o=t.filter(f=>f.entryId===e)||[],[i,a]=j.useState(null),l=()=>{a(null)},c=f=>{a(h=>(h??[]).concat(f))},u={page:f=>{const h=D.Validate.page(f),y=s.onValidate(f,h);return a(y),y}};return d.jsx(Cn.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:l,clearTopLevelErrorsForCard:n,validate:u},children:r})},lr="Add",jl=({config:e,formData:t,onAction:n,onChange:r,onTopLevelChange:s,pages:o=[]})=>{const{hooks:i}=Oe(),{errors:a,addErrors:l,clearErrors:c,queuedErrors:u,enqueueErrors:f,dequeueErrors:h}=Be(),[y,m]=j.useState(null),E=j.useMemo(()=>D.CollectionPage.getData(e.collectionName,t)||[],[t]),p=Array.isArray(E)&&E.length>0?E.reduce((L,F)=>F.isDuplicate&&(!L||F.id>L.id)?F:L,null):null,_=j.useMemo(()=>{const L=e.collectionName.split(".");let F=D.CollectionPage.mergePages(o||[])||[];return L.reduce(($,x,H)=>{const O=H===0?`${$}${x}`:`${$}.${x}`;return H===L.length-1?F?.find(g=>g.collection?.name===O)||null:(F=F.find(g=>g.collection?.name===O)?.childPages||null,O)},"")},[o]),U=j.useMemo(()=>e.card.listView?_.childPages?.reduce((F,$)=>{const x=Ze($.components,{...t,...y});return F.concat(x)},[])||[]:[],[_,t,y,e.card.listView]),T=()=>{u.length>0&&h(F=>F.raisedBy===e.id);const L=wn(e,_,t,i);L.length>0&&f(L)};j.useEffect(()=>{Array.isArray(E)&&E.length>0&&T()},[E]);const P=(L,F)=>{if(typeof n=="function"){const $=[...E],x=E.findIndex(g=>g.id===F),{isDuplicate:H,...O}=E[x];$[x]={...O},n({type:pt.SAVE_AND_NAVIGATE,page:L,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:F},{field:e.collectionName,value:$,isCollection:!0}]})}},v=L=>{D.CollectionPage.duplicateEntry(e.collectionName,t,L.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const F=e.collectionName.split(".").shift();typeof s=="function"&&(s({target:{name:F,value:D.CollectionPage.getData(F,t)}}),T())},B=()=>{if(!y)return;D.CollectionPage.removeEntry(e.collectionName,t,y.id);const L=e.collectionName.split(".").shift();typeof s=="function"&&s({target:{name:L,value:D.CollectionPage.getData(L,t)}}),m(null),T()},S=L=>{const F=U.find(x=>x.fieldId===L);if(!F)return null;const $=Yt({..._,formData:{...t,...y}},F);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(bn,{value:$.value,component:$.component,formData:$.formData})},L)};return d.jsxs("div",{id:e.fieldId,children:[y&&d.jsx(ml,{id:`${e.fieldId}.confirmation`,message:D.interpolateString(e.confirmation?.message,{...y,index:y.index+1})||null,confirmLabel:D.interpolateString(e.confirmation?.label,y)||null,onConfirm:B,onCancel:()=>m(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(S)}):d.jsx(ar,{id:`${e.fieldId}.confirmationChild`,entryData:y,config:e.card?{...e.card,quickEdit:null}:{},masterPage:_,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(ln,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:D.interpolateString(e.addButton.label||lr,{documents:E}),page:e.addButton.page,type:pt.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:E.map((L,F)=>{const $=a.filter(O=>O.entryId===L.id).length>0,x={...e.card,...L.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...$&&e.errorCard?e.errorCard:{},focusOn:p?.id===L.id},H=`${e.fieldId}.summaryCard${L.id}`;return d.jsx("li",{children:d.jsx(Ml,{entryId:L.id,topLevelErrors:a,clearTopLevelErrorsForCard:()=>{const O=a.filter(g=>g.entryId!==L.id);c(),l(O)},children:d.jsx(ar,{id:H,entryData:{...L,index:F},masterPage:_,config:x||{},onFullEdit:P,onDuplicate:v,onDelete:()=>m({...L,index:F}),onQuickEdit:O=>(T(),r(O)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:L.id===y?.id?["deleting-summary-card"]:[""],inError:a.filter(O=>O.entryId===L.id).length>0},H)})})})}),e.card.listView&&e.addButton&&d.jsx(ln,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:D.interpolateString(e.addButton.label||lr,{documents:E}),page:e.addButton.page,type:pt.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Ul="hods-form-collection",kl=({config:e,value:t,formData:n,onChange:r=void 0,onTopLevelChange:s=void 0,wrap:o=!1})=>{const[i,a]=j.useState(t),l=E=>{a(E),typeof r=="function"&&r({target:{name:e.fieldId,value:E}})},c=({target:E})=>{if(typeof r=="function")if(E.name===D.Meta.name)r({target:E});else{const p=i.findIndex(_=>_.id===E.name);l([...i.slice(0,p),E.value,...i.slice(p+1)])}},u=async()=>{l([...i,{id:Ot.v4()}])},f=async E=>{l(i.filter(p=>p.id!==E.id))},h=E=>E.initial&&!i.length?E.initial:E.add;j.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const E=i[i.length-1]?.id,_=document.getElementById(E)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');_&&_.length>0&&_[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),j.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const y={...ke,...e.labels},m=D.classBuilder(Ul,[],e.className);return d.jsxs("div",{className:m(),id:e.id,children:[e.label&&d.jsx(C.Label,{id:e.id,required:e.required,className:m("title"),children:e.label}),Array.isArray(i)&&i.map((E,p)=>{const _=`${e.full_path||e.fieldId}[${p}]`,U=(e.countOffset||0)+p+1,T=D.interpolateString(y.item,{...E,index:U}),P=D.interpolateString(y.remove,{...E,index:U}),v=e.disableAddAndRemove||p===0&&e.minimumEntries?"":e.removeLocation??"start",B=p!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${m("item")}`,style:B,children:[d.jsxs(C.Label,{id:E.id,required:!0,className:m("item-title"),children:[T,v==="start"&&d.jsx(C.Button,{onClick:()=>f(E),classModifiers:"secondary",children:P})]}),d.jsx(Ln,{container:{id:E.id,fieldId:E.id,type:"container",required:e.required,full_path:_,components:e.item.map(S=>{const{firstOnlyLabel:L,...F}=S;let{hint:$}=S;e.restrictHint&&p>0&&($=void 0);let{label:x}=S;return p===0&&(x=S.firstOnlyLabel??S.label),{...F,hint:$,readonly:!!(e?.readonly||S.readonly),label:D.interpolateString(x,{...E,index:U}),full_path:`${_}.${S.fieldId}`}})},value:E,formData:n,onChange:c,onTopLevelChange:s,wrap:o}),v==="end"&&d.jsx(C.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(C.Button,{onClick:()=>f(E),classModifiers:"secondary",children:P})})]},E.id)}),!e.disableAddAndRemove&&d.jsx(C.ButtonGroup,{children:d.jsx(C.Button,{onClick:u,classModifiers:"secondary",children:h(y)})})]})},Yl=(e,t,n)=>{const r=e,s=typeof r.value=="object"?r.value?.value:r.value,o=n.find(i=>String(i.id)===s);return r.label=o===void 0?r.value||"":o.label,r.component=t.cya_label,r},Bl=(e,t)=>typeof e=="string"?!!C.Utils.interpolateString(e,t):!!e,Wt=(e,t)=>{if(Array.isArray(t)){const n=t.find(r=>r.id===(e.full_path||e.id));if(n){const r={error:n.error};return n.properties&&(r.propsInError=n.properties),r}}},Hl=[N.RADIOS,N.CHECKBOXES,N.DATE,N.TIME],Vl=e=>e.fieldset||Hl.includes(e.type),He=({component:e,value:t=null,formData:n=null,wrap:r=!0,onAction:s,onChange:o,onTopLevelChange:i,pages:a=[],submitting:l=!1,...c})=>{const{hooks:u}=Oe(),f=Be(),{data:h,status:y}=cl(e,n),[m,E]=j.useState([]);j.useEffect(()=>{y===St&&E(h)},[e,h,y]);const p=({target:T})=>typeof o=="function"?(e.type===N.EMAIL&&(T.value=T.value.trim()),e.type===N.CHECKBOXES&&Array.isArray(T.value)&&T.value.forEach(P=>{P.children&&P.nested&&(delete P.children,delete P.nested)}),T=Yl(T,e,h),e.type===N.SELECT&&T.value===""&&(T.value=null,T.label=null),o({target:T}),!0):!1;if(j.useEffect(()=>{const T=D.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&T&&typeof p=="function"&&p({target:{name:e.fieldId,value:T}})},[]),e.type===N.CONTAINER){let T=d.jsx(Ln,{...c,container:e,wrap:r,onChange:p,onTopLevelChange:i,value:t||D.Component.defaultValue(e,n),formData:n});return e.fieldset&&(T=Je(e,T)),e.additionalValidation&&(T=Je({...e,...Wt(e,f?.errors)},T)),T}if(e.type===N.COLLECTION)return d.jsx(kl,{...c,config:e,wrap:r,onChange:p,onTopLevelChange:i,value:t||D.Component.defaultValue(e,n),formData:n});if(e.type===N.COLLECTION_SUMMARY)return Je({...e,...Wt(e,f?.errors)},d.jsx(jl,{...c,config:e,formData:n,onAction:s,onChange:o,onTopLevelChange:i,pages:a}));const _=T=>{let P=e.full_path||e.fieldId;if(e.pageCollection){const v=D.CollectionPage.getActiveIndex(e.pageCollection.name,n);P=`${`${e.pageCollection.name}[${v}]`}.${P}`}i({target:{name:D.Meta.name,value:D.Meta.documents.setForField(T,n,P,e.allowMultiple)}})},U=({target:T})=>{if(p({target:T})){if(e.type===N.FILE)_([T.value]);else if(e.type===N.MULTI_FILE){const P=T.value.map((v,B)=>({...v,indexInField:B}));_(P)}}};return D.Component.get({...c,...e,id:e.full_path||e.id,...Wt(e,f?.errors),fieldset:Vl(e),disabled:Bl(e.disabled,n),label:D.interpolateString(e.label,n),content:D.interpolateString(e.content,n),hint:D.interpolateString(e.hint,n),cya_label:D.interpolateString(e.cya_label,n),suffix:D.interpolateString(e.suffix,n),options:m,value:t,onChange:U,onTopLevelChange:i,formData:n,onAction:s,submitting:l},r,u.onGetComponent)},ql=[N.AUTOCOMPLETE,N.CALCULATION,N.CHECKBOXES,N.COLLECTION_SUMMARY,N.DATE,N.EMAIL,N.FILE,N.MULTI_FILE,N.PHONE_NUMBER,N.RADIOS,N.SELECT,N.TEXT,N.TEXT_AREA,N.TIME],Ts=e=>ql.includes(e?.type)||e?.isEditable||!1,Gl="govuk-list",Kl="govuk-body",Wl=e=>{const t=re(e),n=C.Utils.interpolateString(e.heading,e.formData),r=C.Utils.interpolateString(e.text,e.formData);return d.jsx(C.Alert,{...t,heading:n,children:r})},zl=e=>{const t=re(e),n=he.getAutocompleteSource(e);return d.jsx(C.Autocomplete,{...t,source:n})},Jl=e=>{let t=[];he.getOptions(e,r=>{t=r}),t=t.map(r=>Array.isArray(r.nested)?{...r,children:gs(e,r.nested)}:r);const n=re(e);return d.jsx(C.Checkboxes,{...n,options:t})},Xl=e=>{const t=he.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=re(e,["formula"]);return d.jsx(C.TextInput,{...n,readonly:!0})},Ql=e=>{const t=re(e);return d.jsx(C.DateInput,{...t})},Zl=e=>{const t=re(e,["tagName"]),n=Ut(e);return d.jsx(C.Details,{...t,children:n})},ec=e=>{const t=re(e);return d.jsx(C.FileUpload,{...t})},tc=e=>{const t=re(e);return d.jsx(C.MultiFileUpload,{...t})},nc=e=>{const t=re(e);return d.jsx(C.Heading,{...t,children:e.content})},Ut=e=>{const t=re(e);return d.jsx(C.Markup,{...t})},rc=e=>{const t=re(e);return d.jsx(C.InsetText,{...t,children:e.content})},sc=e=>{const t=re(e,["ordered"]),n=e.ordered?"ol":"ul",r=e.ordered?"number":"bullet",s=C.Utils.classBuilder(Gl,r),o=t.items?.map(i=>`<li>${i}</li>`).join("");return Ut({...t,className:s(),tagName:n,content:o,type:N.HTML})},oc=e=>{const t=re(e);return Ut({className:Kl,...t,tagName:"p",type:N.HTML})},ic=e=>{let t=[];he.getOptions(e,r=>{t=r}),t=t.map(r=>Array.isArray(r.nested)?{...r,children:gs(e,r.nested)}:r);const n=re(e);return d.jsx(C.Radios,{...n,options:t})},ac=e=>{const t=re(e);return d.jsx(C.TextArea,{...t})},lc=e=>{const t=re(e);return d.jsx(C.TextInput,{...t})},cc=e=>{const t=re(e);return d.jsx(C.TimeInput,{...t})},uc=e=>{let t=[];he.getOptions(e,r=>{t=r});const n=re(e);return d.jsx(C.Select,{...n,options:t})},dc=e=>{const t=re(e);return d.jsx(C.WarningText,{...t,children:e.content})},fc=e=>{switch(e.type){case N.HTML:return Ut(e);case N.HEADING:return nc(e);case N.INSET_TEXT:return rc(e);case N.TEXT:case N.EMAIL:case N.PHONE_NUMBER:return lc(e);case N.TEXT_AREA:return ac(e);case N.AUTOCOMPLETE:return zl(e);case N.RADIOS:return ic(e);case N.CHECKBOXES:return Jl(e);case N.DATE:return Ql(e);case N.TIME:return cc(e);case N.FILE:return ec(e);case N.MULTI_FILE:return tc(e);case N.WARNING:return dc(e);case N.SELECT:return uc(e);case N.DETAILS:return Zl(e);case N.CALCULATION:return Xl(e);case N.ALERT:return Wl(e);case N.PARAGRAPH:return oc(e);case N.LIST:return sc(e);default:return null}},hc=(e,t)=>{const n={...t};if(e.full_path){const r=e.full_path.split(".");r.pop(),r.push(n.fieldId),n.full_path=r.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||he.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:Cs(n,!1)})):d.jsx(He,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},gs=(e,t)=>{const n=t.filter(r=>!(r.show_when&&!le.meetsAll(r.show_when,e.formData))).map(r=>d.jsx(d.Fragment,{children:hc(e,r)},r.id));return n.length>0?n:null},Cs=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const s=n(e,t);if(s)return s}const r=fc(e);return r&&t&&Ts(e)?Je(e,r):r};function kt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gt={exports:{}},mc=gt.exports,cr;function pc(){return cr||(cr=1,(function(e,t){(function(n,r){e.exports=r()})(mc,(function(){var n=1e3,r=6e4,s=36e5,o="millisecond",i="second",a="minute",l="hour",c="day",u="week",f="month",h="quarter",y="year",m="date",E="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,U={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(g){var b=["th","st","nd","rd"],w=g%100;return"["+g+(b[(w-20)%10]||b[w]||b[0])+"]"}},T=function(g,b,w){var R=String(g);return!R||R.length>=b?g:""+Array(b+1-R.length).join(w)+g},P={s:T,z:function(g){var b=-g.utcOffset(),w=Math.abs(b),R=Math.floor(w/60),I=w%60;return(b<=0?"+":"-")+T(R,2,"0")+":"+T(I,2,"0")},m:function g(b,w){if(b.date()<w.date())return-g(w,b);var R=12*(w.year()-b.year())+(w.month()-b.month()),I=b.clone().add(R,f),M=w-I<0,k=b.clone().add(R+(M?-1:1),f);return+(-(R+(w-I)/(M?I-k:k-I))||0)},a:function(g){return g<0?Math.ceil(g)||0:Math.floor(g)},p:function(g){return{M:f,y,w:u,d:c,D:m,h:l,m:a,s:i,ms:o,Q:h}[g]||String(g||"").toLowerCase().replace(/s$/,"")},u:function(g){return g===void 0}},v="en",B={};B[v]=U;var S="$isDayjsObject",L=function(g){return g instanceof H||!(!g||!g[S])},F=function g(b,w,R){var I;if(!b)return v;if(typeof b=="string"){var M=b.toLowerCase();B[M]&&(I=M),w&&(B[M]=w,I=M);var k=b.split("-");if(!I&&k.length>1)return g(k[0])}else{var Y=b.name;B[Y]=b,I=Y}return!R&&I&&(v=I),I||!R&&v},$=function(g,b){if(L(g))return g.clone();var w=typeof b=="object"?b:{};return w.date=g,w.args=arguments,new H(w)},x=P;x.l=F,x.i=L,x.w=function(g,b){return $(g,{locale:b.$L,utc:b.$u,x:b.$x,$offset:b.$offset})};var H=(function(){function g(w){this.$L=F(w.locale,null,!0),this.parse(w),this.$x=this.$x||w.x||{},this[S]=!0}var b=g.prototype;return b.parse=function(w){this.$d=(function(R){var I=R.date,M=R.utc;if(I===null)return new Date(NaN);if(x.u(I))return new Date;if(I instanceof Date)return new Date(I);if(typeof I=="string"&&!/Z$/i.test(I)){var k=I.match(p);if(k){var Y=k[2]-1||0,q=(k[7]||"0").substring(0,3);return M?new Date(Date.UTC(k[1],Y,k[3]||1,k[4]||0,k[5]||0,k[6]||0,q)):new Date(k[1],Y,k[3]||1,k[4]||0,k[5]||0,k[6]||0,q)}}return new Date(I)})(w),this.init()},b.init=function(){var w=this.$d;this.$y=w.getFullYear(),this.$M=w.getMonth(),this.$D=w.getDate(),this.$W=w.getDay(),this.$H=w.getHours(),this.$m=w.getMinutes(),this.$s=w.getSeconds(),this.$ms=w.getMilliseconds()},b.$utils=function(){return x},b.isValid=function(){return this.$d.toString()!==E},b.isSame=function(w,R){var I=$(w);return this.startOf(R)<=I&&I<=this.endOf(R)},b.isAfter=function(w,R){return $(w)<this.startOf(R)},b.isBefore=function(w,R){return this.endOf(R)<$(w)},b.$g=function(w,R,I){return x.u(w)?this[R]:this.set(I,w)},b.unix=function(){return Math.floor(this.valueOf()/1e3)},b.valueOf=function(){return this.$d.getTime()},b.startOf=function(w,R){var I=this,M=!!x.u(R)||R,k=x.p(w),Y=function(me,ne){var fe=x.w(I.$u?Date.UTC(I.$y,ne,me):new Date(I.$y,ne,me),I);return M?fe:fe.endOf(c)},q=function(me,ne){return x.w(I.toDate()[me].apply(I.toDate("s"),(M?[0,0,0,0]:[23,59,59,999]).slice(ne)),I)},G=this.$W,W=this.$M,z=this.$D,ye="set"+(this.$u?"UTC":"");switch(k){case y:return M?Y(1,0):Y(31,11);case f:return M?Y(1,W):Y(0,W+1);case u:var Se=this.$locale().weekStart||0,_e=(G<Se?G+7:G)-Se;return Y(M?z-_e:z+(6-_e),W);case c:case m:return q(ye+"Hours",0);case l:return q(ye+"Minutes",1);case a:return q(ye+"Seconds",2);case i:return q(ye+"Milliseconds",3);default:return this.clone()}},b.endOf=function(w){return this.startOf(w,!1)},b.$set=function(w,R){var I,M=x.p(w),k="set"+(this.$u?"UTC":""),Y=(I={},I[c]=k+"Date",I[m]=k+"Date",I[f]=k+"Month",I[y]=k+"FullYear",I[l]=k+"Hours",I[a]=k+"Minutes",I[i]=k+"Seconds",I[o]=k+"Milliseconds",I)[M],q=M===c?this.$D+(R-this.$W):R;if(M===f||M===y){var G=this.clone().set(m,1);G.$d[Y](q),G.init(),this.$d=G.set(m,Math.min(this.$D,G.daysInMonth())).$d}else Y&&this.$d[Y](q);return this.init(),this},b.set=function(w,R){return this.clone().$set(w,R)},b.get=function(w){return this[x.p(w)]()},b.add=function(w,R){var I,M=this;w=Number(w);var k=x.p(R),Y=function(W){var z=$(M);return x.w(z.date(z.date()+Math.round(W*w)),M)};if(k===f)return this.set(f,this.$M+w);if(k===y)return this.set(y,this.$y+w);if(k===c)return Y(1);if(k===u)return Y(7);var q=(I={},I[a]=r,I[l]=s,I[i]=n,I)[k]||1,G=this.$d.getTime()+w*q;return x.w(G,this)},b.subtract=function(w,R){return this.add(-1*w,R)},b.format=function(w){var R=this,I=this.$locale();if(!this.isValid())return I.invalidDate||E;var M=w||"YYYY-MM-DDTHH:mm:ssZ",k=x.z(this),Y=this.$H,q=this.$m,G=this.$M,W=I.weekdays,z=I.months,ye=I.meridiem,Se=function(ne,fe,ce,Ce){return ne&&(ne[fe]||ne(R,M))||ce[fe].slice(0,Ce)},_e=function(ne){return x.s(Y%12||12,ne,"0")},me=ye||function(ne,fe,ce){var Ce=ne<12?"AM":"PM";return ce?Ce.toLowerCase():Ce};return M.replace(_,(function(ne,fe){return fe||(function(ce){switch(ce){case"YY":return String(R.$y).slice(-2);case"YYYY":return x.s(R.$y,4,"0");case"M":return G+1;case"MM":return x.s(G+1,2,"0");case"MMM":return Se(I.monthsShort,G,z,3);case"MMMM":return Se(z,G);case"D":return R.$D;case"DD":return x.s(R.$D,2,"0");case"d":return String(R.$W);case"dd":return Se(I.weekdaysMin,R.$W,W,2);case"ddd":return Se(I.weekdaysShort,R.$W,W,3);case"dddd":return W[R.$W];case"H":return String(Y);case"HH":return x.s(Y,2,"0");case"h":return _e(1);case"hh":return _e(2);case"a":return me(Y,q,!0);case"A":return me(Y,q,!1);case"m":return String(q);case"mm":return x.s(q,2,"0");case"s":return String(R.$s);case"ss":return x.s(R.$s,2,"0");case"SSS":return x.s(R.$ms,3,"0");case"Z":return k}return null})(ne)||k.replace(":","")}))},b.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},b.diff=function(w,R,I){var M,k=this,Y=x.p(R),q=$(w),G=(q.utcOffset()-this.utcOffset())*r,W=this-q,z=function(){return x.m(k,q)};switch(Y){case y:M=z()/12;break;case f:M=z();break;case h:M=z()/3;break;case u:M=(W-G)/6048e5;break;case c:M=(W-G)/864e5;break;case l:M=W/s;break;case a:M=W/r;break;case i:M=W/n;break;default:M=W}return I?M:x.a(M)},b.daysInMonth=function(){return this.endOf(f).$D},b.$locale=function(){return B[this.$L]},b.locale=function(w,R){if(!w)return this.$L;var I=this.clone(),M=F(w,R,!0);return M&&(I.$L=M),I},b.clone=function(){return x.w(this.$d,this)},b.toDate=function(){return new Date(this.valueOf())},b.toJSON=function(){return this.isValid()?this.toISOString():null},b.toISOString=function(){return this.$d.toISOString()},b.toString=function(){return this.$d.toUTCString()},g})(),O=H.prototype;return $.prototype=O,[["$ms",o],["$s",i],["$m",a],["$H",l],["$W",c],["$M",f],["$y",y],["$D",m]].forEach((function(g){O[g[1]]=function(b){return this.$g(b,g[0],g[1])}})),$.extend=function(g,b){return g.$i||(g(b,H,$),g.$i=!0),$},$.locale=F,$.isDayjs=L,$.unix=function(g){return $(1e3*g)},$.en=B[v],$.Ls=B,$.p={},$}))})(gt)),gt.exports}var Ec=pc();const X=kt(Ec),Ac=e=>e.defaultValue||e.defaultObjectValue,yc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?X().format("DD-MM-YYYY"):n},Sc=(e,t)=>{const n={...e};let r=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(r={...n.literal}),n.sourced&&(r=r??{},Object.keys(n.sourced).every(s=>{const o=typeof n.sourced[s]=="string"&&oe(t,n.sourced[s]);return o===void 0&&n.skipIfSourceInvalid?(r=null,!1):(r[s]=o||n.sourced[s],!0)})),r},ws=(e,t)=>Ac(e)?e.type===N.DATE?yc(e):(e.defaultObjectValue?Sc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Tc={[N.COLLECTION]:[],[N.CONTAINER]:{}},gc=(e,t)=>e&&(ws(e,t)||Tc[e.type])||"",ot={clean:re,defaultValue:gc,defaultValueFromConfig:ws,editable:Ts,elevateNested:Ze,get:Cs,setupContainerPaths:ys,show:ve,wrap:Je},Cc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Qe(t.formData[e.id],n)&&n.nested.forEach(r=>{const s=r;s.value=t.formData[s.id]})})},Yt=(e,t,n)=>{let r="";return e.formData&&t.fieldId&&(r=e.formData[t.fieldId],Cc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:C.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ot.editable(t)?t:void 0,value:r||"",action:e.cya_link?.singleChangeLink?null:jt(t.readonly,e,n)}},Ve=(e,t,n,r,s)=>xt(t,{...e.formData,...n})?Ze(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>xt(i,{...e.formData,...n})).flatMap(i=>{const a=n?n[i.fieldId]:void 0;if(typeof s=="function"){const l=s({...e,formData:n},i,r);if(l)return l}return i.type===N.CONTAINER?Ve(e,i,{...a,...n},r,s):i.type===N.COLLECTION?vn(e,i,a,r,s):Yt({...e,formData:n},i,r)}):null,wc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{D.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ur=(e,t,n="text")=>{if(typeof e=="string")return C.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const r=e.find(s=>typeof s=="string"?!0:Me(s.show_when,t));return typeof r=="string"?C.Utils.interpolateString(r,t):C.Utils.interpolateString(r[n],t)},bc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},_c=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return Q.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return Q.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),bc(n)}}).filter(t=>!!t)},xc=e=>({type:N.HTML,tagName:"p",content:e}),Ic=(e,t)=>{const n=e.use.split("."),r=n.shift();let s=JSON.parse(JSON.stringify({...t.find(a=>a.id===r)})),o=s,i=s;for(;o&&n.length>0;){const a=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(l=>l.id===a),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]:s=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(a=>a.use?un(a,t):a)),s},un=(e,t)=>{if(e){const n=Ic(e,t);if(n)return n}return{...e}},bs=(e,t,n)=>{if(!e)return null;const r=e.components.map(o=>{if(typeof o=="string")return xc(o);let i;return o.type===N.CONTAINER&&(o.components=o.components.map(a=>a.use?un(a,t):a)),o.use?i=un(o,t):i={...o},n?he.refData.setupUrl(i,n):i}),s=_c(e);return $t.setup({...e,formData:n,components:r,actions:s})},Pc=(e,t,n)=>Array.isArray(e)?e.map((r,s)=>({...bs(r,t,n),index:s})):[],_s=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Mt(e,t),it={applyConditionalProperties:wc,getConditionalText:ur,get:bs,getAll:Pc,getTitle:(e,t)=>ur(e,t,"title"),show:Mt,showCYA:_s},vc=(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},Oc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},Bt=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},Dc=e=>typeof e=="number"&&e>=0,xs=(e,t,n)=>{const r=e[0];if(e.length===1)return t[r]||null;const s=n?.[`${r}ActiveId`]||null;if(!s)return null;const o=t[r]?.findIndex(i=>i.id===s);return Dc(o)?(e.shift(),xs(e,t[r][o],n)):null},qe=(e,t)=>{const n=e.split(".");return xs(n,t,t)},Is=(e,t,n,r=[],s={})=>{const o=qe(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const a=Ot.v4(),l={...i,...s,id:a};r.forEach(u=>delete l[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(l):o.splice(c,0,l),t[`${e.split(".").pop()}ActiveId`]=l.id,a},Nc=(e,t)=>{const n=Bt(e,t);return Is(e,t,n)},Rc=e=>typeof e=="number"&&e>=0,Ps=(e,t,n)=>{const r=e[0],s=n?.[`${r}ActiveId`]||null;if(!s)return null;const o=t[r]?.findIndex(i=>i.id===s);return Rc(o)?e.length===1?o:(e.shift(),Ps(e,t[r][o],n)):null},vs=(e,t)=>{const n=e.split(".");return Ps(n,t,t)},Lc=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]}),Fc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},$c=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const r=n.join("."),s=t[r]||null;return s?(s.childPages.push(e),s.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},Os=e=>{const t={};return e.map((r,s)=>{if(r.orderInForm=s,r?.collection?.name){if(!t[r.collection.name]){const o=Lc(r);return t[r.collection.name]=o,o}return Fc(r,t[r.collection.name]),null}return r}).filter(r=>!!r).map(r=>r.collection?.masterPage&&$c(r,t)?null:r).filter(r=>!!r)},Mc=(e,t,n)=>{const r=qe(e,t);if(!r)return null;const s=r.findIndex(a=>a.id===n);if(s===-1)return null;const o=r[s];r.splice(s,1);const i=t;return i[`${e}ActiveId`]=r.length>0?r[0].id:null,o},jc=e=>typeof e=="number"&&e>=0,On=(e,t,n)=>{const r=e.split("."),s=r[r.length-1];let o=n;r.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=Ot.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===s)return o[s]=t,!0;const a=n[`${i}ActiveId`],l=o[i]?.findIndex(c=>c.id===a);return jc(l)?(o=o[i][l],!1):!0})},It={addEntry:Oc,duplicateActiveEntry:Nc,duplicateEntry:Is,getActiveId:Bt,getActiveIndex:vs,getData:qe,getErrorsForCollection:wn,mergePages:Os,removeEntry:Mc,setData:On},Uc=e=>typeof e=="number"&&e>=0,kc=(e,t,n,r,s,o)=>{const i=s?.label||ke.remove;return{pageId:e.id,fieldId:`delete${r}`,key:`delete${r}`,type:"action",action:{onAction:()=>{n(null,l=>{const c=l;if(!o)return c;Object.entries(o).forEach(h=>{const[y,m]=h;c[y]=m});const u=It.getData(e.collection.name,c),f=u?.findIndex(h=>h.id===t.id);return Uc(f)&&u.splice(f,1),c})},label:C.Utils.interpolateString(i,{...t,index:r})}}},Yc=(e,t,n,r,s,o={})=>{const i=s?.label||ke.change;return{pageId:e.id,fieldId:`change${r}${s.page}`,key:`change${r}${s.page}`,type:"action",action:{onAction:a=>{const l=c=>{const u=c;return Object.entries(o).forEach(f=>{const[h,y]=f;u[h]=y}),u};n(s.page?{pageId:s.page}:a,l)},label:C.Utils.interpolateString(i,{...t,index:r})}}},Bc=(e,t)=>t.show_when?Me(t.show_when,e):!0,Hc=(e,t,n,r)=>({id:t.id,fieldId:t.id,type:N.CONTAINER,required:!0,full_path:r,components:e.components.map(s=>({...s,label:C.Utils.interpolateString(s.label,{...t,index:n}),full_path:`${r}.${s.fieldId}`}))}),Vc=(e,t,n,r,s)=>{const o={...ke,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${s}.Title`,key:C.Utils.interpolateString(o.item,{...t,index:r}),type:"heading",size:e.collection.titleSize||"s"}},qc=(e,t,n,r,s)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:C.Utils.interpolateString(e.text,s),type:r===null?"heading":"headingWithAction",size:e.size||"s",action:r===null?null:{onAction:r,label:"Change"}},Gc=(e,t,n,r)=>({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:r==null?"heading":"headingWithAction",size:n?.size||"m",action:r===null?null:{onAction:r,label:"Change"}}),Kc=(e,t,n,r,s,o={})=>e.collection?.actions?.filter(i=>Bc(s,i)).map(i=>i.type==="remove"?kc(e,t,n,r,i,o):i.type==="change"?Yc(e,t,n,r,i,o):null).filter(i=>!!i),Ds=(e,t,n={})=>()=>{const r=s=>{const o=s;return Object.entries(n).forEach(i=>{const[a,l]=i;o[a]=l}),o};t({pageId:e.id},r)},Wc=(e,t,n,r,s,o,i)=>{let a=[];return e.forEach(l=>{let c=l;if(c.collection.masterPage)a=a.concat(Ns(c,n,r,t,i));else if(c.collection.route&&(c=vc(c,c.collection.route)||c),_s(c,{...c.formData,...t})){const u=Ds(c,n,i);if(c.collection.heading){const y=c.collection.heading.changeLink?u:null,m=qc(c.collection.heading,c.id,s,y,t);a=a.concat(m)}const f=Hc(c,t,s,o),h=Ve({...c,formData:{...c.formData,...t}},f,{...c.formData,...t},u,r);a=a.concat(h)}}),a},Ns=(e,t,n,r,s={})=>{const o=e.collection.name.split(".").pop();let i=r[o]||null;const a=r[`${o}ActiveId`];if(!i||i.length===0)return[];let l=[];if(!e.collection.hideNameFromCYA){const h=e.collection.collectionHeading?.changeLinkPage?Ds({id:e.collection.collectionHeading.changeLinkPage},t,s):null;l.push(Gc(e,o,e.collection.collectionHeading,h))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Me(e.collection.hideItemTitles,r):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Me(e.collection.onlyShowActiveEntryOnCYA,r):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((y,m)=>(c=m,y.id===a))]),i.forEach(h=>{if(!h)return;s={...s,[`${o}ActiveId`]:h.id};const y=c+1,m=e.collection?.actionPosition||"top",E=`${e.collection.name}[${c}]`,p=Kc(e,h,t,y,r,s);if(!u){const _=Vc(e,h,e.id,y,E);l=l.concat(_)}m==="top"&&(l=l.concat(p)),l=l.concat(Wc(e.childPages,h,t,n,y,E,s)),m==="bottom"&&(l=l.concat(p)),c+=1}),l.filter(h=>!!h)},zc=e=>e.value?e.component?d.jsx("div",{children:d.jsx(He,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,Jc=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(s=>{const o=t.findIndex(i=>i.id===s);return n<0&&(n=o),o>-1?zc(t[o]):null})}),firstComponentIndex:n}},Xc=(e,t,n,r)=>{const{value:s,firstComponentIndex:o}=Jc(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:s,action:jt(!1,e,r)},insertAt:o}},Qc=(e,t,n=null)=>{if(it.showCYA(e,e.formData)){if(e.collection)return Ns(e,t,n,e.formData);const s=Ze(e.components,e.formData).filter(o=>xt(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case N.CONTAINER:return Ve(e,o,e.formData[o.fieldId],t,n);case N.COLLECTION:return vn(e,o,e.formData[o.fieldId],t,n);default:return Yt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:a,insertAt:l}=Xc(e,i,s,t);l>-1?s.splice(l,0,a):s.push(a)});const o=e.groups.flatMap(i=>i.components);return s.filter(i=>!o.includes(i.id))}return s}return[]},Zc={getRows:Qc,getCYARowsForContainer:Ve},Rs=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},Ls=(e,t,n)=>{const r=t;e.format&&e.format.on===n&&(r[e.fieldId]=Rs(e.format,r[e.fieldId]))},Fs=(e,t,n)=>{e.forEach(r=>Ls(r,t,n))},$s=(e,t,n)=>{Fs(e.components,t,n)},eu=(e,t,n)=>{e.forEach(r=>$s(r,t,n))},tu=(e,t,n)=>{const r={...t};return Fs(e.components,r,n),eu(e.pages,r,n),r},nu={component:Ls,data:Rs,form:tu,page:$s},ru=(e,t,n,r)=>{if(e===se.HUB&&t){if(t.format===Ae.CYA)return Ae.CYA;if(t.components)return it.get(t,n,r)}if(e===se.TASK||e===se.FORM_WITH_TASK)return Ae.TASK},su={get:ru},Dn="meta",Nn="documents",dn=e=>e?.[Dn]?.[Nn]||[],ou=(e,t,n,r)=>{const s=r?dn(t):dn(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{s.push({...i,field:n})}),{...t?t[Dn]:void 0,[Nn]:s}},iu={setForField:ou,get:dn,name:Nn},au={documents:iu,name:Dn},lu=(e,t)=>{if(e?.field){const n=C.Utils.interpolateString(e.field,t);return!!oe(t,n)}return!1},zt=(e,t)=>{if(e?.value)return e.value;const n=C.Utils.interpolateString(e?.field,t);return oe(t,n)},cu=(e,t)=>{if(!e||!t)return null;const n=C.Utils.interpolateString(e.target,t),r=oe(t,n),s=zt(e,t),o=zt(e.cutoff,t),i=zt(e.ignore,t);let a=null;return r&&s&&Array.isArray(r)&&r.every((l,c)=>c===o?!1:c===i?!0:l===s||e.key&&oe(l,e.key)===s?(a=c,!1):!0),typeof a=="number"?a.toString():a},uu=(e,t,n)=>{let r;if(e?.field){const s=C.Utils.interpolateString(e.field,t);r=oe(t,s)}else r=e?.value;r!=null&&e.name&&t[e.name]!==r&&n({target:{name:e.name,value:r}})},du=(e,t)=>{if(e?.field){const n=C.Utils.interpolateString(e.field,t);return oe(t,n)||null}return e?.value||null},fu=(e,t,n)=>{const r=t;e?.field&&e?.component&&(delete r[e.field],n({target:{name:e.field,value:null,component:e.component}}))},hu=(e,t)=>{if(e?.condition){const n=e,r=C.Utils.interpolateString(n.field,t),s=oe(t,r);switch(n.condition){case"changes":{const o=`${r}LastValue`,i=n[o]||null;return i===null?(n[o]=s,!1):s!==i?(n[o]=s,!0):!1}case"isTruthy":return!!s;case"isFalsy":return!s;default:return!1}}return!0},mu=(e,t)=>{if(e?.fields){let n;return e.fields.find(r=>{const s=C.Utils.interpolateString(r,t),o=oe(t,s);return o?(n=o,!0):!1}),n||(e.fallback?C.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},pu=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let r="";n.forEach(i=>{if(r!==""&&(r+="."),i.slice(-2)==="[]"){const a=i.slice(0,-2),l=vs(a,t);r+=`${a}[${l}]`}else r+=i});const s=C.Utils.interpolateString(r,t);return oe(t,s)?.length||0},Eu=(e,t)=>{const n=C.Utils.interpolateString(e.target,t),r=oe(t,n);return r&&Array.isArray(r)?r.some(s=>e.key?oe(s,e.key)===e.value:s===e.value):r&&typeof r=="object"?oe(r,e.key)===e.value:!1},Au={checkValueIsTruthy:lu,getIndexOfMatchingValueIn:cu,doesContainValue:Eu,persistValueInFormData:uu,setValueInFormData:du,deleteValueInFormData:fu,getLength:pu,getFirstOf:mu},yu=(e,t,n)=>{const r=Au[e.function];if(typeof r=="function")return r(e,t,n)},Su=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(r=>{if(hu(r.run_when,t)){const s=yu(r,t,n);if(r.output){const o=C.Utils.interpolateString(r.output,t).replace("[",".").replace("]","");$r(t,o,s)}}}),t),Tu={runPageOperations:Su},gu=(e,t,n,r)=>!(e!==t.base&&r[t.check]),Cu=(e,t,n)=>{const r=e[n.id]?.[t.base],s=e[n.id]?.[t.check],o=s&&s?.length>0;return!!(r||o)};var Ct={exports:{}},wu=Ct.exports,dr;function bu(){return dr||(dr=1,(function(e,t){(function(n,r){e.exports=r()})(wu,(function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,s=/\d/,o=/\d\d/,i=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,l={},c=function(p){return(p=+p)+(p>68?1900:2e3)},u=function(p){return function(_){this[p]=+_}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(p){(this.zone||(this.zone={})).offset=(function(_){if(!_||_==="Z")return 0;var U=_.match(/([+-]|\d\d)/g),T=60*U[1]+(+U[2]||0);return T===0?0:U[0]==="+"?-T:T})(p)}],h=function(p){var _=l[p];return _&&(_.indexOf?_:_.s.concat(_.f))},y=function(p,_){var U,T=l.meridiem;if(T){for(var P=1;P<=24;P+=1)if(p.indexOf(T(P,0,_))>-1){U=P>12;break}}else U=p===(_?"pm":"PM");return U},m={A:[a,function(p){this.afternoon=y(p,!1)}],a:[a,function(p){this.afternoon=y(p,!0)}],Q:[s,function(p){this.month=3*(p-1)+1}],S:[s,function(p){this.milliseconds=100*+p}],SS:[o,function(p){this.milliseconds=10*+p}],SSS:[/\d{3}/,function(p){this.milliseconds=+p}],s:[i,u("seconds")],ss:[i,u("seconds")],m:[i,u("minutes")],mm:[i,u("minutes")],H:[i,u("hours")],h:[i,u("hours")],HH:[i,u("hours")],hh:[i,u("hours")],D:[i,u("day")],DD:[o,u("day")],Do:[a,function(p){var _=l.ordinal,U=p.match(/\d+/);if(this.day=U[0],_)for(var T=1;T<=31;T+=1)_(T).replace(/\[|\]/g,"")===p&&(this.day=T)}],w:[i,u("week")],ww:[o,u("week")],M:[i,u("month")],MM:[o,u("month")],MMM:[a,function(p){var _=h("months"),U=(h("monthsShort")||_.map((function(T){return T.slice(0,3)}))).indexOf(p)+1;if(U<1)throw new Error;this.month=U%12||U}],MMMM:[a,function(p){var _=h("months").indexOf(p)+1;if(_<1)throw new Error;this.month=_%12||_}],Y:[/[+-]?\d+/,u("year")],YY:[o,function(p){this.year=c(p)}],YYYY:[/\d{4}/,u("year")],Z:f,ZZ:f};function E(p){var _,U;_=p,U=l&&l.formats;for(var T=(p=_.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function($,x,H){var O=H&&H.toUpperCase();return x||U[H]||n[H]||U[O].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(g,b,w){return b||w.slice(1)}))}))).match(r),P=T.length,v=0;v<P;v+=1){var B=T[v],S=m[B],L=S&&S[0],F=S&&S[1];T[v]=F?{regex:L,parser:F}:B.replace(/^\[|\]$/g,"")}return function($){for(var x={},H=0,O=0;H<P;H+=1){var g=T[H];if(typeof g=="string")O+=g.length;else{var b=g.regex,w=g.parser,R=$.slice(O),I=b.exec(R)[0];w.call(x,I),$=$.replace(I,"")}}return(function(M){var k=M.afternoon;if(k!==void 0){var Y=M.hours;k?Y<12&&(M.hours+=12):Y===12&&(M.hours=0),delete M.afternoon}})(x),x}}return function(p,_,U){U.p.customParseFormat=!0,p&&p.parseTwoDigitYear&&(c=p.parseTwoDigitYear);var T=_.prototype,P=T.parse;T.parse=function(v){var B=v.date,S=v.utc,L=v.args;this.$u=S;var F=L[1];if(typeof F=="string"){var $=L[2]===!0,x=L[3]===!0,H=$||x,O=L[2];x&&(O=L[2]),l=this.$locale(),!$&&O&&(l=U.Ls[O]),this.$d=(function(R,I,M,k){try{if(["x","X"].indexOf(I)>-1)return new Date((I==="X"?1e3:1)*R);var Y=E(I)(R),q=Y.year,G=Y.month,W=Y.day,z=Y.hours,ye=Y.minutes,Se=Y.seconds,_e=Y.milliseconds,me=Y.zone,ne=Y.week,fe=new Date,ce=W||(q||G?1:fe.getDate()),Ce=q||fe.getFullYear(),Fe=0;q&&!G||(Fe=G>0?G-1:fe.getMonth());var $e,at=z||0,lt=ye||0,Ke=Se||0,K=_e||0;return me?new Date(Date.UTC(Ce,Fe,ce,at,lt,Ke,K+60*me.offset*1e3)):M?new Date(Date.UTC(Ce,Fe,ce,at,lt,Ke,K)):($e=new Date(Ce,Fe,ce,at,lt,Ke,K),ne&&($e=k($e).week(ne).toDate()),$e)}catch{return new Date("")}})(B,F,S,U),this.init(),O&&O!==!0&&(this.$L=this.locale(O).$L),H&&B!=this.format(F)&&(this.$d=new Date("")),l={}}else if(F instanceof Array)for(var g=F.length,b=1;b<=g;b+=1){L[1]=F[b-1];var w=U.apply(this,L);if(w.isValid()){this.$d=w.$d,this.$L=w.$L,this.init();break}b===g&&(this.$d=new Date(""))}else P.call(this,v)}}}))})(Ct)),Ct.exports}var _u=bu();const Ge=kt(_u),xu=e=>/^-?\d+$/.test(e),Pt=e=>xu(e)?e.padStart(2,"0"):"",xe=e=>{const[t,n,r]=e.split("-");return`${Pt(t)}-${Pt(n)}-${r}`},Ms=e=>{const[t,n]=e.split(":");return`${Pt(t)}:${Pt(n)}`},we="DD-MM-YYYY";X.extend(Ge);const Iu=(e,t)=>{const n=t.date?X(xe(t.date),we):X().add(t.value,t.unit);return X(xe(e),we).isAfter(n)};X.extend(Ge);const Pu=(e,t)=>{const n=t.date?X(xe(t.date),we):X().add(t.value,t.unit);return X(xe(e),we).isBefore(n)};X.extend(Ge);const vu=(e,t,n)=>{const r=n.components?.find(c=>c.fieldId===t.date),s=n.components?.find(c=>c.fieldId===t.time);if(!r||!s||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Xe(r,e[n.fieldId],e[n.fieldId])||Xe(s,e[n.fieldId],e[n.fieldId]))return!0;const a=xe(e[n.fieldId]?.[t.date]),l=Ms(e[n.fieldId]?.[t.time]);return X(`${a} ${l}`,`${we} HH:mm`).isBefore(X())};var wt={exports:{}},Ou=wt.exports,fr;function Du(){return fr||(fr=1,(function(e,t){(function(n,r){e.exports=r()})(Ou,(function(){return function(n,r,s){r.prototype.isToday=function(){var o="YYYY-MM-DD",i=s();return this.format(o)===i.format(o)}}}))})(wt)),wt.exports}var Nu=Du();const Rn=kt(Nu);X.extend(Ge);X.extend(Rn);const Ru=(e,t)=>{const n=X(xe(e),we).isBefore(X()),r=X(xe(e),we).isToday();return n&&!r?!0:r&&!!t?.todayAllowed};X.extend(Ge);X.extend(Rn);const Lu=(e,t)=>X(xe(e),we).isAfter(X())?!0:!!t?.todayAllowed&&X(xe(e),we).isToday(),Fu=(e,t)=>e?e.length>t.value:!0,$u=(e,t)=>e?e.length<t.value:!0,Mu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},ju=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},Uu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,ku=(e,t)=>e?t.array.includes(e):!0,Yu=(e,t,n,r)=>{if(!e||!r)return!0;const s=Bt(t.collectionPath,r);return!qe(t.collectionPath,r)?.some(a=>a.id===s?!1:t.caseInsensitive&&typeof e=="string"&&typeof a[n.id]=="string"?a[n.id].toUpperCase()===e.toUpperCase():a[n.id]===e)},Bu=(e,t,n)=>n.components?.some(r=>!!e[n.id]?.[r.id]),Hu=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Vu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,qu=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Vu.test(t)}return!1},Gu=(e,t,n)=>n.components?.reduce((s,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?s:s+1:s,0)<2,Ku={conditionallyPermittedChange:gu,conditionallyRequired:Cu,mustBeAfter:Iu,mustBeBefore:Pu,mustBeEarlierDateTime:vu,mustBeGreaterThan:Mu,mustBeInTheFuture:Lu,mustBeInThePast:Ru,mustBeLessThan:ju,mustBeLongerThan:Fu,mustBeNumbersOnly:Uu,mustBeOneOf:ku,mustBeShorterThan:$u,mustBeUniqueInCollection:Yu,mustEnterAtLeastOne:Bu,mustHaveLessThanDecimalPlaces:Hu,mustNotContainSql:qu,mustSelectOnlyOne:Gu},Wu=(e,t,n,r)=>{const s=Ku[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof s=="function")return s(o,t,n,r)?void 0:t.message},js=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let r;return e.additionalValidation.forEach(s=>{r||(r=Wu(t,s,e,n))}),r}},vt=(e,t,n)=>{if(!e)return[];const r=n||t,s=js(e,r);if(s)return{id:e.id,error:s};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;Ze(e.components,i).forEach(l=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${l.fieldId}`:l.fieldId;o.push(Xe({...l,full_path:c},i,r))})}return o.flat(1).filter(i=>!!i)},zu=(e,t,n)=>{const r=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((s,o)=>{const i=(e.countOffset||0)+o+1,a=`${e.full_path||e.fieldId}[${o}]`,l={full_path:a,components:e.item.map(c=>{const u={...c,full_path:`${a}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(f=>({...f,message:C.Utils.interpolateString(o===0&&f.firstOnlyMessage?f.firstOnlyMessage:f.message,{index:i})}))),u})};r.push(vt(l,s,n))}),r.filter(s=>!!s).flat()};var bt={exports:{}},Ju=bt.exports,hr;function Xu(){return hr||(hr=1,(function(e,t){(function(n,r){e.exports=r()})(Ju,(function(){return function(n,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}}))})(bt)),bt.exports}var Qu=Xu();const Zu=kt(Qu);X.extend(Ge);X.extend(Rn);X.extend(Zu);const ed=(e,t)=>e==="02"?X().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,Us=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=xe(e),[n,r,s]=t.split("-"),o=parseInt(n,10),i=parseInt(r,10),a=[],l=[];if(s.length===0?(a.push("year"),l.push("Date must include a year")):s.length!==4&&(a.push("year"),l.push("Year must be 4 numbers")),r.length===0?(a.push("month"),l.push("Date must include a month")):(i>12||i<1)&&(a.push("month"),l.push("Month must be between 1 and 12")),n.length===0)a.push("day"),l.push("Date must include a day");else{const c=ed(r,s);(o>c||o<1)&&(a.push("day"),l.push(`Day must be between 1 and ${c}`))}if(a.length>0){const c={};return a.includes("day")&&(c.day=!0),a.includes("month")&&(c.month=!0),a.includes("year")&&(c.year=!0),{message:a.length===1?l[0]:"Enter a valid date",propsInError:c}}return X(t,we).format(we)!==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,ks=(e,t="",n=[])=>{if(e){const r=t?t.toLowerCase():"email address";if(typeof e=="string"&&(td.test(e)||nd.test(e)))return;if(Array.isArray(n)){const s=n.filter(o=>o.type==="format");if(s&&s.length>0&&s[0].message)return s[0].message}return`Enter ${r} in the correct format, like jane.doe@homeoffice.gov.uk`}},rd="Invalid files must be deleted",Ys=(e,t)=>{if(!e)return;let n=!1;if(e.every(r=>(n=r.error,!n)),n){if(Array.isArray(t)){const r=t.filter(s=>s.type==="invalidFile");if(r&&r.length>0&&r[0].message)return r[0].message}return rd}},Bs=(e,t,n,r)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(r)){const o=r.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},Hs=(e,t,n)=>{let r=!1;if((e||e===!1||e===0)&&(r=!0,typeof e=="string"?r=e.trim().length>0:Array.isArray(e)&&(r=e.length>0)),!r){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`}},Vs=(e,t,n,r,s,o=1e3)=>{if(!n||!s&&!t)return;if(s&&!t||t.length>o){if(Array.isArray(r)){const a=r.filter(l=>l.type==="length");if(a&&a.length>0&&a[0].message)return a[0].message}return`${e} must be ${o} characters or less`}},qs=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Ms(e),[n,r]=t.split(":"),s=parseInt(n,10),o=parseInt(r,10),i=[],a=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),a.push("Enter a valid time")),n.length===0?(i.push("hour"),a.push("Time must include a hour")):(s>23||s<0)&&(i.push("hour"),a.push("Hour must be between 0 and 23")),r.length===0?(i.push("minute"),a.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),a.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":a[0],propsInError:c}}return{message:void 0,propsInError:void 0}},sd=(e,t)=>e?.type==="or"?le.meetsOne(e.conditions,t):le.meetsAll(e.conditions,t),Xe=(e,t,n)=>{const r=n||t;if(!ve(e,{...r,...t}))return;if(e.type===N.CONTAINER)return vt(e,t,r);let s,o,a=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===N.COLLECTION_SUMMARY&&(a=qe(e.collectionName,r)),e.required&&(!e.requiredOverrideConditions||!sd(e.requiredOverrideConditions,r))&&(s=Hs(a,e.label,e.custom_errors)),!s){switch(e.type){case N.COLLECTION:return zu(e,a,r);case N.EMAIL:s=ks(a,e.label,e.custom_errors);break;case N.DATE:case N.TIME:{const l=e.type===N.DATE?Us:qs,{message:c,propsInError:u}=l(a);o=u,s=c;break}case N.CHECKBOXES:case N.RADIOS:{let l=[];if(e.data.options?.forEach(c=>{c.nested&&Qe(n[e.id],c)&&(l=l.concat(vt({components:c.nested},n)))}),l.length>0)return l;break}case N.MULTI_FILE:s=Ys(a,e.custom_errors);break;case N.TEXT_AREA:s=Vs(e.label,a,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!s&&e.pattern&&(s=Bs(a,e.label,e.pattern,e.custom_errors)),!s&&e.additionalValidation&&(s=js(e,a,n),e.type===N.DATE&&s&&(o={day:!0,month:!0,year:!0}))}if(s)return{id:e.full_path||e.id,error:s,properties:o}},od=(e,t=[])=>{let n=e.formData;if(e.collection){const r=It.getActiveIndex(e.collection.name,e.formData);r!==null&&(n={...e.formData,...It.getData(e.collection.name,e.formData)?.[r]})}return Mt(e,n)&&Array.isArray(e.components)?e.components.reduce((s,o)=>{if(!ve(o,n))return s;const a=(t.length>0?t.filter(l=>l.showFor?l.showFor===o.id:l.id===o.id):[]).concat(Xe(o,n,n));return s.concat(a).flat().map(l=>l&&{...l,error:C.Utils.interpolateString(l.error,n)})},[]).filter(s=>!!s).flat():[]},id={component:Xe,container:vt,email:ks,date:Us,multifile:Ys,page:od,regex:Bs,required:Hs,textarea:Vs,time:qs},D={CheckYourAnswers:Zc,CollectionPage:It,Component:ot,Condition:le,Container:$t,Data:he,Format:nu,FormPage:it,Hub:su,Meta:au,Operate:Tu,Validate:id,...C.Utils},ad="hods-form-container",Ln=({container:e,value:t=void 0,formData:n,onChange:r=void 0,wrap:s=!0,onTopLevelChange:o=void 0,...i})=>{const a=({target:f})=>{if(typeof r=="function")if(f.name===D.Meta.name)r({target:f});else{const h={...t,[f.name]:f.value};r({target:{name:e.fieldId,value:h}})}},l=f=>{const h=`${e.full_path||e.fieldId}.${f.fieldId}`;return f.type===N.CONTAINER?D.Container.show({...f,full_path:h},n):D.Component.show({...f,full_path:h},{...n,...oe(n,e.full_path)})},c=D.classBuilder(ad,[],e.className),u=C.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(C.MediumHeading,{children:e.title}),e.components&&e.components.filter(l).map((f,h)=>{const y=f.type===N.FILE?{}:"",m=t?t[f.fieldId]:y,E=`${e.full_path||e.fieldId}.${f.fieldId}`;return d.jsx(He,{...i,component:{...f,full_path:E,readonly:!!(e.readonly||f.readonly)},formData:n,value:m||y,wrap:s,onChange:a,onTopLevelChange:o},h)})]})},ld=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{}},mr=({group:e})=>{const[t,n]=j.useState({});return j.useEffect(()=>{n(ld(e))},[e,n]),e?.action?d.jsxs(C.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(C.SmallHeading,{children:e}),t==="m"&&d.jsx(C.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(C.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(C.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Pn,{row:{action:e.action}})})]}),dd="govuk-summary-list",fn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:r=!1,classBlock:s=dd,classModifiers:o=[],className:i="",showGroupAction:a=!0,...l})=>{const c=C.Utils.classBuilder(s,o,i),u=C.Utils.cleanHtmlAttributes(l);let f=null;if(r){const h=e.filter(y=>!!y.action);f=h?.length?h[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(h=>{const y=`${h.pageId}_${h.full_path||h.fieldId}`;return h.type==="title"?d.jsx(Es,{title:h.key,classes:c},y):h.type==="heading"?d.jsx(cd,{title:h.key,size:h.size||"s",classes:c},y):h.type==="headingWithAction"?d.jsx(ud,{row:h,classes:c,noChangeAction:t},y):h.type==="action"?t?null:d.jsx("div",{children:d.jsx(mr,{group:h})},`${y}-actions`):d.jsx(ps,{row:h,classes:c,showAction:!t},y)}).filter(h=>!!h),a&&r&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(mr,{group:f})})]})})},fd="hods-check-your-answers",hd="Check your answers",pr=9,md=({title:e=hd,titleSize:t="l",pages:n,actions:r=[],onAction:s,onRowAction:o,hide_page_titles:i=!1,hide_actions:a=!1,hide_title:l=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:f,groups:h,sections:y=[],type:m,hideBlankRows:E=!1,optionalFieldPlaceholder:p})=>{const[_,U]=j.useState([]),[T,P]=j.useState([]),{errors:v}=Be(),{hooks:B}=Oe();j.useEffect(()=>{const g=(R,I)=>D.CheckYourAnswers.getRows(R,o,B.onGetCYARows).map((k,Y)=>({...k,value:d.jsx(bn,{value:k.value,component:k.component,formData:R.formData,placeholder:p},`${I}_${Y}`)})),w=D.CollectionPage.mergePages(n).map((R,I)=>{const M=g(R,I);return M?.length?{...R,rows:M}:null}).filter(R=>!!R);U(w)},[n,o,U]);const S=i?0:pr,L=g=>g===_.length-1;j.useEffect(()=>{(()=>{const b=Array.isArray(h)?h.map(w=>w.pageId):[];P(b)})()},[P,h]);const F=B.onGetCYA({title:e,pages:n,actions:r,onAction:s,onRowAction:o,hidePageTitles:i,hideActions:a,hideTitle:l,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:f,groups:h,errors:v,sections:y,type:m});if(F)return F;const $=g=>T.includes(g),x=g=>h?.find(b=>b.pageId===g),H=(g,b)=>{if(!g.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[b==="s"&&d.jsx(C.SmallHeading,{children:D.FormPage.getTitle(g.title,g.formData)}),b==="m"&&d.jsx(C.MediumHeading,{children:D.FormPage.getTitle(g.title,g.formData)})]});const w=jt(!1,g,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[b==="s"&&d.jsx(C.SmallHeading,{children:D.FormPage.getTitle(g.title,g.formData)}),b==="m"&&d.jsx(C.MediumHeading,{children:D.FormPage.getTitle(g.title,g.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Pn,{row:{action:w}})})]})},O=()=>Array.from(new Set(v.map(b=>b.id))).map(b=>v.find(w=>w.id===b));return d.jsxs("div",{className:fd,children:[e&&!l&&d.jsx(C.Heading,{size:t,children:e},"heading"),v&&v.length>0&&d.jsx(C.ErrorSummary,{errors:O()}),m===se.TASK_CYA&&_.length>0&&y&&y.map(g=>g.tasks.filter(b=>b.state!==J.TYPES.SKIPPED).map((b,w)=>{const R=_.filter(I=>b.pages.some(M=>M===I.name));return d.jsxs(j.Fragment,{children:[d.jsx(C.MediumHeading,{children:R.length>0&&(b.displayName||b.name)}),R.map((I,M)=>{const k=$(I.id)||u,Y=!i&&I.title&&!$(I.id);return d.jsxs(j.Fragment,{children:[Y&&H(I,"s"),d.jsx(fn,{rows:I.rows,classModifiers:c,noChangeAction:k,noGroupAction:f,isGroup:$(I.id)})]},M)})]},w)})),m!==se.TASK_CYA&&_&&_.map((g,b,w)=>{const R=!E||g.collection?g.rows:g.rows.filter(G=>G?.value?.props?.value);if(R.length===0)return null;const I=!i&&g.title&&!$(g.id),M=L(b)||$(w[b].id)||w.length>b+1&&$(w[b+1].id)?pr:S,k=$(g.id)?x(g.id):void 0,Y=`govuk-!-margin-bottom-${M}`,q=$(g.id)||u;return d.jsxs(j.Fragment,{children:[I&&H(g,"m"),k&&d.jsx("div",{className:"group-title",children:d.jsx(C.MediumHeading,{children:k.title||D.FormPage.getTitle(g.title,g.formData)})}),d.jsx(fn,{className:Y,rows:R,classModifiers:c,noChangeAction:q,noGroupAction:f,isGroup:$(g.id)})]},b)}),!a&&d.jsx(xn,{actions:r?.filter(g=>D.Component.show(g,n[n.length-1].formData)),onAction:g=>s(g)})]})},pd=hs,Ed=({page:e,pages:t,onCollectionChange:n=void 0,onAction:r,hashLink:s=!1,classBlock:o=pd,classModifiers:i=[],className:a="",submitting:l=!1})=>{const[c,u]=j.useState({});let f=D.CollectionPage.getData(e.collection.name,e.formData)||[];const h=e.collection.name.split(".").pop();let y=D.CollectionPage.getActiveIndex(e.collection.name,e.formData);const m=e,E=({target:v})=>{D.CollectionPage.setData(m.collection.name,v.value,e.formData),f=v.value;const B=e.collection.name.split(".").shift();u(S=>({...S,[B]:D.CollectionPage.getData(B,e.formData)}))},p=({target:v})=>{m.formData[v.name]=v.value,u(B=>({...B,[v.name]:v.value}))},_=v=>{E({target:{value:v}}),typeof n=="function"&&n(e.formData)},U=v=>{y=f.length,p({target:{name:`${h}ActiveId`,value:v}})},T=v=>{r(v,c,{})},P=({target:v})=>{if(y===null){const B=Ot.v4();U(B),_([...f,{id:B,[v.name]:v.value}])}else _([...f.slice(0,y),{...f[y],[v.name]:v.value},...f.slice(y+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(In,{page:{...e,formData:{...e.formData,...f[y],[`${h}ActiveIndex`]:y,[`${h}NumberedIndex`]:typeof y=="number"?y+1:null},components:e.components.map(v=>({...v,pageCollection:{...e.collection}}))},pages:t,onAction:T,onWrapperChange:P,onTopLevelChange:p,hashLink:s,classBlock:o,classModifiers:i,className:a,submitting:l})},Ad="hods-task-list",yd=({state:e=J.TYPES.CANNOT_START_YET})=>{const t=C.Utils.classBuilder(Ad,void 0,void 0),n=J.DETAILS[e]||J.DETAILS.cannotStartYet;return d.jsx(C.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Sd="hods-task-list",Td=({task:e,onClick:t})=>{const n=C.Utils.classBuilder(Sd,void 0,void 0),[r,s]=j.useState(e.state!==J.TYPES.CANNOT_START_YET),[o,i]=j.useState(e.state);j.useEffect(()=>{s(e.state!==J.TYPES.CANNOT_START_YET),i(e.state)},[e.state,s,i]);const a=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:r?d.jsx(C.Link,{onClick:()=>t(e),onKeyPress:l=>{l.key==="Enter"&&t(e)},tabIndex:0,children:a}):a}),d.jsx(yd,{state:o})]})},gd="hods-task-list",Cd="Incomplete form",wd=({id:e="",refTitle:t,refNumber:n,notes:r={},incompleteTitle:s=Cd,showCompletionOverview:o=!0,sections:i,fieldId:a="",onTaskAction:l,classBlock:c=gd,classModifiers:u=[],className:f="",formData:h={},annotations:y=[],...m})=>{const E=C.Utils.classBuilder(c,u,f),p=C.Utils.cleanHtmlAttributes(m),[_,U]=i.filter(S=>!S.skipped).reduce((S,L)=>[S[0]+(L.tasks?.filter(F=>F.state===J.TYPES.COMPLETE).length??0),S[1]+(L.tasks?.filter(F=>F.state!==J.TYPES.SKIPPED).length??0)],[0,0]),T=`${e}Notes`,{title:P,text:v}=r&&r||{},B=S=>{typeof l=="function"&&l(S)};return d.jsxs("div",{...p,id:e,className:E(),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:E("annotation"),children:[d.jsx("p",{className:`${E("annotation-key")} govuk-body`,children:C.Utils.interpolateString(S.key,h)}),d.jsx("p",{className:`${E("annotation-value")} govuk-body`,children:C.Utils.interpolateString(S.value,h)})]},S.key)),o&&U!==_&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:s})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${_} of ${U} sections`}),P&&v&&ve(r,h)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:C.Utils.interpolateString(P,h)})}),d.jsx(C.TextArea,{id:T,fieldId:T,readOnly:!0,value:C.Utils.interpolateString(v,h)})]}),i.filter(S=>!S.skipped).map((S,L)=>d.jsxs(j.Fragment,{children:[d.jsxs("h2",{className:E("section"),children:[i.length>1?`${L+1}. `:" ",S.name]}),S.label&&d.jsx(C.Hint,{children:S.label}),d.jsx("ol",{className:E("items"),children:S.tasks.filter(F=>F.state!==J.TYPES.SKIPPED).map(F=>d.jsx(Td,{task:F,onClick:B},`${S.name}-${F.name}`))})]},`${S.name}`))]})},Gs=(e,t)=>e?.page||t,bd=(e,t,n)=>{const r=Gs(e.action,e.pageId);r!==t&&n(r)},_d=(e,t,n,r=void 0)=>{const s=Gs(e,t);s!==t&&n(s,r)},xd=(e,t)=>{t(e)},ge={cyaAction:bd,navigate:_d,submissionError:xd},Id=(e,t,n,r)=>e.validate?e.checkPreexistingErrors&&r.length!==0?!1:n(t).length===0:!0,Pd=(e,t)=>t(e).length===0,vd=["radios","checkboxes"],Od=(e,t)=>{const n=e.split("."),r={};return n.forEach(s=>{r[`${s}ActiveId`]=t[`${s}ActiveId`]}),r};function Dd(e,t){const n=[];return e?.data?.options?.forEach(r=>{!Qe(t,r)&&r.nested&&r.nested.forEach(s=>{n.push(s.id)})}),n}const Ks=(e,t)=>{let n=e;if(t.components.forEach(r=>{if(!vd.includes(r.type))return;Dd(r,n[r.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Od(t.collection.name,t.formData),...n};const r=qe(t.collection.name,n);if(r){const s=Bt(t.collection.name,n),o=r.map(i=>i.id===s?Ks(i,{...t,collection:void 0}):i);On(t.collection.name,o,n)}}return n},Nd=(e,t,n)=>{if(e===ie.HUB&&n===Ae.CYA)return{title:""};if(e===ie.CYA)return{};const r=t?.find(s=>s.id===e);if(r?.type===ie.PARTIAL_CYA){const s=D.FormPage.applyConditionalProperties(r);return{title:s.title,hideChangeActions:s.hideChangeActions,hideGroupActions:s.hideGroupActions}}},Ws=(e,t,n)=>{if(e)return e===ie.HUB?n===Ae.CYA||n===Ae.TASK?void 0:n:t.find(r=>r.id===e)},Rd=(e,t,n)=>({pageId:e,cya:Nd(e,t,n),page:Ws(e,t,n)}),Er=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Ld=(e,t,n)=>e.page?.type===ie.PARTIAL_CYA?Er(n||t,e.pageId):n||t,Ar=(e,t,n,r,s)=>{if(!t&&s===se.FORM_WITH_TASK){if(r?.formStatus?.taskPage){const i=n.find(a=>a.id===r.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:ie.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{it.show({show_when:i.show_when},r)&&(o=i.pageId)}),o||e?.page||ie.HUB},zs=(e,t,n)=>{let r=e.findIndex(o=>o.id===t)+1,s=e[r];for(;s&&!it.show(s,n);)r+=1,s=e[r];return s?.id||void 0},Fd=(e,t,n)=>zs(e,t,n)||ie.CYA,$d=e=>e.length>0?e[0].id:void 0,hn=(e,t,n,r,s)=>{if(r){if(r.type===Q.TYPES.NAVIGATE)return t.find(o=>o.id===r.page)?r.page:void 0;if(r.type===Q.TYPES.SAVE_AND_RETURN)return e===se.HUB?ie.HUB:void 0}switch(e){case se.HUB:return Ar(r);case se.CYA:return Fd(t,n,s);case se.FORM_WITH_TASK:case se.TASK:return Ar(r,n,t,s,e);case se.WIZARD:return zs(t,n,s);default:return $d(t)}},Md=(e,t,n,r,s,o,i,a)=>{if(e===se.TASK||e===se.FORM_WITH_TASK){const l=s.formStatus||{};return l.tasks=l.tasks||{},l.tasks[o.name]=l.tasks[o.name]||{},n===(ie.CYA||"submitForm")&&i?l.tasks[o.name].complete=!0:o.name?r?.type===Q.TYPES.SAVE_AND_NAVIGATE?l.tasks[o.name]={complete:!1,currentPage:hn(e,t,n,r,s)}:o.pages?.includes(n)&&(l.tasks[o.name]={complete:!!r?.complete,currentPage:n}):a&&a.forEach(c=>{c.tasks.forEach(u=>{const f=u.pages[u.pages.length-1];(f===n||f.id===n)&&i&&u?.type==="pre-task-list"?l.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(l.tasks[u.name]={complete:!1,currentPage:n})})}),l.taskPage=l.tasks[o.name].currentPage,l}return r?.type===Q.TYPES.SAVE_AND_RETURN?{page:n}:{page:hn(e,t,n,r,s)}},jd=({complete:e,currentPage:t},n=J.TYPES.NOT_STARTED)=>e?J.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?J.TYPES.IN_PROGRESS:n,Ud=(e,t,n=!1)=>t.reduce((r,s)=>{const o=e[s];return n&&o?.state===J.TYPES.SKIPPED?r:r&&o?.complete},!0),Js=(e,t)=>{const n=e[t-1].state;return n===J.TYPES.COMPLETE?!0:n===J.TYPES.SKIPPED?t-1===0?!0:Js(e,t-1):!1},kd=(e,t,n,r,s=!1,o=!0)=>{if(r[e.name])return jd(r[e.name],e.state);if(s)return e.depends_on&&!Ud(r,e.depends_on,e.ignoreSkipped)?J.TYPES.CANNOT_START_YET:J.TYPES.NOT_STARTED;let i=o;return t&&(i=Js(n,t)),i?J.TYPES.NOT_STARTED:J.TYPES.CANNOT_START_YET},Yd=(e,t,n,r)=>{const s=e.tasks.map(o=>({...o}));return s.filter(o=>o.state!==J.TYPES.SKIPPED).forEach((o,i)=>{const a=o;a.state=kd(a,i,s,t,n,r)}),s},Xs=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===J.TYPES.COMPLETE?!0:n===J.TYPES.SKIPPED?t-1===0?!0:Xs(e,t-1):!1},Bd=(e,t,n=!1,r=null)=>{const s=e.map(i=>{const a=i.show_when?[i.show_when].flat():[];return r&&!D.Condition.meetsAll(a,r)?{...i,skipped:!0,tasks:i.tasks.map(l=>({...l,state:J.TYPES.SKIPPED}))}:{...i}});s.forEach(i=>{const a=i;a.tasks=a.tasks.map(l=>{const c=l.show_when?[l.show_when].flat():[];return r&&!D.Condition.meetsAll(c,r)?{...l,state:J.TYPES.SKIPPED}:{...l}})});const o={...t};return s.forEach(i=>{i.tasks.filter(a=>a.state===J.TYPES.SKIPPED).forEach(a=>{o[a.name]={...o[a.name],state:J.TYPES.SKIPPED}})}),s.forEach((i,a)=>{const l=i,c=a===0||Xs(s,a);l.tasks=Yd(l,o,n,c)}),s},Hd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},Ue=(e,t)=>{if(Array.isArray(e))for(let s=0;s<e.length;s+=1)Ue(e[s],t);const n=t.split(".");let r=e;for(let s=0;s<n.length-1;s+=1)if(r=r[n[s]],r===void 0)return;r[n[n.length-1]]&&delete r[n[n.length-1]]},Qs=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},Fn=(e,t)=>{const n=Qs(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,r)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(s=>{t(s,r)}):Object.keys(n).forEach(s=>{s==="field"&&r.push(n[s]),t(n[s],r)})),r);return e.show_when?new Set(t(e.show_when,[])||[]):null},Gd=(e,t)=>{const n=e.split(".");for(let r=n.length;r>0;r-=1){const s=n.slice(0,r).join("."),o=t.get(s);if(o)return o}return null},ze=(e,t)=>e.show_when?e.show_when?.type==="or"?le.meetsOne(e,t):le.meetsAll(e,t):!0,Zs=(e,t,n)=>{const r=t.get(e.use)??n.get(e.use)??e,s=JSON.parse(JSON.stringify(r));return e.use&&e.show_when&&(s.show_when=e.show_when),s},Kd=(e,t,n)=>{const{meta:{documents:r}}=n,s=t[e.fieldId];if(!r||!s)return;const o=Array.isArray(s)?s:[s];for(let i=o.length-1;i>=0;i-=1){const a=r.findIndex(l=>l.url===o[i].url);a!==-1&&r.splice(a,1)}},mn=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):mn(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):mn(e[t])})},eo=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Wd=(e,t,n,r)=>{if(r[t]>1)r[t]-=1;else{if(n.preserveInPayload)return;Ue(e,t),eo(n,s=>{const o=Fn(t,s.fieldId);r[o]>1?r[o]-=1:Ue(e,o)})}},zd=(e,t,n,r)=>{t.forEach(s=>{if(!e.has(s.fieldId)){if(s.type==="multifile"&&Kd(s,n,r),s.preserveInPayload)return;Ue(n,s.fieldId),eo(s,o=>{const i=Fn(s.fieldId,o.fieldId);e.has(i)||Ue(n,i)})}})},yr=e=>Array.isArray(e)?e:[e],Jd=(e,t,n,r)=>{const s=new Map,o={},i=[],a=new Map,l=(c,u,f)=>{u.fieldId&&(f=f?`${f}.${u.fieldId}`:u.fieldId,o[f]=(o[f]||0)+1,u.path=f,c.show_when&&(u.show_when=u.show_when?[...yr(c.show_when),...yr(u.show_when)]:c.show_when),Hd(f,u,s),u.components?u.components.forEach(h=>{l(c,h,f)}):u?.data?.options&&u?.data?.options?.forEach(h=>{if(h.nested){const y=!Qe(oe(r,f),h),m=h.show_when;h.nested.forEach(E=>{y&&i.push(Fn(f,E.fieldId)),m&&(E.show_when=m),l(c,E,Qs(f))})}}))};return e?.forEach(c=>{c.childPages?a.set(c.collection.name,c):c.components?.forEach(u=>{const f=Zs(u,t,n);l(c,f,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:Ue(r,c)}),{allComponents:s,componentsToKeep:o,allCollections:a}},Xd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(r=>{if(!r.fieldId)return;const s=qd(r);if(s)if(t.has(r.path)){const o=t.get(r.path);s.forEach(i=>o.add(i))}else t.set(r.path,new Set(s))})}),t},Qd=(e,t,n,r,s,o)=>{const i=(l,c,u)=>{if(l.has(c))return;l.add(c),u.get(c.path)?.forEach(h=>{const y=Gd(h,t);if(y)y.forEach(m=>{l.has(m)||i(l,m,u)});else{const m=/([a-zA-Z_$][\w$]*)\[\d+\]/,E=h.match(m);if(E){const p=E[1],_=r.get(p);_&&_.childPages?.forEach(U=>{if(U.show_when){const T=JSON.stringify(U.show_when),P=`It is not possible to reliably clean hidden data when a component is dependent on a
3
7
  collection's data, and that collection is itself dependent on data elsewhere in the form.
4
- The dependency path is ${f}, and the chained show_when is ${S}.
5
- The form will need to be changed to break this chained dependency`;throw new Error(w)}})}}}),Me(u,i)||ld(i,u.path,u,r)},o=new Set;e?.forEach((l,u)=>{t.get(u)?.forEach(c=>{o.has(c)||a(o,c,e)})})},hd=(e,t,r,n)=>{e?.forEach((s,i)=>{Me(s,t)||(delete t[i],delete t[`${i}ActiveId`]);const a=t[i];a?.forEach(o=>{const l={...t,...o},u=new Set,d=new Map;s.childPages?.forEach(c=>{const f=Me(c,l);c.components?.forEach(m=>{const A=vi(m,r,n);if(!A.fieldId)return;const T=Me(m,l);f&&T&&Me(A,l)?u.add(A.fieldId):d.set(A.id,A)})}),ud(u,d,o,t)}),a&&sd(a)})},md=(e,t,r)=>{if(!e)return r;const n=new Map(t.components.map(d=>[d.id,d])),s=new Map(t.components.map(d=>[d.fieldId,d])),i=zs(t.pages),{allComponents:a,componentsToKeep:o,allCollections:l}=cd(i,n,s,r),u=dd(a);return fd(u,a,o,l,t,r),hd(l,r,n,s),Sr(r),r},Z={canActionProceed:Bc,canCYASubmit:kc,cleanHiddenNestedData:fi,getFormState:Wc,getRelevantPages:Kc,getNextPageId:Tr,getPage:hi,getSubmissionStatus:Xc,getUpdatedSectionStates:rd,clearOutUncompletedRoutes:md},pd=(e,t,r,n,s,i,a,o,l,u,d,c,f,m,A,T,v,x)=>{if(t.type===X.TYPES.SUBMIT&&m!==pe.TASK){if(e("submit"),Z.canCYASubmit(r,n.pages)&&!v){x(!0);const $=N.Format.form({pages:r,components:i},{...a},Te.SUBMIT),S={pages:r,components:i};Z.clearOutUncompletedRoutes(s,S,$),$.formStatus=Z.getSubmissionStatus(l,r,u,t,$,d,!0),o($),c.onSubmit(t.type,$,()=>{c.onFormComplete(),x(!1)},w=>{x(!1),Ee.submissionError(w,f)})}}else{const S=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Z.canCYASubmit(d.fullPages,n.pages):!0;if(t.type===X.TYPES.SAVE_AND_CONTINUE&&m===pe.TASK&&S){const w=N.Format.form({pages:r,components:i},{...a},Te.SUBMIT);w.formStatus=Z.getSubmissionStatus(l,r,u,t,w,d,!0),o(w),c.onSubmit(t.type,w,()=>{x(!1),A(ae.HUB)},b=>{x(!1),Ee.submissionError(b,f)})}if(t.type===X.TYPES.SUBMIT&&m===pe.TASK&&(e("submit"),S)){const w=N.Format.form({pages:r,components:i},{...a},Te.SUBMIT),b={pages:r,components:i};Z.clearOutUncompletedRoutes(s,b,w),w.formStatus=Z.getSubmissionStatus(l,r,u,t,w,d,!0),o(w),c.onSubmit(t.type,w,()=>{c.onFormComplete(),x(!1)},q=>{x(!1),Ee.submissionError(q,f)})}if(t.type===X.TYPES.SAVE_AND_NAVIGATE&&S){const w=N.Format.form({pages:r,components:i},{...a},Te.SUBMIT);w.formStatus=Z.getSubmissionStatus(l,r,u,t,w,d,!0),o(w),c.onSubmit(t.type,w,()=>{x(!1),A(t.page)},b=>{x(!1),Ee.submissionError(b,f)})}if(t.type===X.TYPES.SAVE_AND_RETURN&&S){const w=N.Format.form({pages:r,components:i},{...a},Te.SUBMIT);w.formStatus=Z.getSubmissionStatus(l,r,u,t,w,d,!1),o(w),c.onSubmit(t.type,w,()=>{l===ne.TASK?A(void 0):A(ae.HUB),x(!1)},b=>{x(!1),Ee.submissionError(b,f)})}if(t.type===X.TYPES.NAVIGATE&&(A(Z.getNextPageId(l,r,u,t,T.page?.formData)),x(!1)),t.type===X.TYPES.CANCEL){const w=N.Format.form({pages:r,components:i},{...a},Te.CANCEL);c.onCancel(w),x(!1)}}},zn=(e,t,r,n,s,i,a,o,l,u,d,c,f,m,A,T,v,x,$,S,w,b)=>{const q={...s},E=i,P=n.onAction(E.page.formData,t,s,e.customAction);E.page.formData=P.formData;let L=P.patch;if(E.page.formData={...E.page.formData,...L},e.type===X.TYPES.CANCEL){n.onCancel(E.page.formData),w(!1);return}if(Z.canActionProceed(e,E.page,a.page,b)&&(!S||e.ignoreSubmittingFlag))if(L=Z.cleanHiddenNestedData(L,E.page),w(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(C=>{C.isCollection?Rr(C.field,C.value,i.page.formData):N.Data.setDataItem(i.page.formData,C.field,C.value)}),E.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===X.TYPES.NAVIGATE)Ee.navigate(e,f,o),w(!1);else{let M=j=>o(Z.getNextPageId(l,d,f,e,j)),C,H;e.collection&&(C=e.collection,H=`addAnother${C.charAt(0).toUpperCase()+C.slice(1)}`.slice(0,-1));let D,y;switch(C&&(D=E.page.formData[C],D&&D.length>0&&E.page.formData[`${C}ActiveId`]&&(y=D.findIndex(j=>j.id===E.page.formData[`${C}ActiveId`]))),e.type){case X.TYPES.SUBMIT:m("submit");break;case X.TYPES.SAVE_AND_NAVIGATE:const j={...A};D&&D.length>0&&e.resetActiveId&&(E.page.formData[`${C}ActiveId`]=D[0].id),D&&D.length>0&&!e.resetActiveId&&(y!==void 0&&y+1<E.page.formData[C].length&&(E.page.formData[H]="Yes"),y!==void 0&&y+1===E.page.formData[C].length&&E.page.formData[H]&&(E.page.formData[H]="No")),M=()=>Ee.navigate(e,f,o,j);break;case X.TYPES.COLLECTION_ADD:if(y===void 0||D.length===0||y+1===E.page.formData[C].length?N.CollectionPage.addEntry(e.collection,E.page.formData):E.page.formData[`${e.collection}ActiveId`]=D[y+1].id,E.page.formData[`${e.collection}`]&&E.page.formData[`${e.collection}`].length>0){const Y=E.page.formData[`${e.collection}`].length-1;Object.keys(E.page.formData[`${e.collection}`][Y]).filter(V=>V in E.page.formData&&V!=="id").forEach(V=>delete E.page.formData[V])}M=()=>Ee.navigate(e,f,o);break;case X.TYPES.COLLECTION_DUPLICATE:N.CollectionPage.duplicateActiveEntry(e.collection,i.page.formData)&&(M=()=>Ee.navigate(e,f,o));break;case X.TYPES.COLLECTION_REMOVE:const k=e.targetId||E.page.formData[`${e.collection.split(".").pop()}ActiveId`],p=N.CollectionPage.removeEntry(e.collection,i.page.formData,k);e.recordRemoval&&(E.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...p});const U=E.page.formData.id;p!==null&&Object.keys(p).filter(G=>G in E.page.formData).forEach(G=>delete E.page.formData[G]),Object.assign(E.page.formData,D[D.length-1]),E.page.formData.id=U,D.length>0?E.page.formData[`${e.collection}ActiveId`]=D[D.length-1].id:(delete E.page.formData[`${e.collection}ActiveId`],delete E.page.formData[e.collection]),M=()=>Ee.navigate(e,f,o);break}N.Data.deleteValues(s,i.page.formData);const g=N.Format.form({pages:d,components:c},{...s,...t,...i.page.formData},Te.SUBMIT);g.formStatus=Z.getSubmissionStatus(l,d,f,e,g,A,!0,v?.sections),L&&T(g);const _={pages:d,components:c};e.type===X.TYPES.SUBMIT&&Z.clearOutUncompletedRoutes(u,_,g);let F,O;l===ne.HUB&&Object.keys(r).length>0&&(F=Object.keys(r)[0],O=Object.values(r)[0]),n.onSubmit(e.type,g,j=>{const k={...g,...j};x({data:k}),M(k),w(!1)},(j,k=!0)=>{Ee.submissionError(j,$),k&&T({...q}),w(!1)},F,O,f)}},Jn=(e,t,r,n,s,i)=>{if(e){const a=e;a.fullPages=[],a.pages.forEach(l=>{a.fullPages.push(Z.getPage(l,t))}),r(e);const o={...a};if(a.state===z.TYPES.COMPLETE&&!a.alwaysShowFirstPage)if(n?.noTaskCYAs){const l=s.formStatus.tasks[e.name].currentPage;i(a.pages[0]||l)}else a.customCYA?i(a.customCYA):i(ae.CYA,o);else if(a.state===z.TYPES.IN_PROGRESS&&!a.alwaysShowFirstPage){const l=s.formStatus.tasks[e.name].currentPage;i(l||e.pages[0],o)}else a.firstPage?i(a.firstPage,o):i(a.pages[0],o)}},Ti=({title:e,titleSize:t,type:r,cleanseHiddenData:n=!1,components:s,pages:i,hub:a={nonSequential:!1,sections:[]},cya:o={actions:[],disableTaskSwitch:!1},data:l,hashLink:u=!1,hooks:d,classBlock:c=Ed,classModifiers:f=[],className:m="",hide_title:A,summaryListClassModifiers:T=[],noChangeAction:v=!1,newPageId:x="",viewOnly:$=!0,hideBlankRows:S=!1})=>h.jsx(ws,{overrides:d,children:h.jsx(bs,{children:h.jsx(Ad,{title:e,titleSize:t,type:r,cleanseHiddenData:n,components:s,pages:i,hub:a,cya:o,data:l,classBlock:c,classModifiers:f,className:m,hashLink:u,hide_title:A,summaryListClassModifiers:T,noChangeAction:v,newPageId:x,viewOnly:$,hideBlankRows:S})})}),Ed="hods-form",Ad=({title:e,titleSize:t,type:r,cleanseHiddenData:n,components:s,pages:i,hub:a,cya:o,data:l,classBlock:u,classModifiers:d,className:c,hashLink:f,hide_title:m,summaryListClassModifiers:A,noChangeAction:T,newPageId:v,viewOnly:x,hideBlankRows:$})=>{const[S,w]=B.useState({}),[b,q]=B.useState(),[E,P]=B.useState([]),[L,M]=B.useState(void 0),[C,H]=B.useState(Z.getNextPageId(r,i,null,null,l)),[D,y]=B.useState(Z.getFormState(C,E,L)),[g,_]=B.useState({}),[F,O]=B.useState({}),[j,k]=B.useState("load"),[p,U]=B.useState(!1),[Y,G]=B.useState(!1),{hooks:V}=ge(),{addErrors:K,clearErrors:re,errors:me,validate:he}=Oe();window.onpopstate=W=>{if(!document.location.hash&&(W.state&&W.state.fullPages!==void 0&&_(Q=>({...Q,fullPages:W.state?.fullPages})),re(),U(!0),V.onGoingBack(W.state?W.state:null,...D.page.formData),s&&E&&S&&D.page?.formData&&j===void 0)){const Q=N.Format.form({pages:E,components:s},{...S,...D.page.formData},Te.SUBMIT);if(Q?.formStatus?.taskPage){const oe=Q.formStatus.tasks;Object.keys(oe).forEach(Se=>{const Yr=oe[Se];Yr.currentPage&&!Yr.complete&&delete oe[Se].currentPage}),delete Q.formStatus.taskPage}w(Q)}},B.useEffect(()=>{s&&i&&l&&(j==="load"||x)&&(w(N.Data.setupForm(i,s,l)),l.formStatus?.page&&H(l.formStatus.page))},[s,i,l,w,j,x]),B.useEffect(()=>{P(N.FormPage.getAll(i,s,{...S}))},[s,i,S,P]),B.useEffect(()=>{H(W=>W||Z.getNextPageId(r,E))},[r,E,H]),B.useEffect(()=>{M(N.Hub.get(r,a,s,{...S}))},[r,a,S,s,M]),B.useEffect(()=>{r===ne.HUB&&p&&S&&D.page?.formData&&(D.page.formData={...S}),U(!1),y(Z.getFormState(C,E,L))},[E,L,C,y,r,p,S,D.page]),B.useEffect(()=>{k(void 0),V.onFormLoad(W=>{_(W)})},[V]),B.useEffect(()=>{O(a)},[a]),B.useEffect(()=>{b?.data&&(w(b.data),q(void 0))},[b,w,q]);const ee=a?.sections,de=a?.nonSequential;B.useEffect(()=>{const W=g.fullPages;if(W&&(W.forEach(Q=>{const oe=Q;oe&&(oe.formData=S)}),_(Q=>({...Q,fullPages:W}))),ee){const Q=S?.formStatus?.tasks||{},oe=Z.getUpdatedSectionStates(ee,Q,de,S);O(Se=>({...Se,sections:[...oe]}))}},[g.fullPages,S,ee,de]);const ue=(W,Q={})=>{re(),H(W),V.onPageChange(W,Q)};B.useEffect(()=>{v!==void 0&&H(v)},[v]);const Ae=W=>{V.onChange(W)},_e=(W,Q)=>{if(typeof Q=="function"){const oe=Q({...S});oe&&w(oe)}D.page?.type===ae.PARTIAL_CYA&&!o.disableTaskSwitch&&F.sections.every(oe=>oe.tasks.every(Se=>Se.pages.includes(W.pageId)&&Se.name!==g.name?(Jn(Se,E,_,F,S,ue),!1):!0)),W&&Ee.cyaAction(W,C,ue)},Pe=N.classBuilder(u,d,c);if(L===pe.TASK){const W=o;W.actions=[X.TYPES.SAVE_AND_CONTINUE,X.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:Ve,nonSequential:Ge,...$e}=F;return h.jsxs("div",{className:Pe(),children:[e&&!m&&C===ae.HUB&&h.jsx(I.Heading,{size:t,children:e}),D.cya&&h.jsx(wc,{pages:Z.getRelevantPages(D,E,g.fullPages),...o,...D.page?.type===ae.PARTIAL_CYA&&{actions:D.page.actions?.filter(W=>N.Component.show(W,S))},...D.cya,onAction:W=>{pd(k,W,E,he,n,s,S,w,r,C,g,V,K,L,ue,D,Y,G)},onRowAction:_e,summaryListClassModifiers:A,hide_title:m,noChangeAction:D.cya.hideChangeActions??T,noGroupAction:D.cya.hideGroupActions??!1,sections:typeof F<"u"?F.sections:[],type:r,hideBlankRows:$}),L===pe.TASK&&D.pageId===ae.HUB&&h.jsx(Mc,{...$e,refNumber:S.businessKey,onTaskAction:W=>{Jn(W,E,_,F,S,ue)},annotations:F?.taskListAnnotations||[],formData:S}),D.page&&!D.cya&&!D.page.collection&&h.jsx(Or,{page:D.page,pages:[...E],onAction:(W,Q,oe)=>{zn(W,Q,oe,V,S,D,he,ue,r,n,E,s,C,k,g,w,F,q,K,Y,G,me)},onChange:Ae,hashLink:f,classModifiers:D.page.classModifiers,className:D.page.className,submitting:Y,pageId:C}),D.page&&!D.cya&&D.page.collection&&h.jsx(Dc,{page:D.page,pages:E,onCollectionChange:Ae,onAction:(W,Q,oe)=>{zn(W,Q,oe,V,S,D,he,ue,r,n,E,s,C,k,g,w,F,q,K,Y,G,me)},hashLink:f,classModifiers:D.page.classModifiers,className:D.page.className,submitting:Y})]})};exports.Container=Ur;exports.FormComponent=Le;exports.FormRenderer=Ti;exports.FormTypes=ne;exports.HooksContextProvider=ws;exports.HubFormats=pe;exports.Models=ua;exports.PageActions=Dr;exports.SummaryList=yr;exports.Utils=N;exports.ValidationContextProvider=bs;exports.default=Ti;
8
+ The dependency path is ${h}, and the chained show_when is ${T}.
9
+ The form will need to be changed to break this chained dependency`;throw new Error(P)}})}}}),ze(c,o)||Wd(o,c.path,c,n)},a=new Set;e?.forEach((l,c)=>{t.get(c)?.forEach(f=>{a.has(f)||i(a,f,e)})})},Zd=(e,t,n,r)=>{e?.forEach((s,o)=>{ze(s,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(a=>{const l={...t,...a},c=new Set,u=new Map;s.childPages?.forEach(f=>{const h=ze(f,l);f.components?.forEach(y=>{const m=Zs(y,n,r);if(!m.fieldId)return;const E=ze(y,l);h&&E&&ze(m,l)?c.add(m.fieldId):u.set(m.id,m)})}),zd(c,u,a,t)}),i&&Vd(i)})},ef=(e,t,n)=>{if(!e)return n;const r=new Map(t.components.map(u=>[u.id,u])),s=new Map(t.components.map(u=>[u.fieldId,u])),o=Os(t.pages),{allComponents:i,componentsToKeep:a,allCollections:l}=Jd(o,r,s,n),c=Xd(i);return Qd(c,i,a,l,t,n),Zd(l,n,r,s),mn(n),n},ee={canActionProceed:Id,canCYASubmit:Pd,cleanHiddenNestedData:Ks,getFormState:Rd,getRelevantPages:Ld,getNextPageId:hn,getPage:Ws,getSubmissionStatus:Md,getUpdatedSectionStates:Bd,clearOutUncompletedRoutes:ef},tf=(e,t,n,r,s,o,i,a,l,c,u,f,h,y,m,E,p,_)=>{if(t.type===Q.TYPES.SUBMIT&&y!==Ae.TASK){if(e("submit"),ee.canCYASubmit(n,r.pages)&&!p){_(!0);const U=D.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),T={pages:n,components:o};ee.clearOutUncompletedRoutes(s,T,U),U.formStatus=ee.getSubmissionStatus(l,n,c,t,U,u,!0),a(U),f.onSubmit(t.type,U,()=>{f.onFormComplete(),_(!1)},P=>{_(!1),ge.submissionError(P,h)})}}else{const T=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?ee.canCYASubmit(u.fullPages,r.pages):!0;if(t.type===Q.TYPES.SAVE_AND_CONTINUE&&y===Ae.TASK&&T){const P=D.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);P.formStatus=ee.getSubmissionStatus(l,n,c,t,P,u,!0),a(P),f.onSubmit(t.type,P,()=>{_(!1),m(ie.HUB)},v=>{_(!1),ge.submissionError(v,h)})}if(t.type===Q.TYPES.SUBMIT&&y===Ae.TASK&&(e("submit"),T)){const P=D.Format.form({pages:n,components:o},{...i},Ie.SUBMIT),v={pages:n,components:o};ee.clearOutUncompletedRoutes(s,v,P),P.formStatus=ee.getSubmissionStatus(l,n,c,t,P,u,!0),a(P),f.onSubmit(t.type,P,()=>{f.onFormComplete(),_(!1)},B=>{_(!1),ge.submissionError(B,h)})}if(t.type===Q.TYPES.SAVE_AND_NAVIGATE&&T){const P=D.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);P.formStatus=ee.getSubmissionStatus(l,n,c,t,P,u,!0),a(P),f.onSubmit(t.type,P,()=>{_(!1),m(t.page)},v=>{_(!1),ge.submissionError(v,h)})}if(t.type===Q.TYPES.SAVE_AND_RETURN&&T){const P=D.Format.form({pages:n,components:o},{...i},Ie.SUBMIT);P.formStatus=ee.getSubmissionStatus(l,n,c,t,P,u,!1),a(P),f.onSubmit(t.type,P,()=>{l===se.TASK?m(void 0):m(ie.HUB),_(!1)},v=>{_(!1),ge.submissionError(v,h)})}if(t.type===Q.TYPES.NAVIGATE&&(m(ee.getNextPageId(l,n,c,t,E.page?.formData)),_(!1)),t.type===Q.TYPES.CANCEL){const P=D.Format.form({pages:n,components:o},{...i},Ie.CANCEL);f.onCancel(P),_(!1)}}},Sr=(e,t,n,r,s,o,i,a,l,c,u,f,h,y,m,E,p,_,U,T,P,v)=>{const B={...s},S=o,L=r.onAction(S.page.formData,t,s,e.customAction);S.page.formData=L.formData;let F=L.patch;if(S.page.formData={...S.page.formData,...F},e.type===Q.TYPES.CANCEL){r.onCancel(S.page.formData),P(!1);return}if(ee.canActionProceed(e,S.page,i.page,v)&&(!T||e.ignoreSubmittingFlag))if(F=ee.cleanHiddenNestedData(F,S.page),P(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?On(x.field,x.value,o.page.formData):D.Data.setDataItem(o.page.formData,x.field,x.value)}),S.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===Q.TYPES.NAVIGATE)ge.navigate(e,h,a),P(!1);else{let $=M=>a(ee.getNextPageId(l,u,h,e,M)),x,H;e.collection&&(x=e.collection,H=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let O,g;switch(x&&(O=S.page.formData[x],O&&O.length>0&&S.page.formData[`${x}ActiveId`]&&(g=O.findIndex(M=>M.id===S.page.formData[`${x}ActiveId`]))),e.type){case Q.TYPES.SUBMIT:y("submit");break;case Q.TYPES.SAVE_AND_NAVIGATE:const M={...m};O&&O.length>0&&e.resetActiveId&&(S.page.formData[`${x}ActiveId`]=O[0].id),O&&O.length>0&&!e.resetActiveId&&(g!==void 0&&g+1<S.page.formData[x].length&&(S.page.formData[H]="Yes"),g!==void 0&&g+1===S.page.formData[x].length&&S.page.formData[H]&&(S.page.formData[H]="No")),$=()=>ge.navigate(e,h,a,M);break;case Q.TYPES.COLLECTION_ADD:if(g===void 0||O.length===0||g+1===S.page.formData[x].length?D.CollectionPage.addEntry(e.collection,S.page.formData):S.page.formData[`${e.collection}ActiveId`]=O[g+1].id,S.page.formData[`${e.collection}`]&&S.page.formData[`${e.collection}`].length>0){const G=S.page.formData[`${e.collection}`].length-1;Object.keys(S.page.formData[`${e.collection}`][G]).filter(z=>z in S.page.formData&&z!=="id").forEach(z=>delete S.page.formData[z])}$=()=>ge.navigate(e,h,a);break;case Q.TYPES.COLLECTION_DUPLICATE:D.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&($=()=>ge.navigate(e,h,a));break;case Q.TYPES.COLLECTION_REMOVE:const k=e.targetId||S.page.formData[`${e.collection.split(".").pop()}ActiveId`],Y=D.CollectionPage.removeEntry(e.collection,o.page.formData,k);e.recordRemoval&&(S.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...Y});const q=S.page.formData.id;Y!==null&&Object.keys(Y).filter(W=>W in S.page.formData).forEach(W=>delete S.page.formData[W]),Object.assign(S.page.formData,O[O.length-1]),S.page.formData.id=q,O.length>0?S.page.formData[`${e.collection}ActiveId`]=O[O.length-1].id:(delete S.page.formData[`${e.collection}ActiveId`],delete S.page.formData[e.collection]),$=()=>ge.navigate(e,h,a);break}D.Data.deleteValues(s,o.page.formData);const b=D.Format.form({pages:u,components:f},{...s,...t,...o.page.formData},Ie.SUBMIT);b.formStatus=ee.getSubmissionStatus(l,u,h,e,b,m,!0,p?.sections),F&&E(b);const w={pages:u,components:f};e.type===Q.TYPES.SUBMIT&&ee.clearOutUncompletedRoutes(c,w,b);let R,I;l===se.HUB&&Object.keys(n).length>0&&(R=Object.keys(n)[0],I=Object.values(n)[0]),r.onSubmit(e.type,b,M=>{const k={...b,...M};_({data:k}),$(k),P(!1)},(M,k=!0)=>{ge.submissionError(M,U),k&&E({...B}),P(!1)},R,I,h)}},Tr=(e,t,n,r,s,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(l=>{i.fullPages.push(ee.getPage(l,t))}),n(e);const a={...i};if(i.state===J.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(r?.noTaskCYAs){const l=s.formStatus.tasks[e.name].currentPage;o(i.pages[0]||l)}else i.customCYA?o(i.customCYA):o(ie.CYA,a);else if(i.state===J.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const l=s.formStatus.tasks[e.name].currentPage;o(l||e.pages[0],a)}else i.firstPage?o(i.firstPage,a):o(i.pages[0],a)}},to=({title:e,titleSize:t,type:n,cleanseHiddenData:r=!1,components:s,pages:o,hub:i={nonSequential:!1,sections:[]},cya:a={actions:[],disableTaskSwitch:!1},data:l,hashLink:c=!1,hooks:u,classBlock:f=nf,classModifiers:h=[],className:y="",hide_title:m,summaryListClassModifiers:E=[],noChangeAction:p=!1,newPageId:_="",viewOnly:U=!0,hideBlankRows:T=!1})=>d.jsx(cs,{overrides:u,children:d.jsx(us,{children:d.jsx(rf,{title:e,titleSize:t,type:n,cleanseHiddenData:r,components:s,pages:o,hub:i,cya:a,data:l,classBlock:f,classModifiers:h,className:y,hashLink:c,hide_title:m,summaryListClassModifiers:E,noChangeAction:p,newPageId:_,viewOnly:U,hideBlankRows:T})})}),nf="hods-form",rf=({title:e,titleSize:t,type:n,cleanseHiddenData:r,components:s,pages:o,hub:i,cya:a,data:l,classBlock:c,classModifiers:u,className:f,hashLink:h,hide_title:y,summaryListClassModifiers:m,noChangeAction:E,newPageId:p,viewOnly:_,hideBlankRows:U})=>{const[T,P]=j.useState({}),[v,B]=j.useState(),[S,L]=j.useState([]),[F,$]=j.useState(void 0),[x,H]=j.useState(ee.getNextPageId(n,o,null,null,l)),[O,g]=j.useState(ee.getFormState(x,S,F)),[b,w]=j.useState({}),[R,I]=j.useState({}),[M,k]=j.useState("load"),[Y,q]=j.useState(!1),[G,W]=j.useState(!1),{hooks:z}=Oe(),{addErrors:ye,clearErrors:Se,errors:_e,validate:me}=Be();window.onpopstate=K=>{if(!document.location.hash&&(K.state&&K.state.fullPages!==void 0&&w(Z=>({...Z,fullPages:K.state?.fullPages})),Se(),q(!0),z.onGoingBack(K.state?K.state:null,...O.page.formData),s&&S&&T&&O.page?.formData&&M===void 0)){const Z=D.Format.form({pages:S,components:s},{...T,...O.page.formData},Ie.SUBMIT);if(Z?.formStatus?.taskPage){const ae=Z.formStatus.tasks;Object.keys(ae).forEach(Pe=>{const $n=ae[Pe];$n.currentPage&&!$n.complete&&delete ae[Pe].currentPage}),delete Z.formStatus.taskPage}P(Z)}},j.useEffect(()=>{s&&o&&l&&(M==="load"||_)&&(P(D.Data.setupForm(o,s,l)),l.formStatus?.page&&H(l.formStatus.page))},[s,o,l,P,M,_]),j.useEffect(()=>{L(D.FormPage.getAll(o,s,{...T}))},[s,o,T,L]),j.useEffect(()=>{H(K=>K||ee.getNextPageId(n,S))},[n,S,H]),j.useEffect(()=>{$(D.Hub.get(n,i,s,{...T}))},[n,i,T,s,$]),j.useEffect(()=>{n===se.HUB&&Y&&T&&O.page?.formData&&(O.page.formData={...T}),q(!1),g(ee.getFormState(x,S,F))},[S,F,x,g,n,Y,T,O.page]),j.useEffect(()=>{k(void 0),z.onFormLoad(K=>{w(K)})},[z]),j.useEffect(()=>{I(i)},[i]),j.useEffect(()=>{v?.data&&(P(v.data),B(void 0))},[v,P,B]);const ne=i?.sections,fe=i?.nonSequential;j.useEffect(()=>{const K=b.fullPages;if(K&&(K.forEach(Z=>{const ae=Z;ae&&(ae.formData=T)}),w(Z=>({...Z,fullPages:K}))),ne){const Z=T?.formStatus?.tasks||{},ae=ee.getUpdatedSectionStates(ne,Z,fe,T);I(Pe=>({...Pe,sections:[...ae]}))}},[b.fullPages,T,ne,fe]);const ce=(K,Z={})=>{Se(),H(K),z.onPageChange(K,Z)};j.useEffect(()=>{p!==void 0&&H(p)},[p]);const Ce=K=>{z.onChange(K)},Fe=(K,Z)=>{if(typeof Z=="function"){const ae=Z({...T});ae&&P(ae)}O.page?.type===ie.PARTIAL_CYA&&!a.disableTaskSwitch&&R.sections.every(ae=>ae.tasks.every(Pe=>Pe.pages.includes(K.pageId)&&Pe.name!==b.name?(Tr(Pe,S,w,R,T,ce),!1):!0)),K&&ge.cyaAction(K,x,ce)},$e=D.classBuilder(c,u,f);if(F===Ae.TASK){const K=a;K.actions=[Q.TYPES.SAVE_AND_CONTINUE,Q.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:at,nonSequential:lt,...Ke}=R;return d.jsxs("div",{className:$e(),children:[e&&!y&&x===ie.HUB&&d.jsx(C.Heading,{size:t,children:e}),O.cya&&d.jsx(md,{pages:ee.getRelevantPages(O,S,b.fullPages),...a,...O.page?.type===ie.PARTIAL_CYA&&{actions:O.page.actions?.filter(K=>D.Component.show(K,T))},...O.cya,onAction:K=>{tf(k,K,S,me,r,s,T,P,n,x,b,z,ye,F,ce,O,G,W)},onRowAction:Fe,summaryListClassModifiers:m,hide_title:y,noChangeAction:O.cya.hideChangeActions??E,noGroupAction:O.cya.hideGroupActions??!1,sections:typeof R<"u"?R.sections:[],type:n,hideBlankRows:U}),F===Ae.TASK&&O.pageId===ie.HUB&&d.jsx(wd,{...Ke,refNumber:T.businessKey,onTaskAction:K=>{Tr(K,S,w,R,T,ce)},annotations:R?.taskListAnnotations||[],formData:T}),O.page&&!O.cya&&!O.page.collection&&d.jsx(In,{page:O.page,pages:[...S],onAction:(K,Z,ae)=>{Sr(K,Z,ae,z,T,O,me,ce,n,r,S,s,x,k,b,P,R,B,ye,G,W,_e)},onChange:Ce,hashLink:h,classModifiers:O.page.classModifiers,className:O.page.className,submitting:G,pageId:x}),O.page&&!O.cya&&O.page.collection&&d.jsx(Ed,{page:O.page,pages:S,onCollectionChange:Ce,onAction:(K,Z,ae)=>{Sr(K,Z,ae,z,T,O,me,ce,n,r,S,s,x,k,b,P,R,B,ye,G,W,_e)},hashLink:h,classModifiers:O.page.classModifiers,className:O.page.className,submitting:G})]})};exports.Container=Ln;exports.FormComponent=He;exports.FormRenderer=to;exports.FormTypes=se;exports.HooksContextProvider=cs;exports.HubFormats=Ae;exports.Models=qo;exports.PageActions=xn;exports.SummaryList=fn;exports.Utils=D;exports.ValidationContextProvider=us;exports.default=to;