@ukhomeoffice/cop-react-form-renderer 8.0.0-alpha.4 → 8.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -8
- package/dist/index.js +3084 -3422
- package/dist/utils/Component/cleanAttributes.d.ts +1 -1
- package/dist/utils/Component/index.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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){
|
|
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(
|
|
5
|
-
`):" "+
|
|
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
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),T=require("@ukhomeoffice/cop-react-components"),O=require("react"),mt=require("uuid"),q=require("dayjs"),Re=require("dayjs/plugin/customParseFormat"),tn=require("dayjs/plugin/isToday"),Wr=require("dayjs/plugin/isLeapYear"),ve={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},zr="alert",Jr="autocomplete",Xr="calculation",Qr="checkboxes",Zr="collection",eo="collection-summary",to="container",no="date",so="details",ro="email",oo="file",io="heading",lo="html",ao="inset-text",co="list",uo="multifile",fo="paragraph",ho="phone-number",mo="radios",po="select",Eo="text",Ao="textarea",yo="time",To="warning",b={ALERT:zr,AUTOCOMPLETE:Jr,CALCULATION:Xr,CHECKBOXES:Qr,COLLECTION:Zr,COLLECTION_SUMMARY:eo,CONTAINER:to,DATE:no,DETAILS:so,EMAIL:ro,FILE:oo,HEADING:io,HTML:lo,INSET_TEXT:ao,LIST:co,MULTI_FILE:uo,PARAGRAPH:fo,PHONE_NUMBER:ho,RADIOS:mo,SELECT:po,TEXT:Eo,TEXT_AREA:Ao,TIME:yo,WARNING:To},So="blur",Co="submit",go="cancel",Te={BLUR:So,SUBMIT:Co,CANCEL:go},bo="cya",wo="hub",Io="partial-cya",te={CYA:bo,HUB:wo,PARTIAL_CYA:Io},_o="cya",Po="form",xo="form-with-task-list",No="hub-and-spoke",Oo="task-list",Ro="task-list-cya",vo="wizard",Z={CYA:_o,FORM:Po,FORM_WITH_TASK:xo,HUB:No,TASK:Oo,TASK_CYA:Ro,WIZARD:vo},Lo="CYA",Do="TASK",he={CYA:Lo,TASK:Do},Ut="cancel",cs="collectionAdd",us="collectionDuplicate",ds="collectionRemove",fs="navigate",Mt="saveAndContinue",kt="saveAndNavigate",$t="saveAndReturn",Bt="submit",st={CANCEL:Ut,COLLECTION_ADD:cs,COLLECTION_DUPLICATE:us,COLLECTION_REMOVE:ds,NAVIGATE:fs,SAVE_AND_CONTINUE:Mt,SAVE_AND_NAVIGATE:kt,SAVE_AND_RETURN:$t,SUBMIT:Bt},Fo={[Ut]:{type:Ut,validate:!1,label:"Cancel",classModifiers:"secondary"},[cs]:void 0,[us]:void 0,[ds]:void 0,[fs]:void 0,[Mt]:{type:Mt,validate:!0,label:"Save and continue"},[kt]:{type:kt,validate:!0,label:"Save and continue"},[$t]:{type:$t,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Bt]:{type:Bt,validate:!0}},G={TYPES:st,DEFAULTS:Fo},hs="complete",ms="inProgress",ps="notStarted",Es="cannotStartYet",As="skipped",jo={COMPLETE:hs,IN_PROGRESS:ms,NOT_STARTED:ps,CANNOT_START_YET:Es,SKIPPED:As},Uo={[hs]:{label:"Completed",colour:"dark-blue"},[ms]:{label:"In Progress",colour:"white"},[ps]:{label:"Not Started",colour:"dark-grey"},[Es]:{label:"Cannot Start Yet",colour:"dark-grey"},[As]:{label:"Skipped",colour:"dark-grey"}},B={TYPES:jo,DETAILS:Uo},Mo={CollectionLabels:ve,ComponentTypes:b,EventTypes:Te,FormPages:te,FormTypes:Z,HubFormats:he,PageAction:G,TaskStates:B},ys=e=>{try{const t=ko(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},ko=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return Xe(e,(n,s)=>n*s);case"divide":return Xe(e,(n,s)=>n/s);case"plus":return Xe(e,(n,s)=>n+s);case"minus":return Xe(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},Xe=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return $o(n.map(s=>Bo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},$o=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const s=Math.pow(10,n);return Math.round((e+Number.EPSILON)*s)/s},Bo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=Yo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ys({...e,formData:t});default:throw new Error("Only accept following as argument field: {field, value, or formula}")}}else throw new Error("Argument cannot have more than one reference")},Yo=(e,t)=>T.Utils.interpolateString("${"+e+"}",t),Ho=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return le.getSource(t,n)}return e.value},Qe=e=>{if(Array.isArray(e))return e.length;if(typeof e=="string"){const t=e.replace(/,/g,"");return Number.isNaN(t)?null:parseFloat(t)}return typeof e=="number"?e:null},nn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Ho(e,n);switch(e.op){case"=":case"eq":return s===t;case"!=":case"<>":case"ne":case"neq":return s!==t;case"in":return Array.isArray(s)?s.includes(t):!1;case"nin":return Array.isArray(s)?s.includes(t)===!1:!0;case"<":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r<o}case">":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r>o}case"contains":return t?.toString().toLowerCase().includes(s);case"!contains":return!t?.toString().toLowerCase().includes(s);case"includes":return Array.isArray(t)?t.includes(s):!1;case"!includes":return Array.isArray(t)?!t.includes(s):!0;case"includesObjectProp":return Array.isArray(t)?t.some(r=>r[e.key]===s):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(r=>r[e.key]===s):!0;case"includesAllOf":return Array.isArray(t)?s.every(r=>t.includes(r)):!1;case"!includesAllOf":return Array.isArray(t)?!s.every(r=>t.includes(r)):!0;default:return!1}}return!0},Vo=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const n=e.full_path;return t=Array.isArray(t)?t:[t],t.map(s=>{const r=le.getDataPath(s.field,n);return{...s,field:r}})}},qo=e=>Array.isArray(e)||!!(e.field&&e.op),Ts=e=>e&&!qo(e)?Vo(e):e,Ss=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ss(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=le.getSource(t,i);return nn(o,l,t)};return n==="and"?s.every(r):s.some(r)},xe=(e,t)=>{const n=Ts(e);return n?Ss(n,t):!0},Go=(e,t)=>{const n=Ts(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=le.getSource(t,r.field);return nn(r,o,t)}):!0},se={meetsOne:Go,meetsAll:xe,met:nn},Ko=(e,t)=>{const n=e;return t.forEach((s,r)=>{if(s.refdata_match){const o=s.refdata_match,i=Object.keys(o)[0],l=e.findIndex(a=>a[i]===o[i]);l>=0&&(n[l]={...e[l],nested:s.nested})}s.combineWithRefdata&&!n.includes(s)&&(r>0&&typeof t[r-1]=="string"&&n.push(t[r-1]),n.push(s))}),n},Ze=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?se.meetsOne(n,e.formData):se.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:T.Utils.interpolateString(n.value,e.formData),label:T.Utils.interpolateString(n.label,e.formData),hint:T.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),Wo=(e,t)=>{const n=e.formData[t].map(s=>({value:T.Utils.interpolateString(e.item.value,s),label:T.Utils.interpolateString(e.item.label,s),hint:T.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Cs=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Wo(e,e?.data?.collection);return t(Ze(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Ko(e.options,e.data.options);return t(Ze(e,n))}if(e.options)return t(Ze(e,e.options));if(e.data&&e.data.options)return t(Ze(e,e.data.options))}return t([])},zo=6e3,Jo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},xn=e=>e===0,gs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),Xo=(e,t)=>{let n=0;return e.synonyms.some(r=>gs(r,t))&&(n=4),n},Qo=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return gs(i,n)})&&(s=5),s},Zo=(e,t,n,s)=>{const r=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=r.indexOf(t);return i!==-1&&(o=Jo(i,r)),xn(o)&&e.synonyms&&(o=Xo(e,t)),xn(o)&&s.item?.extraFieldsToSearch&&(o=Qo(s,e,t)),{score:o,label:r,option:e}},ei=(e,t,n)=>(s,r)=>{const o=Zo(r,e,t,n);return o.score>0&&s.push(o),s},ti=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),ni=e=>{let t=[];Cs(e,s=>{t=s});const n=e?.item?T.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(ei(o,n,e),[]).sort(ti).slice(0,zo).map(l=>l.option);r(i)}},Ie=".",sn="/",bs=`${Ie}${Ie}`,Nn=`${Ie}${sn}`,Yt=e=>e.join(Ie),Ht=(e,t=Ie)=>e.split(t),si=e=>e===bs,ri=e=>[Ie,bs].indexOf(e)>-1,oi=e=>e&&e.indexOf(Ie)===0,ii=e=>e.indexOf(Nn)===0?e:`${Nn}${e}`,li=(e,t)=>{const n=ii(t),s=Ht(n,sn).filter(si).length+1,r=e?Ht(e):[];return s>=r.length?"":Yt(r.slice(0,-s))},ai=(e,t)=>{const n=Ht(t,sn).filter(s=>!ri(s));return e?`${e}.${Yt(n)}`:Yt(n)},ci=(e,t)=>oi(e)?ai(li(t,e),e):e,ui=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},di=e=>e.includes("["),fi=e=>e.replace("]","").split("["),ee=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&di(s)){const[r,o]=fi(s);return ui(n[r],o)}return n?n[s]:void 0},e)},hi=(e,t)=>{let n=e.value||e.id,s=e.label||e.name;return t&&(n=e[t.value]||n,s=e[t.label]||s),{value:n?.toString(),label:s}},mi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...hi(n,t)}):[],pi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},ws=(e,t,n,s=!1)=>{if(t&&e){const r=s?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=r.pop();let i=e;r.forEach(l=>{(!i[l]||typeof i[l]!="object")&&(i[l]={}),i=i[l]}),i[o]=n}return e},Is=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=ee(n,e.source.field))},Ei=(e,t)=>{e.forEach(n=>Is(n,t))},Ai=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Is(s,t))})},yi=(e,t,n)=>{const s={...n};return Ei(t,s),Ai(e,s),s},Ti=(e,t)=>({...e,components:_s(e.components,t)}),Si=(e,t)=>({...e,item:_s(e.item,t)}),_s=(e,t)=>e.map(n=>Ps(n,t)),Ps=(e,t)=>{if(e){if(e.type===b.CONTAINER)return Ti(e,t);if(e.type===b.COLLECTION)return Si(e,t);if(e.type===b.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:T.Utils.interpolateString(e.data.url,t)}}}return e},le={applyFormula:ys,getAutocompleteSource:ni,getDataPath:ci,getOptions:Cs,getSource:ee,refData:{setupUrl:Ps,toOptions:mi},deleteValues:pi,setDataItem:ws,setupForm:yi},Ye=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ce=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t),He=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ce(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||le.getSource(t,s.full_path);Array.isArray(r.nested)&&Ye(o,r)&&Ce(r,t)&&(n=n.concat(r.nested))})}),n},On=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],Q=(e,t)=>{const n=Array.isArray(t)?[...On,...t]:On;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function xs(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ci}=Object.prototype,{getPrototypeOf:rn}=Object,{iterator:pt,toStringTag:Ns}=Symbol,Et=(e=>t=>{const n=Ci.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ae=e=>(e=e.toLowerCase(),t=>Et(t)===e),At=e=>t=>typeof t===e,{isArray:Le}=Array,Ne=At("undefined");function Ve(e){return e!==null&&!Ne(e)&&e.constructor!==null&&!Ne(e.constructor)&&ce(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Os=Ae("ArrayBuffer");function gi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Os(e.buffer),t}const bi=At("string"),ce=At("function"),Rs=At("number"),qe=e=>e!==null&&typeof e=="object",wi=e=>e===!0||e===!1,rt=e=>{if(Et(e)!=="object")return!1;const t=rn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ns in e)&&!(pt in e)},Ii=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_i=Ae("Date"),Pi=Ae("File"),xi=e=>!!(e&&typeof e.uri<"u"),Ni=e=>e&&typeof e.getParts<"u",Oi=Ae("Blob"),Ri=Ae("FileList"),vi=e=>qe(e)&&ce(e.pipe);function Li(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rn=Li(),vn=typeof Rn.FormData<"u"?Rn.FormData:void 0,Di=e=>{let t;return e&&(vn&&e instanceof vn||ce(e.append)&&((t=Et(e))==="formdata"||t==="object"&&ce(e.toString)&&e.toString()==="[object FormData]"))},Fi=Ae("URLSearchParams"),[ji,Ui,Mi,ki]=["ReadableStream","Request","Response","Headers"].map(Ae),$i=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ge(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),Le(e))for(s=0,r=e.length;s<r;s++)t.call(null,e[s],s,e);else{if(Ve(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(s=0;s<i;s++)l=o[s],t.call(null,e[l],l,e)}}function vs(e,t){if(Ve(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,r;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ls=e=>!Ne(e)&&e!==be;function Vt(){const{caseless:e,skipUndefined:t}=Ls(this)&&this||{},n={},s=(r,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&vs(n,o)||o;rt(n[i])&&rt(r)?n[i]=Vt(n[i],r):rt(r)?n[i]=Vt({},r):Le(r)?n[i]=r.slice():(!t||!Ne(r))&&(n[i]=r)};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Ge(arguments[r],s);return n}const Bi=(e,t,n,{allOwnKeys:s}={})=>(Ge(t,(r,o)=>{n&&ce(r)?Object.defineProperty(e,o,{value:xs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),Yi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Vi=(e,t,n,s)=>{let r,o,i;const l={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)i=r[o],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&rn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},qi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Gi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Rs(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ki=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&rn(Uint8Array)),Wi=(e,t)=>{const s=(e&&e[pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},zi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Ji=Ae("HTMLFormElement"),Xi=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),Ln=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Qi=Ae("RegExp"),Ds=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};Ge(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},Zi=e=>{Ds(e,(t,n)=>{if(ce(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(ce(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},el=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},tl=()=>{},nl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sl(e){return!!(e&&ce(e.append)&&e[Ns]==="FormData"&&e[pt])}const rl=e=>{const t=new Array(10),n=(s,r)=>{if(qe(s)){if(t.indexOf(s)>=0)return;if(Ve(s))return s;if(!("toJSON"in s)){t[r]=s;const o=Le(s)?[]:{};return Ge(s,(i,l)=>{const a=n(i,r+1);!Ne(a)&&(o[l]=a)}),t[r]=void 0,o}}return s};return n(e,0)},ol=Ae("AsyncFunction"),il=e=>e&&(qe(e)||ce(e))&&ce(e.then)&&ce(e.catch),Fs=((e,t)=>e?setImmediate:t?((n,s)=>(be.addEventListener("message",({source:r,data:o})=>{r===be&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),be.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ce(be.postMessage)),ll=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Fs,al=e=>e!=null&&ce(e[pt]),E={isArray:Le,isArrayBuffer:Os,isBuffer:Ve,isFormData:Di,isArrayBufferView:gi,isString:bi,isNumber:Rs,isBoolean:wi,isObject:qe,isPlainObject:rt,isEmptyObject:Ii,isReadableStream:ji,isRequest:Ui,isResponse:Mi,isHeaders:ki,isUndefined:Ne,isDate:_i,isFile:Pi,isReactNativeBlob:xi,isReactNative:Ni,isBlob:Oi,isRegExp:Qi,isFunction:ce,isStream:vi,isURLSearchParams:Fi,isTypedArray:Ki,isFileList:Ri,forEach:Ge,merge:Vt,extend:Bi,trim:$i,stripBOM:Yi,inherits:Hi,toFlatObject:Vi,kindOf:Et,kindOfTest:Ae,endsWith:qi,toArray:Gi,forEachEntry:Wi,matchAll:zi,isHTMLForm:Ji,hasOwnProperty:Ln,hasOwnProp:Ln,reduceDescriptors:Ds,freezeMethods:Zi,toObjectSet:el,toCamelCase:Xi,noop:tl,toFiniteNumber:nl,findKey:vs,global:be,isContextDefined:Ls,isSpecCompliantForm:sl,toJSONObject:rl,isAsyncFn:ol,isThenable:il,setImmediate:Fs,asap:ll,isIterable:al};let F=class js extends Error{static from(t,n,s,r,o,i){const l=new js(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:E.toJSONObject(this.config),code:this.code,status:this.status}}};F.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";F.ERR_BAD_OPTION="ERR_BAD_OPTION";F.ECONNABORTED="ECONNABORTED";F.ETIMEDOUT="ETIMEDOUT";F.ERR_NETWORK="ERR_NETWORK";F.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";F.ERR_DEPRECATED="ERR_DEPRECATED";F.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";F.ERR_BAD_REQUEST="ERR_BAD_REQUEST";F.ERR_CANCELED="ERR_CANCELED";F.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";F.ERR_INVALID_URL="ERR_INVALID_URL";const cl=null;function qt(e){return E.isPlainObject(e)||E.isArray(e)}function Us(e){return E.endsWith(e,"[]")?e.slice(0,-2):e}function Nt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Us(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function ul(e){return E.isArray(e)&&!e.some(qt)}const dl=E.toFlatObject(E,{},null,function(t){return/^is[A-Z]/.test(t)});function yt(e,t,n){if(!E.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=E.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,A){return!E.isUndefined(A[p])});const s=n.metaTokens,r=n.visitor||u,o=n.dots,i=n.indexes,a=(n.Blob||typeof Blob<"u"&&Blob)&&E.isSpecCompliantForm(t);if(!E.isFunction(r))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(E.isDate(h))return h.toISOString();if(E.isBoolean(h))return h.toString();if(!a&&E.isBlob(h))throw new F("Blob is not supported. Use a Buffer instead.");return E.isArrayBuffer(h)||E.isTypedArray(h)?a&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,p,A){let w=h;if(E.isReactNative(t)&&E.isReactNativeBlob(h))return t.append(Nt(A,p,o),c(h)),!1;if(h&&!A&&typeof h=="object"){if(E.endsWith(p,"{}"))p=s?p:p.slice(0,-2),h=JSON.stringify(h);else if(E.isArray(h)&&ul(h)||(E.isFileList(h)||E.endsWith(p,"[]"))&&(w=E.toArray(h)))return p=Us(p),w.forEach(function(C,I){!(E.isUndefined(C)||C===null)&&t.append(i===!0?Nt([p],I,o):i===null?p:p+"[]",c(C))}),!1}return qt(h)?!0:(t.append(Nt(A,p,o),c(h)),!1)}const m=[],f=Object.assign(dl,{defaultVisitor:u,convertValue:c,isVisitable:qt});function y(h,p){if(!E.isUndefined(h)){if(m.indexOf(h)!==-1)throw Error("Circular reference detected in "+p.join("."));m.push(h),E.forEach(h,function(w,L){(!(E.isUndefined(w)||w===null)&&r.call(t,w,E.isString(L)?L.trim():L,p,f))===!0&&y(w,p?p.concat(L):[L])}),m.pop()}}if(!E.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Dn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function on(e,t){this._pairs=[],e&&yt(e,this,t)}const Ms=on.prototype;Ms.append=function(t,n){this._pairs.push([t,n])};Ms.toString=function(t){const n=t?function(s){return t.call(this,s,Dn)}:Dn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function fl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ks(e,t,n){if(!t)return e;const s=n&&n.encode||fl,r=E.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=E.isURLSearchParams(t)?t.toString():new on(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Fn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){E.forEach(this.handlers,function(s){s!==null&&t(s)})}}const ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},hl=typeof URLSearchParams<"u"?URLSearchParams:on,ml=typeof FormData<"u"?FormData:null,pl=typeof Blob<"u"?Blob:null,El={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ml,Blob:pl},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",Gt=typeof navigator=="object"&&navigator||void 0,Al=an&&(!Gt||["ReactNative","NativeScript","NS"].indexOf(Gt.product)<0),yl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tl=an&&window.location.href||"http://localhost",Sl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:yl,navigator:Gt,origin:Tl},Symbol.toStringTag,{value:"Module"})),ie={...Sl,...El};function Cl(e,t){return yt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&E.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function gl(e){return E.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bl(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function $s(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&E.isArray(r)?r.length:i,a?(E.hasOwnProp(r,i)?r[i]=[r[i],s]:r[i]=s,!l):((!r[i]||!E.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&E.isArray(r[i])&&(r[i]=bl(r[i])),!l)}if(E.isFormData(e)&&E.isFunction(e.entries)){const n={};return E.forEachEntry(e,(s,r)=>{t(gl(s),r,n,0)}),n}return null}function wl(e,t,n){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Ke={transitional:ln,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=E.isObject(t);if(o&&E.isHTMLForm(t)&&(t=new FormData(t)),E.isFormData(t))return r?JSON.stringify($s(t)):t;if(E.isArrayBuffer(t)||E.isBuffer(t)||E.isStream(t)||E.isFile(t)||E.isBlob(t)||E.isReadableStream(t))return t;if(E.isArrayBufferView(t))return t.buffer;if(E.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Cl(t,this.formSerializer).toString();if((l=E.isFileList(t))||s.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return yt(l?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||r?(n.setContentType("application/json",!1),wl(t)):t}],transformResponse:[function(t){const n=this.transitional||Ke.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(E.isResponse(t)||E.isReadableStream(t))return t;if(t&&E.isString(t)&&(s&&!this.responseType||r)){const i=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?F.from(l,F.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};E.forEach(["delete","get","head","post","put","patch"],e=>{Ke.headers[e]={}});const Il=E.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_l=e=>{const t={};let n,s,r;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){r=i.indexOf(":"),n=i.substring(0,r).trim().toLowerCase(),s=i.substring(r+1).trim(),!(!n||t[n]&&Il[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t},jn=Symbol("internals"),Pl=e=>!/[\r\n]/.test(e);function Bs(e,t){if(!(e===!1||e==null)){if(E.isArray(e)){e.forEach(n=>Bs(n,t));return}if(!Pl(String(e)))throw new Error(`Invalid character in header content ["${t}"]`)}}function Me(e){return e&&String(e).trim().toLowerCase()}function xl(e){let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==10&&n!==13)break;t-=1}return t===e.length?e:e.slice(0,t)}function ot(e){return e===!1||e==null?e:E.isArray(e)?e.map(ot):xl(String(e))}function Nl(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Ol=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ot(e,t,n,s,r){if(E.isFunction(s))return s.call(this,t,n);if(r&&(t=n),!!E.isString(t)){if(E.isString(s))return t.indexOf(s)!==-1;if(E.isRegExp(s))return s.test(t)}}function Rl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function vl(e,t){const n=E.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{value:function(r,o,i){return this[s].call(this,t,r,o,i)},configurable:!0})})}let ue=class{constructor(t){t&&this.set(t)}set(t,n,s){const r=this;function o(l,a,c){const u=Me(a);if(!u)throw new Error("header name must be a non-empty string");const m=E.findKey(r,u);(!m||r[m]===void 0||c===!0||c===void 0&&r[m]!==!1)&&(Bs(l,a),r[m||a]=ot(l))}const i=(l,a)=>E.forEach(l,(c,u)=>o(c,u,a));if(E.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(E.isString(t)&&(t=t.trim())&&!Ol(t))i(_l(t),n);else if(E.isObject(t)&&E.isIterable(t)){let l={},a,c;for(const u of t){if(!E.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(a=l[c])?E.isArray(a)?[...a,u[1]]:[a,u[1]]:u[1]}i(l,n)}else t!=null&&o(n,t,s);return this}get(t,n){if(t=Me(t),t){const s=E.findKey(this,t);if(s){const r=this[s];if(!n)return r;if(n===!0)return Nl(r);if(E.isFunction(n))return n.call(this,r,s);if(E.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Me(t),t){const s=E.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Ot(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let r=!1;function o(i){if(i=Me(i),i){const l=E.findKey(s,i);l&&(!n||Ot(s,s[l],l,n))&&(delete s[l],r=!0)}}return E.isArray(t)?t.forEach(o):o(t),r}clear(t){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const o=n[s];(!t||Ot(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){const n=this,s={};return E.forEach(this,(r,o)=>{const i=E.findKey(s,o);if(i){n[i]=ot(r),delete n[o];return}const l=t?Rl(o):String(o).trim();l!==o&&delete n[o],n[l]=ot(r),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return E.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=t&&E.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(r=>s.set(r)),s}static accessor(t){const s=(this[jn]=this[jn]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=Me(i);s[l]||(vl(r,i),s[l]=!0)}return E.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);E.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});E.freezeMethods(ue);function Rt(e,t){const n=this||Ke,s=t||n,r=ue.from(s.headers);let o=s.data;return E.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ys(e){return!!(e&&e.__CANCEL__)}let We=class extends F{constructor(t,n,s){super(t??"canceled",F.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function Hs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new F("Request failed with status code "+n.status,[F.ERR_BAD_REQUEST,F.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ll(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dl(e,t){e=e||10;const n=new Array(e),s=new Array(e);let r=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const c=Date.now(),u=s[o];i||(i=c),n[r]=a,s[r]=c;let m=o,f=0;for(;m!==r;)f+=n[m++],m=m%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const y=u&&c-u;return y?Math.round(f*1e3/y):void 0}}function Fl(e,t){let n=0,s=1e3/t,r,o;const i=(c,u=Date.now())=>{n=u,r=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),m=u-n;m>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-m)))},()=>r&&i(r)]}const ct=(e,t,n=3)=>{let s=0;const r=Dl(50,250);return Fl(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=i-s,c=r(a),u=i<=l;s=i;const m={loaded:i,total:l,progress:l?i/l:void 0,bytes:a,rate:c||void 0,estimated:c&&l&&u?(l-i)/c:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(m)},n)},Un=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},Mn=e=>(...t)=>E.asap(()=>e(...t)),jl=ie.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ie.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,Ul=ie.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];E.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),E.isString(s)&&l.push(`path=${s}`),E.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),E.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ml(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function kl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vs(e,t,n){let s=!Ml(t);return e&&(s||n==!1)?kl(e,t):t}const kn=e=>e instanceof ue?{...e}:e;function _e(e,t){t=t||{};const n={};function s(c,u,m,f){return E.isPlainObject(c)&&E.isPlainObject(u)?E.merge.call({caseless:f},c,u):E.isPlainObject(u)?E.merge({},u):E.isArray(u)?u.slice():u}function r(c,u,m,f){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c,m,f)}else return s(c,u,m,f)}function o(c,u){if(!E.isUndefined(u))return s(void 0,u)}function i(c,u){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,m){if(m in t)return s(c,u);if(m in e)return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(c,u,m)=>r(kn(c),kn(u),m,!0)};return E.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const m=E.hasOwnProp(a,u)?a[u]:r,f=m(e[u],t[u],u);E.isUndefined(f)&&m!==l||(n[u]=f)}),n}const qs=e=>{const t=_e({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:o,headers:i,auth:l}=t;if(t.headers=i=ue.from(i),t.url=ks(Vs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),E.isFormData(n)){if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(E.isFunction(n.getHeaders)){const a=n.getHeaders(),c=["content-type","content-length"];Object.entries(a).forEach(([u,m])=>{c.includes(u.toLowerCase())&&i.set(u,m)})}}if(ie.hasStandardBrowserEnv&&(s&&E.isFunction(s)&&(s=s(t)),s||s!==!1&&jl(t.url))){const a=r&&o&&Ul.read(o);a&&i.set(r,a)}return t},$l=typeof XMLHttpRequest<"u",Bl=$l&&function(e){return new Promise(function(n,s){const r=qs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,m,f,y,h;function p(){y&&y(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function w(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};Hs(function(S){n(S),p()},function(S){s(S),p()},_),A=null}"onloadend"in A?A.onloadend=w:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.indexOf("file:")===0)||setTimeout(w)},A.onabort=function(){A&&(s(new F("Request aborted",F.ECONNABORTED,e,A)),A=null)},A.onerror=function(I){const _=I&&I.message?I.message:"Network Error",U=new F(_,F.ERR_NETWORK,e,A);U.event=I||null,s(U),A=null},A.ontimeout=function(){let I=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const _=r.transitional||ln;r.timeoutErrorMessage&&(I=r.timeoutErrorMessage),s(new F(I,_.clarifyTimeoutError?F.ETIMEDOUT:F.ECONNABORTED,e,A)),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&E.forEach(i.toJSON(),function(I,_){A.setRequestHeader(_,I)}),E.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,h]=ct(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([m,y]=ct(a),A.upload.addEventListener("progress",m),A.upload.addEventListener("loadend",y)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new We(null,e,A):C),A.abort(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const L=Ll(r.url);if(L&&ie.protocols.indexOf(L)===-1){s(new F("Unsupported protocol "+L+":",F.ERR_BAD_REQUEST,e));return}A.send(o||null)})},Yl=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let s=new AbortController,r;const o=function(c){if(!r){r=!0,l();const u=c instanceof Error?c:this.reason;s.abort(u instanceof F?u:new We(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new F(`timeout of ${t}ms exceeded`,F.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>c.addEventListener("abort",o));const{signal:a}=s;return a.unsubscribe=()=>E.asap(l),a}},Hl=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,r;for(;s<n;)r=s+t,yield e.slice(s,r),s=r},Vl=async function*(e,t){for await(const n of ql(e))yield*Hl(n,t)},ql=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},$n=(e,t,n,s)=>{const r=Vl(e,t);let o=0,i,l=a=>{i||(i=!0,s&&s(a))};return new ReadableStream({async pull(a){try{const{done:c,value:u}=await r.next();if(c){l(),a.close();return}let m=u.byteLength;if(n){let f=o+=m;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})},Bn=64*1024,{isFunction:et}=E,Gl=(({Request:e,Response:t})=>({Request:e,Response:t}))(E.global),{ReadableStream:Yn,TextEncoder:Hn}=E.global,Vn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Kl=e=>{e=E.merge.call({skipUndefined:!0},Gl,e);const{fetch:t,Request:n,Response:s}=e,r=t?et(t):typeof fetch=="function",o=et(n),i=et(s);if(!r)return!1;const l=r&&et(Yn),a=r&&(typeof Hn=="function"?(h=>p=>h.encode(p))(new Hn):async h=>new Uint8Array(await new n(h).arrayBuffer())),c=o&&l&&Vn(()=>{let h=!1;const p=new Yn,A=new n(ie.origin,{body:p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return p.cancel(),h&&!A}),u=i&&l&&Vn(()=>E.isReadableStream(new s("").body)),m={stream:u&&(h=>h.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!m[h]&&(m[h]=(p,A)=>{let w=p&&p[h];if(w)return w.call(p);throw new F(`Response type '${h}' is not supported`,F.ERR_NOT_SUPPORT,A)})});const f=async h=>{if(h==null)return 0;if(E.isBlob(h))return h.size;if(E.isSpecCompliantForm(h))return(await new n(ie.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(E.isArrayBufferView(h)||E.isArrayBuffer(h))return h.byteLength;if(E.isURLSearchParams(h)&&(h=h+""),E.isString(h))return(await a(h)).byteLength},y=async(h,p)=>{const A=E.toFiniteNumber(h.getContentLength());return A??f(p)};return async h=>{let{url:p,method:A,data:w,signal:L,cancelToken:C,timeout:I,onDownloadProgress:_,onUploadProgress:U,responseType:S,headers:R,withCredentials:v="same-origin",fetchOptions:D}=qs(h),x=t||fetch;S=S?(S+"").toLowerCase():"text";let k=Yl([L,C&&C.toAbortSignal()],I),P=null;const N=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let j;try{if(U&&c&&A!=="get"&&A!=="head"&&(j=await y(R,w))!==0){let J=new n(p,{method:"POST",body:w,duplex:"half"}),de;if(E.isFormData(w)&&(de=J.headers.get("content-type"))&&R.setContentType(de),J.body){const[ae,fe]=Un(j,ct(Mn(U)));w=$n(J.body,Bn,ae,fe)}}E.isString(v)||(v=v?"include":"omit");const M=o&&"credentials"in n.prototype,Y={...D,signal:k,method:A.toUpperCase(),headers:R.normalize().toJSON(),body:w,duplex:"half",credentials:M?v:void 0};P=o&&new n(p,Y);let H=await(o?x(P,D):x(p,Y));const V=u&&(S==="stream"||S==="response");if(u&&(_||V&&N)){const J={};["status","statusText","headers"].forEach(re=>{J[re]=H[re]});const de=E.toFiniteNumber(H.headers.get("content-length")),[ae,fe]=_&&Un(de,ct(Mn(_),!0))||[];H=new s($n(H.body,Bn,ae,()=>{fe&&fe(),N&&N()}),J)}S=S||"text";let K=await m[E.findKey(m,S)||"text"](H,h);return!V&&N&&N(),await new Promise((J,de)=>{Hs(J,de,{data:K,headers:ue.from(H.headers),status:H.status,statusText:H.statusText,config:h,request:P})})}catch(M){throw N&&N(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new F("Network Error",F.ERR_NETWORK,h,P,M&&M.response),{cause:M.cause||M}):F.from(M,M&&M.code,h,P,M&&M.response)}}},Wl=new Map,Gs=e=>{let t=e&&e.env||{};const{fetch:n,Request:s,Response:r}=t,o=[s,r,n];let i=o.length,l=i,a,c,u=Wl;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:Kl(t)),u=c;return c};Gs();const cn={http:cl,xhr:Bl,fetch:{get:Gs}};E.forEach(cn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qn=e=>`- ${e}`,zl=e=>E.isFunction(e)||e===null||e===!1;function Jl(e,t){e=E.isArray(e)?e:[e];const{length:n}=e;let s,r;const o={};for(let i=0;i<n;i++){s=e[i];let l;if(r=s,!zl(s)&&(r=cn[(l=String(s)).toLowerCase()],r===void 0))throw new F(`Unknown adapter '${l}'`);if(r&&(E.isFunction(r)||(r=r.get(t))))break;o[l||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
|
+
`+i.map(qn).join(`
|
|
5
|
+
`):" "+qn(i[0]):"as no adapter specified";throw new F("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return r}const Ks={getAdapter:Jl,adapters:cn};function vt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new We(null,e)}function Gn(e){return vt(e),e.headers=ue.from(e.headers),e.data=Rt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ks.getAdapter(e.adapter||Ke.adapter,e)(e).then(function(s){return vt(e),s.data=Rt.call(e,e.transformResponse,s),s.headers=ue.from(s.headers),s},function(s){return Ys(s)||(vt(e),s&&s.response&&(s.response.data=Rt.call(e,e.transformResponse,s.response),s.response.headers=ue.from(s.response.headers))),Promise.reject(s)})}const Ws="1.15.0",Tt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Tt[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Kn={};Tt.transitional=function(t,n,s){function r(o,i){return"[Axios v"+Ws+"] Transitional option '"+o+"'"+i+(s?". "+s:"")}return(o,i,l)=>{if(t===!1)throw new F(r(i," has been removed"+(n?" in "+n:"")),F.ERR_DEPRECATED);return n&&!Kn[i]&&(Kn[i]=!0,console.warn(r(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}};Tt.spelling=function(t){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function Xl(e,t,n){if(typeof e!="object")throw new F("options must be an object",F.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let r=s.length;for(;r-- >0;){const o=s[r],i=t[o];if(i){const l=e[o],a=l===void 0||i(l,o,e);if(a!==!0)throw new F("option "+o+" must be "+a,F.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new F("Unknown option "+o,F.ERR_BAD_OPTION)}}const it={assertOptions:Xl,validators:Tt},me=it.validators;let we=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Fn,response:new Fn}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const o=(()=>{if(!r.stack)return"";const i=r.stack.indexOf(`
|
|
6
|
+
`);return i===-1?"":r.stack.slice(i+1)})();try{if(!s.stack)s.stack=o;else if(o){const i=o.indexOf(`
|
|
7
|
+
`),l=i===-1?-1:o.indexOf(`
|
|
8
|
+
`,i+1),a=l===-1?"":o.slice(l+1);String(s.stack).endsWith(a)||(s.stack+=`
|
|
9
|
+
`+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=_e(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&it.assertOptions(s,{silentJSONParsing:me.transitional(me.boolean),forcedJSONParsing:me.transitional(me.boolean),clarifyTimeoutError:me.transitional(me.boolean),legacyInterceptorReqResOrdering:me.transitional(me.boolean)},!1),r!=null&&(E.isFunction(r)?n.paramsSerializer={serialize:r}:it.assertOptions(r,{encode:me.function,serialize:me.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),it.assertOptions(n,{baseUrl:me.spelling("baseURL"),withXsrfToken:me.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&E.merge(o.common,o[n.method]);o&&E.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||ln;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,m=0,f;if(!a){const h=[Gn.bind(this),void 0];for(h.unshift(...l),h.push(...c),f=h.length,u=Promise.resolve(n);m<f;)u=u.then(h[m++],h[m++]);return u}f=l.length;let y=n;for(;m<f;){const h=l[m++],p=l[m++];try{y=h(y)}catch(A){p.call(this,A);break}}try{u=Gn.call(this,y)}catch(h){return Promise.reject(h)}for(m=0,f=c.length;m<f;)u=u.then(c[m++],c[m++]);return u}getUri(t){t=_e(this.defaults,t);const n=Vs(t.baseURL,t.url,t.allowAbsoluteUrls);return ks(n,t.params,t.paramsSerializer)}};E.forEach(["delete","get","head","options"],function(t){we.prototype[t]=function(n,s){return this.request(_e(s||{},{method:t,url:n,data:(s||{}).data}))}});E.forEach(["post","put","patch"],function(t){function n(s){return function(o,i,l){return this.request(_e(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}we.prototype[t]=n(),we.prototype[t+"Form"]=n(!0)});let Ql=class zs{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(r=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](r);s._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(l=>{s.subscribe(l),o=l}).then(r);return i.cancel=function(){s.unsubscribe(o)},i},t(function(o,i,l){s.reason||(s.reason=new We(o,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new zs(function(r){t=r}),cancel:t}}};function Zl(e){return function(n){return e.apply(null,n)}}function ea(e){return E.isObject(e)&&e.isAxiosError===!0}const Kt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Kt).forEach(([e,t])=>{Kt[t]=e});function Js(e){const t=new we(e),n=xs(we.prototype.request,t);return E.extend(n,we.prototype,t,{allOwnKeys:!0}),E.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return Js(_e(e,r))},n}const z=Js(Ke);z.Axios=we;z.CanceledError=We;z.CancelToken=Ql;z.isCancel=Ys;z.VERSION=Ws;z.toFormData=yt;z.AxiosError=F;z.Cancel=z.CanceledError;z.all=function(t){return Promise.all(t)};z.spread=Zl;z.isAxiosError=ea;z.mergeConfig=_e;z.AxiosHeaders=ue;z.formToJSON=e=>$s(E.isHTMLForm(e)?new FormData(e):e);z.getAdapter=Ks.getAdapter;z.HttpStatusCode=Kt;z.default=z;const{Axios:Wd,AxiosError:zd,CanceledError:Jd,isCancel:Xd,CancelToken:Qd,VERSION:Zd,all:ef,Cancel:tf,isAxiosError:nf,spread:sf,toFormData:rf,AxiosHeaders:of,HttpStatusCode:lf,formToJSON:af,getAdapter:cf,mergeConfig:uf}=z,oe={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,n)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,n,s)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},Wn=Object.keys(oe),Xs=O.createContext(),Qs=({overrides:e={onAction:void 0,onCancel:void 0,onChange:void 0,onFormComplete:void 0,onFormLoad:void 0,onGetComponent:void 0,onGetCYA:void 0,onGetCYARows:void 0,onGoingBack:void 0,onPageChange:void 0,onRequest:void 0,onSubmit:void 0,onValidate:void 0},children:t=null})=>{const[n,s]=O.useState({onAction:e?.onAction||oe.onAction,onChange:e?.onChange||oe.onChange,onFormComplete:e?.onFormComplete||oe.onFormComplete,onFormLoad:e?.onFormLoad||oe.onFormLoad,onGetComponent:e?.onGetComponent||oe.onGetComponent,onGetCYA:e?.onGetCYA||oe.onGetCYA,onGetCYARows:e?.onGetCYARows||oe.onGetCYARows,onGoingBack:e?.onGoingBack||oe.onGoingBack,onPageChange:e?.onPageChange||oe.onPageChange,onRequest:e?.onRequest||oe.onRequest,onSubmit:e?.onSubmit||oe.onSubmit,onValidate:e?.onValidate||oe.onValidate,onCancel:e?.onCancel||oe.onCancel}),r=(i,l)=>{Wn.includes(i)&&s(a=>({...a,[i]:l||oe[i]}))},o=i=>{Wn.includes(i)&&s(l=>({...l,[i]:oe[i]}))};return d.jsx(Xs.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},ge=()=>O.useContext(Xs),ta=()=>{const{hooks:e}=ge(),[t,n]=O.useState({});return O.useEffect(()=>{const s=z.create({baseURL:"/"});return s.interceptors.request.use(e.onRequest),s.interceptors.response.use(r=>r,async r=>Promise.reject(r)),n({instance:s}),()=>{n({})}},[e]),t.instance},un=O.createContext(),Zs=({children:e=null})=>{const{hooks:t}=ge(),[n,s]=O.useState([]),[r,o]=O.useState([]),i=f=>{o(y=>[...y,...f].filter(h=>!!h))},l=f=>{typeof f=="function"&&o(y=>y.filter(h=>!f(h)))},a=()=>{r.length&&o([])},c=f=>{s(y=>[...y,...f].filter(h=>!!h))},u=()=>{o([]),s([])},m={page:f=>{const y=g.Validate.page(f,r),h=t.onValidate(f,y);return s(h),h},pages:f=>{const y=f.map(p=>g.Validate.page(p,r)),h=f.flatMap((p,A)=>t.onValidate(p,y[A]));return s(h),h}};return d.jsx(un.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:m},children:e})},De=()=>O.useContext(un),Lt={},Dt={},na="idle",sa="fetching",er="fetched",tr="error",ra=(e,t=!0)=>{const n=ta(),s=O.useRef(z.CancelToken.source()),[r,o]=O.useState(na),[i,l]=O.useState(null),[a,c]=O.useState(null),u=()=>{s.current&&s.current.cancel()};return O.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(sa);let f;if(t&&Lt[e])f=Lt[e];else{if(t&&Dt[e])throw Dt[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(h=>{throw l(h),h})).data,t&&(Lt[e]=f)}c(f),o(er)}catch(f){t&&(Dt[e]=f),l(f),c(null),o(tr)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},oa="loading",lt="complete",ia=e=>{const t=e.data;if(t&&!t.options||t?.url)return T.Utils.interpolateString(t.url,e.formData)},la=(e,t)=>{const n=ia({...e,formData:t}),{status:s,data:r}=ra(n,e?.data?.useCache),[o,i]=O.useState([]),[l,a]=O.useState(oa);return O.useEffect(()=>{n?s===er?(r&&i(le.refData.toOptions(r.data||r,e.item)),a(lt)):s===tr&&(i([]),a(lt)):(e.data&&e.data.options&&i(le.refData.toOptions(e.data.options,e.item)),a(lt))},[e.id,s,r,n]),{data:o,status:l}},$e=(e,t)=>{const n=Q(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(T.FormGroup,{...n,onChange:null,children:t})},dn=(e,t,n,s,r={})=>{if(!t)return[];const o=g.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(l=>{r={...r,[`${t.collection.name.split(".").pop()}ActiveId`]:l.id};const a=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...r}};if(c.childPages)return dn(e,u,n,s,r);const m=g.Validate.page(u);return s.onValidate(u,m)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},fn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Fe,{component:{...t,readonly:!0},wrap:!1,value:e,formData:n}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:s)||d.jsx(T.VisuallyHidden,{children:"No answer"}),aa="Continue",Wt=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?G.DEFAULTS[e]:e,r=G.DEFAULTS[e.type];return s?d.jsx(T.Button,{...n,className:s.className,classModifiers:s.classModifiers,start:s.start||!1,name:s.label,onClick:s.disabled?()=>{}:()=>t(s),children:s.label||r?.label||aa}):null},ca="hods-form-confirmation",ua="Are you sure?",da="Confirm",fa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=T.Utils.classBuilder(ca,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||ua}),s,d.jsx(T.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||da}),d.jsx(T.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},hn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===b.CONTAINER?hn(t):ze.editable(t)?t:null).filter(t=>!!t):[],ha=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const s=t?`${t}.${n.fieldId}`:n.fieldId,r={...n,full_path:s};return n.type===b.CONTAINER?zt(r):(n.type===b.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===b.CONTAINER&&(r.data.options[i].nested[a]=zt(l))})}),r)})},zt=e=>{if(e){const t=ha(e);return{...e,components:t}}return e},ma=(e,t)=>e.some(n=>ze.show(n,t)),pa=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=hn(e);return n.length>0?ma(n,t):!0},St={editableComponents:hn,setup:zt,show:pa},Ea=(e,t)=>e.some(n=>Ce(n,t)),Ct=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=St.editableComponents(e);return n.length>0?Ea(n,t):!0},Aa=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Ct(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(m=>m.id===a)});return}const c=l.components.find(m=>m.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){xe(a.show_when,{...t,...n})&&s.push({...u,show_when:c.show_when||[]});return}s.push(u)})});const r={...e.childPages[0],formData:t};r.components=s,r.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return r.formData={...r.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete r.title,delete r.collection,r},mn=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(T.ButtonGroup,{children:e.map((n,s)=>d.jsx(Wt,{action:n,onAction:t},s))}),ya=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?se.meetsOne(t.runWhen?.constraint,e.formData):!1},nr="hods-form__page",pn=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=nr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:m})=>{const[f,y]=O.useState({}),{errors:h,validate:p}=De(),[A,w]=O.useState({}),[L,C]=O.useState(!1),I=O.useMemo(()=>ya(e),[e]);O.useEffect(()=>{C(!0)},[]),O.useEffect(()=>{L&&I&&p.page(e)},[m,L]);const _=({target:x})=>{const k=e,{value:P}=x;P?(k.formData[x.name]=P,y(N=>({...N,[x.name]:P})),w(N=>({...N,[x.component]:x.label}))):(delete k.formData[x.name],y(N=>{const{[x.name]:j,...M}=N;return M}),w(N=>{const{[x.component]:j,...M}=N;return M})),typeof o=="function"&&o(e.formData)};O.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=h.length>0?"Error: "+x:x},[h]);const U=g.classBuilder(l,a,c),S=e;S.actions=S.actions?.map(x=>x.label?{...x,label:g.interpolateString(x.label,S.formData)}:x),S.formData=g.Operate.runPageOperations(S,{...S.formData,...f},s||_);const R=e.title?d.jsx(T.Heading,{size:e.titleSize,children:g.FormPage.getTitle(e.title,e.formData)}):d.jsx(T.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(x=>g.Component.show(x,e.formData)).map((x,k)=>d.jsx(Fe,{component:x,onAction:P=>n(P,f,A),onChange:s||_,onTopLevelChange:r||_,value:e.formData[x.fieldId]||f[x.fieldId],formData:e.formData,pages:t,submitting:u},k));let D=null;return I&&h?.length>0?D=[{error:e?.customValidation?.[0]?.message}]:h?.length>0&&!I&&(D=h),d.jsxs("div",{className:U(),children:[D&&d.jsx(T.ErrorSummary,{errors:D,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:R}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[R,v]}),d.jsx(mn,{actions:e.actions?.filter(x=>g.Component.show(x,e.formData)),onAction:x=>n(x,f,A)})]},e.id)},zn="hods-form-banner-strip",sr=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=g.classBuilder(zn,s,""),o=t.filter(i=>g.Component.show(i,n));return d.jsx("div",{id:e,className:r(),children:o.map((i,l)=>{const a=`${e}-banner-${l}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:a,className:r("banner"),children:d.jsx(T.Markup,{content:g.interpolateString(c,n)})},a)}return d.jsx(T.Tag,{classBlock:`${zn}__tag`,classModifiers:i.classModifiers,text:g.interpolateString(i.text,n)},a)})})},Ta=e=>{if(e&&e.action){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},En=({row:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ta(e))},[e,n]),e.action?d.jsxs(T.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(T.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},rr=({row:e,classes:t,showAction:n=!1})=>d.jsxs("dl",{className:t("row"),role:"listitem",children:[d.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),d.jsx("dd",{className:t("value"),children:e.value}),n&&d.jsx("dd",{className:t("actions"),children:e.action&&d.jsx(En,{row:e})})]}),or=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(T.SmallHeading,{children:e})}),at=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=wt(o,t);return t.type==="title"?d.jsx(or,{title:t.key,classes:n}):d.jsx(rr,{row:{key:i.key,value:d.jsx(fn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Sa="govuk-summary-card",Ca="govuk-summary-list",tt="Item",nt="Change",Jn="Delete",ga="warning",ba=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=T.Utils.classBuilder(Sa,i,n.className),c=T.Utils.classBuilder(Ca,[]);return d.jsxs("div",{className:a(),id:e,children:[d.jsxs("div",{className:a("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:a("title-content"),children:[d.jsx("h2",{className:a("title"),children:T.Utils.interpolateString(n.title||tt,{...t,index:t.index+1})}),n.banners&&d.jsx(sr,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:a("actions"),children:[d.jsx("li",{className:a("action"),children:n.changeAction&&typeof s=="function"&&n.changeAction.classModifiers?d.jsx(T.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||ga,"aria-label":T.Utils.interpolateString(`${n.deleteAction?.label||Jn} ${n.title||tt}`,{...t,index:t.index+1}),children:n.deleteAction.label||Jn})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const m=u.components.map(f=>g.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const h=f.columns.filter(p=>se.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return h.length?h.flatMap(p=>{const A=m.find(w=>w.fieldId===p);return A?at(u,A,c,t,l):null}):null})})})})]})},wa=({id:e,"data-testid":t,actions:n,onFullEdit:s=null,entryData:r,formData:o,name:i,autoFocus:l})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(a=>g.Component.show(a,o)).map(a=>d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||Xn},e))}):d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||Xn}),Ia=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},gt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ia(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},ir=[b.ALERT,b.COLLECTION_SUMMARY,b.DETAILS,b.HEADING,b.HTML,b.INSET_TEXT],ut=(e,t)=>{if(!e||ir.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===b.COLLECTION){if(!ee(t,e.full_path||e.fieldId)?.length)return!1}else{const n=ee(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===b.CONTAINER?St.show(e,t):ze.show(e,t)},lr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>ir.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),_a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:gt(!1,e,t)}],Pa=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),xa=(e,t,n,s,r)=>{const o={...ve,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},An=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&ut(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Pa(t,o,l,a);return c=lr(c),[xa(t,o,e.id,l,a),...je(e,c,o,s,r)]}).filter(o=>!!o):_a(e,s),Na="hods-form-summary-card-details",ar=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=g.classBuilder(Na,r),a=O.useMemo(()=>t.map(u=>e.childPages.find(m=>m.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,m,f)=>{let y=0;return u.flatMap((h,p)=>{let A=0;const w=h.fields?.flatMap(C=>m.filter(_=>_.fieldId===C).map(_=>{if(!_||!Ce(_,{...f.formData,...s}))return null;if(_.type===b.CONTAINER){const U=je(f,_,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(S=>{const R={...s,[S.fieldId]:s[_.fieldId]?.[S.fieldId]};return at(f,{...S,label:S.key},l,R,i)})},C)}if(_.type===b.COLLECTION){const U=An({...f,formData:{...f.formData,...s}},_,s[_.id]);A+=1;let S=0;return d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(R=>{const v={...s,[R.fieldId]:s[_.fieldId]?.[R.fieldId]},D=at(f,{...R,label:R.key},l,v,i);return R.type==="title"&&(S+=1,S>1)?d.jsx("div",{style:{marginTop:"40px"},children:D}):D})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:at(f,_,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&w.length!==0?(y+=2,[...w,d.jsx("div",{className:l("divider"),style:{"--column":y}},`divider${y}`)]):w}).filter(h=>!!h)};return e?.childPages?.filter(u=>g.FormPage.show(u,{...n,...s})).map(u=>{const m=g.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!g.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const h=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return h&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(ar,{masterPage:h,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const y=f.columns.filter(h=>se.meetsAll(h,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:g.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":y.length-1},children:c(y,m,u)})]},f.title)})}).filter(u=>!!u)||null},Oa="hods-form-summary-card",Xn="Change",Ra="Delete",va="Quick Edit",La="Duplicate",Da="Full details",Qn="secondary",Zn=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:m,hideDetails:f=!1})=>{const[y,h]=O.useState(!1),p=T.Utils.classBuilder(Oa,s,n.className),A=O.useMemo(()=>n.quickEdit?Aa(m,u,t):null,[m,n,u,t,y]),{addErrors:w,resetQuickEditErrors:L,clearTopLevelErrorsForCard:C,validate:I}=De(),{hooks:_}=ge(),U=async(S,R)=>{if(S.type==="cancel"&&(h(v=>!v),L?.()),S.type==="save"&&typeof l=="function"){const v={...A.formData,...R,[`${a}ActiveId`]:t.id},D=I.page({...A,formData:v});if(D.length)return;let x;await _.onSubmit("quickEdit",v,()=>{},P=>{x=P}),x&&w(x);const k=D.concat(x);if(k.length===0||k.length===1&&k[0]===void 0){C();const P=g.CollectionPage.getData(a,u),{isDuplicate:N,...j}=P[t.index];P[t.index]={...j,...R},l({target:{name:a,value:P}}),h(M=>!M)}}};return n.listView?d.jsx(ba,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:m,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(sr,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:g.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:g.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(T.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>h(S=>!S),classModifiers:"primary",disabled:y,name:"QuickEdit",autoFocus:n.focusOn,children:va}),n.changeAction&&typeof r=="function"&&d.jsx(wa,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:r,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":g.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ra}),n.duplicateAction&&typeof i=="function"&&d.jsx(T.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":g.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||La})]})]}),y&&A&&d.jsx(pn,{page:A,onAction:(S,R)=>U(S,R),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(T.Details,{summary:n.detailsTitle||Da,className:"details",children:d.jsx(ar,{masterPage:m,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Fa=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=ge(),o=t.filter(m=>m.entryId===e)||[],[i,l]=O.useState(null),a=()=>{l(null)},c=m=>{l(f=>(f??[]).concat(m))},u={page:m=>{const f=g.Validate.page(m),y=r.onValidate(m,f);return l(y),y}};return d.jsx(un.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},es="Add",ja=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=ge(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:m,dequeueErrors:f}=De(),[y,h]=O.useState(null),p=O.useMemo(()=>g.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((R,v)=>v.isDuplicate&&(!R||v.id>R.id)?v:R,null):null,w=O.useMemo(()=>{const R=e.collectionName.split(".");let v=g.CollectionPage.mergePages(o||[])||[];return R.reduce((D,x,k)=>{const P=k===0?`${D}${x}`:`${D}.${x}`;return k===R.length-1?v?.find(N=>N.collection?.name===P)||null:(v=v.find(N=>N.collection?.name===P)?.childPages||null,P)},"")},[o]),L=O.useMemo(()=>e.card.listView?w.childPages?.reduce((v,D)=>{const x=He(D.components,{...t,...y});return v.concat(x)},[])||[]:[],[w,t,y,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const R=dn(e,w,t,i);R.length>0&&m(R)};O.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const I=(R,v)=>{if(typeof n=="function"){const D=[...p],x=p.findIndex(N=>N.id===v),{isDuplicate:k,...P}=p[x];D[x]={...P},n({type:st.SAVE_AND_NAVIGATE,page:R,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:D,isCollection:!0}]})}},_=R=>{g.CollectionPage.duplicateEntry(e.collectionName,t,R.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:g.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!y)return;g.CollectionPage.removeEntry(e.collectionName,t,y.id);const R=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:R,value:g.CollectionPage.getData(R,t)}}),h(null),C()},S=R=>{const v=L.find(x=>x.fieldId===R);if(!v)return null;const D=wt({...w,formData:{...t,...y}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(fn,{value:D.value,component:D.component,formData:D.formData})},R)};return d.jsxs("div",{id:e.fieldId,children:[y&&d.jsx(fa,{id:`${e.fieldId}.confirmation`,message:g.interpolateString(e.confirmation?.message,{...y,index:y.index+1})||null,confirmLabel:g.interpolateString(e.confirmation?.label,y)||null,onConfirm:U,onCancel:()=>h(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(S)}):d.jsx(Zn,{id:`${e.fieldId}.confirmationChild`,entryData:y,config:e.card?{...e.card,quickEdit:null}:{},masterPage:w,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((R,v)=>{const D=l.filter(P=>P.entryId===R.id).length>0,x={...e.card,...R.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...D&&e.errorCard?e.errorCard:{},focusOn:A?.id===R.id},k=`${e.fieldId}.summaryCard${R.id}`;return d.jsx("li",{children:d.jsx(Fa,{entryId:R.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const P=l.filter(N=>N.entryId!==R.id);c(),a(P)},children:d.jsx(Zn,{id:k,entryData:{...R,index:v},masterPage:w,config:x||{},onFullEdit:I,onDuplicate:_,onDelete:()=>h({...R,index:v}),onQuickEdit:P=>(C(),s(P)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:R.id===y?.id?["deleting-summary-card"]:[""],inError:l.filter(P=>P.entryId===R.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Ua="hods-form-collection",Ma=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=O.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===g.Meta.name)s({target:p});else{const A=i.findIndex(w=>w.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:mt.v4()}])},m=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;O.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,w=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');w&&w.length>0&&w[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),O.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const y={...ve,...e.labels},h=g.classBuilder(Ua,[],e.className);return d.jsxs("div",{className:h(),id:e.id,children:[e.label&&d.jsx(T.Label,{id:e.id,required:e.required,className:h("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const w=`${e.full_path||e.fieldId}[${A}]`,L=(e.countOffset||0)+A+1,C=g.interpolateString(y.item,{...p,index:L}),I=g.interpolateString(y.remove,{...p,index:L}),_=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${h("item")}`,style:U,children:[d.jsxs(T.Label,{id:p.id,required:!0,className:h("item-title"),children:[C,_==="start"&&d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})]}),d.jsx(Cn,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:w,components:e.item.map(S=>{const{firstOnlyLabel:R,...v}=S;let{hint:D}=S;e.restrictHint&&A>0&&(D=void 0);let{label:x}=S;return A===0&&(x=S.firstOnlyLabel??S.label),{...v,hint:D,readonly:!!(e?.readonly||S.readonly),label:g.interpolateString(x,{...p,index:L}),full_path:`${w}.${S.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),_==="end"&&d.jsx(T.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(T.ButtonGroup,{children:d.jsx(T.Button,{onClick:u,classModifiers:"secondary",children:f(y)})})]})},ka=(e,t,n)=>{const s=e,r=typeof s.value=="object"?s.value?.value:s.value,o=n.find(i=>String(i.id)===r);return s.label=o===void 0?s.value||"":o.label,s.component=t.cya_label,s},$a=(e,t)=>typeof e=="string"?!!T.Utils.interpolateString(e,t):!!e,Ft=(e,t)=>{if(Array.isArray(t)){const n=t.find(s=>s.id===(e.full_path||e.id));if(n){const s={error:n.error};return n.properties&&(s.propsInError=n.properties),s}}},Ba=[b.RADIOS,b.CHECKBOXES,b.DATE,b.TIME],Ya=e=>e.fieldset||Ba.includes(e.type),Fe=({component:e,value:t=null,formData:n=null,wrap:s=!0,onAction:r,onChange:o,onTopLevelChange:i,pages:l=[],submitting:a=!1,...c})=>{const{hooks:u}=ge(),m=De(),{data:f,status:y}=la(e,n),[h,p]=O.useState([]);O.useEffect(()=>{y===lt&&p(f)},[e,f,y]);const A=({target:C})=>typeof o=="function"?(e.type===b.EMAIL&&(C.value=C.value.trim()),e.type===b.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(I=>{I.children&&I.nested&&(delete I.children,delete I.nested)}),C=ka(C,e,f),e.type===b.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(O.useEffect(()=>{const C=g.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===b.CONTAINER){let C=d.jsx(Cn,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=$e(e,C)),e.additionalValidation&&(C=$e({...e,...Ft(e,m?.errors)},C)),C}if(e.type===b.COLLECTION)return d.jsx(Ma,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});if(e.type===b.COLLECTION_SUMMARY)return $e({...e,...Ft(e,m?.errors)},d.jsx(ja,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const w=C=>{let I=e.full_path||e.fieldId;if(e.pageCollection){const _=g.CollectionPage.getActiveIndex(e.pageCollection.name,n);I=`${`${e.pageCollection.name}[${_}]`}.${I}`}i({target:{name:g.Meta.name,value:g.Meta.documents.setForField(C,n,I,e.allowMultiple)}})},L=({target:C})=>{if(A({target:C})){if(e.type===b.FILE)w([C.value]);else if(e.type===b.MULTI_FILE){const I=C.value.map((_,U)=>({..._,indexInField:U}));w(I)}}};return g.Component.get({...c,...e,id:e.full_path||e.id,...Ft(e,m?.errors),fieldset:Ya(e),disabled:$a(e.disabled,n),label:g.interpolateString(e.label,n),content:g.interpolateString(e.content,n),hint:g.interpolateString(e.hint,n),cya_label:g.interpolateString(e.cya_label,n),suffix:g.interpolateString(e.suffix,n),options:h,value:t,onChange:L,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},Ha=[b.AUTOCOMPLETE,b.CALCULATION,b.CHECKBOXES,b.COLLECTION_SUMMARY,b.DATE,b.EMAIL,b.FILE,b.MULTI_FILE,b.PHONE_NUMBER,b.RADIOS,b.SELECT,b.TEXT,b.TEXT_AREA,b.TIME],cr=e=>Ha.includes(e?.type)||e?.isEditable||!1,Va="govuk-list",qa="govuk-body",Ga=e=>{const t=Q(e),n=T.Utils.interpolateString(e.heading,e.formData),s=T.Utils.interpolateString(e.text,e.formData);return d.jsx(T.Alert,{...t,heading:n,children:s})},Ka=e=>{const t=Q(e),n=le.getAutocompleteSource(e);return d.jsx(T.Autocomplete,{...t,source:n})},Wa=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Checkboxes,{...n,options:t})},za=e=>{const t=le.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=Q(e,["formula"]);return d.jsx(T.TextInput,{...n,readonly:!0})},Ja=e=>{const t=Q(e);return d.jsx(T.DateInput,{...t})},Xa=e=>{const t=Q(e,["tagName"]),n=bt(e);return d.jsx(T.Details,{...t,children:n})},Qa=e=>{const t=Q(e);return d.jsx(T.FileUpload,{...t})},Za=e=>{const t=Q(e);return d.jsx(T.MultiFileUpload,{...t})},ec=e=>{const t=Q(e);return d.jsx(T.Heading,{...t,children:e.content})},bt=e=>{const t=Q(e);return d.jsx(T.Markup,{...t})},tc=e=>{const t=Q(e);return d.jsx(T.InsetText,{...t,children:e.content})},nc=e=>{const t=Q(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=T.Utils.classBuilder(Va,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return bt({...t,className:r(),tagName:n,content:o,type:b.HTML})},sc=e=>{const t=Q(e);return bt({className:qa,...t,tagName:"p",type:b.HTML})},rc=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Radios,{...n,options:t})},oc=e=>{const t=Q(e);return d.jsx(T.TextArea,{...t})},ic=e=>{const t=Q(e);return d.jsx(T.TextInput,{...t})},lc=e=>{const t=Q(e);return d.jsx(T.TimeInput,{...t})},ac=e=>{let t=[];le.getOptions(e,s=>{t=s});const n=Q(e);return d.jsx(T.Select,{...n,options:t})},cc=e=>{const t=Q(e);return d.jsx(T.WarningText,{...t,children:e.content})},uc=e=>{switch(e.type){case b.HTML:return bt(e);case b.HEADING:return ec(e);case b.INSET_TEXT:return tc(e);case b.TEXT:case b.EMAIL:case b.PHONE_NUMBER:return ic(e);case b.TEXT_AREA:return oc(e);case b.AUTOCOMPLETE:return Ka(e);case b.RADIOS:return rc(e);case b.CHECKBOXES:return Wa(e);case b.DATE:return Ja(e);case b.TIME:return lc(e);case b.FILE:return Qa(e);case b.MULTI_FILE:return Za(e);case b.WARNING:return cc(e);case b.SELECT:return ac(e);case b.DETAILS:return Xa(e);case b.CALCULATION:return za(e);case b.ALERT:return Ga(e);case b.PARAGRAPH:return sc(e);case b.LIST:return nc(e);default:return null}},dc=(e,t)=>{const n={...t};if(e.full_path){const s=e.full_path.split(".");s.pop(),s.push(n.fieldId),n.full_path=s.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||le.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:dr(n,!1)})):d.jsx(Fe,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},ur=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!se.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:dc(e,s)},s.id));return n.length>0?n:null},dr=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=uc(e);return s&&t&&cr(e)?$e(e,s):s},fc=e=>e.defaultValue||e.defaultObjectValue,hc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?q().format("DD-MM-YYYY"):n},mc=(e,t)=>{const n={...e};let s=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(s={...n.literal}),n.sourced&&(s=s??{},Object.keys(n.sourced).every(r=>{const o=typeof n.sourced[r]=="string"&&ee(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},fr=(e,t)=>fc(e)?e.type===b.DATE?hc(e):(e.defaultObjectValue?mc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,pc={[b.COLLECTION]:[],[b.CONTAINER]:{}},Ec=(e,t)=>e&&(fr(e,t)||pc[e.type])||"",ze={clean:Q,defaultValue:Ec,defaultValueFromConfig:fr,editable:cr,elevateNested:He,get:dr,setupContainerPaths:lr,show:Ce,wrap:$e},Ac=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ye(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},wt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Ac(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:T.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ze.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:gt(t.readonly,e,n)}},je=(e,t,n,s,r)=>ut(t,{...e.formData,...n})?He(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>ut(i,{...e.formData,...n})).flatMap(i=>{const l=n?n[i.fieldId]:void 0;if(typeof r=="function"){const a=r({...e,formData:n},i,s);if(a)return a}return i.type===b.CONTAINER?je(e,i,{...l,...n},s,r):i.type===b.COLLECTION?An(e,i,l,s,r):wt({...e,formData:n},i,s)}):null,yc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{g.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ts=(e,t,n="text")=>{if(typeof e=="string")return T.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:xe(r.show_when,t));return typeof s=="string"?T.Utils.interpolateString(s,t):T.Utils.interpolateString(s[n],t)},Tc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Sc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return G.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return G.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),Tc(n)}}).filter(t=>!!t)},Cc=e=>({type:b.HTML,tagName:"p",content:e}),gc=(e,t)=>{const n=e.use.split("."),s=n.shift();let r=JSON.parse(JSON.stringify({...t.find(l=>l.id===s)})),o=r,i=r;for(;o&&n.length>0;){const l=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(a=>a.id===l),i.components.length>0?o=i.components[0]:o=void 0):o=void 0}if(o)return o={cya_label:o.label,...o,...e},i&&i.id!==o.id?i.components=[o]:r=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(l=>l.use?Jt(l,t):l)),r},Jt=(e,t)=>{if(e){const n=gc(e,t);if(n)return n}return{...e}},hr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return Cc(o);let i;return o.type===b.CONTAINER&&(o.components=o.components.map(l=>l.use?Jt(l,t):l)),o.use?i=Jt(o,t):i={...o},n?le.refData.setupUrl(i,n):i}),r=Sc(e);return St.setup({...e,formData:n,components:s,actions:r})},bc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...hr(s,t,n),index:r})):[],mr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Ct(e,t),Je={applyConditionalProperties:yc,getConditionalText:ts,get:hr,getAll:bc,getTitle:(e,t)=>ts(e,t,"title"),show:Ct,showCYA:mr},wc=(e,t)=>{if(!e)return null;if(!t)return e;const n={...e};return n.show_when?Array.isArray(t)?n.show_when=Array.isArray(n.show_when)?[...t,...n.show_when]:[...t,n.show_when]:n.show_when=Array.isArray(n.show_when)?[...n.show_when,t]:[n.show_when,t]:n.show_when=t,n},Ic=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},It=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},_c=e=>typeof e=="number"&&e>=0,pr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return _c(o)?(e.shift(),pr(e,t[s][o],n)):null},Ue=(e,t)=>{const n=e.split(".");return pr(n,t,t)},Er=(e,t,n,s=[],r={})=>{const o=Ue(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=mt.v4(),a={...i,...r,id:l};s.forEach(u=>delete a[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(a):o.splice(c,0,a),t[`${e.split(".").pop()}ActiveId`]=a.id,l},Pc=(e,t)=>{const n=It(e,t);return Er(e,t,n)},xc=e=>typeof e=="number"&&e>=0,Ar=(e,t,n)=>{const s=e[0],r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return xc(o)?e.length===1?o:(e.shift(),Ar(e,t[s][o],n)):null},yr=(e,t)=>{const n=e.split(".");return Ar(n,t,t)},Nc=e=>({id:e.id,name:e.name,...e.collection.show_when&&{show_when:e.collection.show_when},orderInForm:e.orderInForm,deleteCollectionWhenHidden:e.deleteCollectionWhenHidden,collection:{masterPage:!0,...e.collection},formData:{...e.formData},childPages:[e]}),Oc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Rc=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const s=n.join("."),r=t[s]||null;return r?(r.childPages.push(e),r.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},Tr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Nc(s);return t[s.collection.name]=o,o}return Oc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Rc(s,t)?null:s).filter(s=>!!s)},vc=(e,t,n)=>{const s=Ue(e,t);if(!s)return null;const r=s.findIndex(l=>l.id===n);if(r===-1)return null;const o=s[r];s.splice(r,1);const i=t;return i[`${e}ActiveId`]=s.length>0?s[0].id:null,o},Lc=e=>typeof e=="number"&&e>=0,yn=(e,t,n)=>{const s=e.split("."),r=s[s.length-1];let o=n;s.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=mt.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===r)return o[r]=t,!0;const l=n[`${i}ActiveId`],a=o[i]?.findIndex(c=>c.id===l);return Lc(a)?(o=o[i][a],!1):!0})},dt={addEntry:Ic,duplicateActiveEntry:Pc,duplicateEntry:Er,getActiveId:It,getActiveIndex:yr,getData:Ue,getErrorsForCollection:dn,mergePages:Tr,removeEntry:vc,setData:yn},Dc=e=>typeof e=="number"&&e>=0,Fc=(e,t,n,s,r,o)=>{const i=r?.label||ve.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[y,h]=f;c[y]=h});const u=dt.getData(e.collection.name,c),m=u?.findIndex(f=>f.id===t.id);return Dc(m)&&u.splice(m,1),c})},label:T.Utils.interpolateString(i,{...t,index:s})}}},jc=(e,t,n,s,r,o={})=>{const i=r?.label||ve.change;return{pageId:e.id,fieldId:`change${s}${r.page}`,key:`change${s}${r.page}`,type:"action",action:{onAction:l=>{const a=c=>{const u=c;return Object.entries(o).forEach(m=>{const[f,y]=m;u[f]=y}),u};n(r.page?{pageId:r.page}:l,a)},label:T.Utils.interpolateString(i,{...t,index:s})}}},Uc=(e,t)=>t.show_when?xe(t.show_when,e):!0,Mc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),kc=(e,t,n,s,r)=>{const o={...ve,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},$c=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:T.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},Bc=(e,t,n,s)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:n?.text||t.charAt(0).toUpperCase()+t.slice(1),type:s==null?"heading":"headingWithAction",size:n?.size||"m",action:s===null?null:{onAction:s,label:"Change"}}),Yc=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Uc(r,i)).map(i=>i.type==="remove"?Fc(e,t,n,s,i,o):i.type==="change"?jc(e,t,n,s,i,o):null).filter(i=>!!i),Sr=(e,t,n={})=>()=>{const s=r=>{const o=r;return Object.entries(n).forEach(i=>{const[l,a]=i;o[l]=a}),o};t({pageId:e.id},s)},Hc=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Cr(c,n,s,t,i));else if(c.collection.route&&(c=wc(c,c.collection.route)||c),mr(c,{...c.formData,...t})){const u=Sr(c,n,i);if(c.collection.heading){const y=c.collection.heading.changeLink?u:null,h=$c(c.collection.heading,c.id,r,y,t);l=l.concat(h)}const m=Mc(c,t,r,o),f=je({...c,formData:{...c.formData,...t}},m,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Cr=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?Sr({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(Bc(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?xe(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?xe(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((y,h)=>(c=h,y.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const y=c+1,h=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=Yc(e,f,t,y,s,r);if(!u){const w=kc(e,f,e.id,y,p);a=a.concat(w)}h==="top"&&(a=a.concat(A)),a=a.concat(Hc(e.childPages,f,t,n,y,p,r)),h==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},Vc=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Fe,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,qc=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(r=>{const o=t.findIndex(i=>i.id===r);return n<0&&(n=o),o>-1?Vc(t[o]):null})}),firstComponentIndex:n}},Gc=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=qc(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:gt(!1,e,s)},insertAt:o}},Kc=(e,t,n=null)=>{if(Je.showCYA(e,e.formData)){if(e.collection)return Cr(e,t,n,e.formData);const r=He(e.components,e.formData).filter(o=>ut(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case b.CONTAINER:return je(e,o,e.formData[o.fieldId],t,n);case b.COLLECTION:return An(e,o,e.formData[o.fieldId],t,n);default:return wt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=Gc(e,i,r,t);a>-1?r.splice(a,0,l):r.push(l)});const o=e.groups.flatMap(i=>i.components);return r.filter(i=>!o.includes(i.id))}return r}return[]},Wc={getRows:Kc,getCYARowsForContainer:je},gr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},br=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=gr(e.format,s[e.fieldId]))},wr=(e,t,n)=>{e.forEach(s=>br(s,t,n))},Ir=(e,t,n)=>{wr(e.components,t,n)},zc=(e,t,n)=>{e.forEach(s=>Ir(s,t,n))},Jc=(e,t,n)=>{const s={...t};return wr(e.components,s,n),zc(e.pages,s,n),s},Xc={component:br,data:gr,form:Jc,page:Ir},Qc=(e,t,n,s)=>{if(e===Z.HUB&&t){if(t.format===he.CYA)return he.CYA;if(t.components)return Je.get(t,n,s)}if(e===Z.TASK||e===Z.FORM_WITH_TASK)return he.TASK},Zc={get:Qc},Tn="meta",Sn="documents",Xt=e=>e?.[Tn]?.[Sn]||[],eu=(e,t,n,s)=>{const r=s?Xt(t):Xt(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Tn]:void 0,[Sn]:r}},tu={setForField:eu,get:Xt,name:Sn},nu={documents:tu,name:Tn},su=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return!!ee(t,n)}return!1},jt=(e,t)=>{if(e?.value)return e.value;const n=T.Utils.interpolateString(e?.field,t);return ee(t,n)},ru=(e,t)=>{if(!e||!t)return null;const n=T.Utils.interpolateString(e.target,t),s=ee(t,n),r=jt(e,t),o=jt(e.cutoff,t),i=jt(e.ignore,t);let l=null;return s&&r&&Array.isArray(s)&&s.every((a,c)=>c===o?!1:c===i?!0:a===r||e.key&&ee(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},ou=(e,t,n)=>{let s;if(e?.field){const r=T.Utils.interpolateString(e.field,t);s=ee(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},iu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return ee(t,n)||null}return e?.value||null},lu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},au=(e,t)=>{if(e?.condition){const n=e,s=T.Utils.interpolateString(n.field,t),r=ee(t,s);switch(n.condition){case"changes":{const o=`${s}LastValue`,i=n[o]||null;return i===null?(n[o]=r,!1):r!==i?(n[o]=r,!0):!1}case"isTruthy":return!!r;case"isFalsy":return!r;default:return!1}}return!0},cu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=T.Utils.interpolateString(s,t),o=ee(t,r);return o?(n=o,!0):!1}),n||(e.fallback?T.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},uu=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let s="";n.forEach(i=>{if(s!==""&&(s+="."),i.slice(-2)==="[]"){const l=i.slice(0,-2),a=yr(l,t);s+=`${l}[${a}]`}else s+=i});const r=T.Utils.interpolateString(s,t);return ee(t,r)?.length||0},du=(e,t)=>{const n=T.Utils.interpolateString(e.target,t),s=ee(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?ee(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?ee(s,e.key)===e.value:!1},fu={checkValueIsTruthy:su,getIndexOfMatchingValueIn:ru,doesContainValue:du,persistValueInFormData:ou,setValueInFormData:iu,deleteValueInFormData:lu,getLength:uu,getFirstOf:cu},hu=(e,t,n)=>{const s=fu[e.function];if(typeof s=="function")return s(e,t,n)},mu=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(au(s.run_when,t)){const r=hu(s,t,n);if(s.output){const o=T.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");ws(t,o,r)}}}),t),pu={runPageOperations:mu},Eu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Au=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},yu=e=>/^-?\d+$/.test(e),ft=e=>yu(e)?e.padStart(2,"0"):"",ye=e=>{const[t,n,s]=e.split("-");return`${ft(t)}-${ft(n)}-${s}`},_r=e=>{const[t,n]=e.split(":");return`${ft(t)}:${ft(n)}`},Ee="DD-MM-YYYY";q.extend(Re);const Tu=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isAfter(n)};q.extend(Re);const Su=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isBefore(n)};q.extend(Re);const Cu=(e,t,n)=>{const s=n.components?.find(c=>c.fieldId===t.date),r=n.components?.find(c=>c.fieldId===t.time);if(!s||!r||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Be(s,e[n.fieldId],e[n.fieldId])||Be(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ye(e[n.fieldId]?.[t.date]),a=_r(e[n.fieldId]?.[t.time]);return q(`${l} ${a}`,`${Ee} HH:mm`).isBefore(q())};q.extend(Re);q.extend(tn);const gu=(e,t)=>{const n=q(ye(e),Ee).isBefore(q()),s=q(ye(e),Ee).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};q.extend(Re);q.extend(tn);const bu=(e,t)=>q(ye(e),Ee).isAfter(q())?!0:!!t?.todayAllowed&&q(ye(e),Ee).isToday(),wu=(e,t)=>e?e.length>t.value:!0,Iu=(e,t)=>e?e.length<t.value:!0,_u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Pu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},xu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Nu=(e,t)=>e?t.array.includes(e):!0,Ou=(e,t,n,s)=>{if(!e||!s)return!0;const r=It(t.collectionPath,s);return!Ue(t.collectionPath,s)?.some(l=>l.id===r?!1:t.caseInsensitive&&typeof e=="string"&&typeof l[n.id]=="string"?l[n.id].toUpperCase()===e.toUpperCase():l[n.id]===e)},Ru=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),vu=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Lu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,Du=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Lu.test(t)}return!1},Fu=(e,t,n)=>n.components?.reduce((r,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?r:r+1:r,0)<2,ju={conditionallyPermittedChange:Eu,conditionallyRequired:Au,mustBeAfter:Tu,mustBeBefore:Su,mustBeEarlierDateTime:Cu,mustBeGreaterThan:_u,mustBeInTheFuture:bu,mustBeInThePast:gu,mustBeLessThan:Pu,mustBeLongerThan:wu,mustBeNumbersOnly:xu,mustBeOneOf:Nu,mustBeShorterThan:Iu,mustBeUniqueInCollection:Ou,mustEnterAtLeastOne:Ru,mustHaveLessThanDecimalPlaces:vu,mustNotContainSql:Du,mustSelectOnlyOne:Fu},Uu=(e,t,n,s)=>{const r=ju[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Pr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Uu(t,r,e,n))}),s}},ht=(e,t,n)=>{if(!e)return[];const s=n||t,r=Pr(e,s);if(r)return{id:e.id,error:r};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;He(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Be({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Mu=(e,t,n)=>{const s=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((r,o)=>{const i=(e.countOffset||0)+o+1,l=`${e.full_path||e.fieldId}[${o}]`,a={full_path:l,components:e.item.map(c=>{const u={...c,full_path:`${l}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(m=>({...m,message:T.Utils.interpolateString(o===0&&m.firstOnlyMessage?m.firstOnlyMessage:m.message,{index:i})}))),u})};s.push(ht(a,r,n))}),s.filter(r=>!!r).flat()};q.extend(Re);q.extend(tn);q.extend(Wr);const ku=(e,t)=>e==="02"?q().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,xr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ye(e),[n,s,r]=t.split("-"),o=parseInt(n,10),i=parseInt(s,10),l=[],a=[];if(r.length===0?(l.push("year"),a.push("Date must include a year")):r.length!==4&&(l.push("year"),a.push("Year must be 4 numbers")),s.length===0?(l.push("month"),a.push("Date must include a month")):(i>12||i<1)&&(l.push("month"),a.push("Month must be between 1 and 12")),n.length===0)l.push("day"),a.push("Date must include a day");else{const c=ku(s,r);(o>c||o<1)&&(l.push("day"),a.push(`Day must be between 1 and ${c}`))}if(l.length>0){const c={};return l.includes("day")&&(c.day=!0),l.includes("month")&&(c.month=!0),l.includes("year")&&(c.year=!0),{message:l.length===1?a[0]:"Enter a valid date",propsInError:c}}return q(t,Ee).format(Ee)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},$u=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,Bu=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,Nr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&($u.test(e)||Bu.test(e)))return;if(Array.isArray(n)){const r=n.filter(o=>o.type==="format");if(r&&r.length>0&&r[0].message)return r[0].message}return`Enter ${s} in the correct format, like jane.doe@homeoffice.gov.uk`}},Yu="Invalid files must be deleted",Or=(e,t)=>{if(!e)return;let n=!1;if(e.every(s=>(n=s.error,!n)),n){if(Array.isArray(t)){const s=t.filter(r=>r.type==="invalidFile");if(s&&s.length>0&&s[0].message)return s[0].message}return Yu}},Rr=(e,t,n,s)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(s)){const o=s.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},vr=(e,t,n)=>{let s=!1;if((e||e===!1||e===0)&&(s=!0,typeof e=="string"?s=e.trim().length>0:Array.isArray(e)&&(s=e.length>0)),!s){if(Array.isArray(n)){const o=n.filter(i=>i.type==="required");if(o&&o.length>0&&o[0].message)return o[0].message}return`${t||"Field"} is required`}},Lr=(e,t,n,s,r,o=1e3)=>{if(!n||!r&&!t)return;if(r&&!t||t.length>o){if(Array.isArray(s)){const l=s.filter(a=>a.type==="length");if(l&&l.length>0&&l[0].message)return l[0].message}return`${e} must be ${o} characters or less`}},Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=_r(e),[n,s]=t.split(":"),r=parseInt(n,10),o=parseInt(s,10),i=[],l=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),l.push("Enter a valid time")),n.length===0?(i.push("hour"),l.push("Time must include a hour")):(r>23||r<0)&&(i.push("hour"),l.push("Hour must be between 0 and 23")),s.length===0?(i.push("minute"),l.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),l.push("Minute must be between 0 and 59")),i.length>0){const c={};return i.includes("hour")&&(c.hour=!0),i.includes("minute")&&(c.minute=!0),i.includes("invalid")&&(c.invalid=!0),{message:i.length>1?"Enter a valid time":l[0],propsInError:c}}return{message:void 0,propsInError:void 0}},Hu=(e,t)=>e?.type==="or"?se.meetsOne(e.conditions,t):se.meetsAll(e.conditions,t),Be=(e,t,n)=>{const s=n||t;if(!Ce(e,{...s,...t}))return;if(e.type===b.CONTAINER)return ht(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===b.COLLECTION_SUMMARY&&(l=Ue(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!Hu(e.requiredOverrideConditions,s))&&(r=vr(l,e.label,e.custom_errors)),!r){switch(e.type){case b.COLLECTION:return Mu(e,l,s);case b.EMAIL:r=Nr(l,e.label,e.custom_errors);break;case b.DATE:case b.TIME:{const a=e.type===b.DATE?xr:Dr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case b.CHECKBOXES:case b.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ye(n[e.id],c)&&(a=a.concat(ht({components:c.nested},n)))}),a.length>0)return a;break}case b.MULTI_FILE:r=Or(l,e.custom_errors);break;case b.TEXT_AREA:r=Lr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=Rr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Pr(e,l,n),e.type===b.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},Vu=(e,t=[])=>{let n=e.formData;if(e.collection){const s=dt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...dt.getData(e.collection.name,e.formData)?.[s]})}return Ct(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ce(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Be(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:T.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},qu={component:Be,container:ht,email:Nr,date:xr,multifile:Or,page:Vu,regex:Rr,required:vr,textarea:Lr,time:Dr},g={CheckYourAnswers:Wc,CollectionPage:dt,Component:ze,Condition:se,Container:St,Data:le,Format:Xc,FormPage:Je,Hub:Zc,Meta:nu,Operate:pu,Validate:qu,...T.Utils},Gu="hods-form-container",Cn=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:m})=>{if(typeof s=="function")if(m.name===g.Meta.name)s({target:m});else{const f={...t,[m.name]:m.value};s({target:{name:e.fieldId,value:f}})}},a=m=>{const f=`${e.full_path||e.fieldId}.${m.fieldId}`;return m.type===b.CONTAINER?g.Container.show({...m,full_path:f},n):g.Component.show({...m,full_path:f},{...n,...ee(n,e.full_path)})},c=g.classBuilder(Gu,[],e.className),u=T.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(T.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((m,f)=>{const y=m.type===b.FILE?{}:"",h=t?t[m.fieldId]:y,p=`${e.full_path||e.fieldId}.${m.fieldId}`;return d.jsx(Fe,{...i,component:{...m,full_path:p,readonly:!!(e.readonly||m.readonly)},formData:n,value:h||y,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},Ku=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,"action")){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},ns=({group:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ku(e))},[e,n]),e?.action?d.jsxs(T.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&d.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},Wu=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(T.SmallHeading,{children:e}),t==="m"&&d.jsx(T.MediumHeading,{children:e})]}),zu=({row:e,classes:t,noChangeAction:n=!1})=>d.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[d.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&d.jsx(T.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(T.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(En,{row:{action:e.action}})})]}),Ju="govuk-summary-list",Qt=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=Ju,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=T.Utils.classBuilder(r,o,i),u=T.Utils.cleanHtmlAttributes(a);let m=null;if(s){const f=e.filter(y=>!!y.action);m=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const y=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(or,{title:f.key,classes:c},y):f.type==="heading"?d.jsx(Wu,{title:f.key,size:f.size||"s",classes:c},y):f.type==="headingWithAction"?d.jsx(zu,{row:f,classes:c,noChangeAction:t},y):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(ns,{group:f})},`${y}-actions`):d.jsx(rr,{row:f,classes:c,showAction:!t},y)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(ns,{group:m})})]})})},Xu="hods-check-your-answers",Qu="Check your answers",ss=9,Zu=({title:e=Qu,titleSize:t="l",pages:n,actions:s=[],onAction:r,onRowAction:o,hide_page_titles:i=!1,hide_actions:l=!1,hide_title:a=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:m,groups:f,sections:y=[],type:h,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[w,L]=O.useState([]),[C,I]=O.useState([]),{errors:_}=De(),{hooks:U}=ge();O.useEffect(()=>{const N=(Y,H)=>g.CheckYourAnswers.getRows(Y,o,U.onGetCYARows).map((K,J)=>({...K,value:d.jsx(fn,{value:K.value,component:K.component,formData:Y.formData,placeholder:A},`${H}_${J}`)})),M=g.CollectionPage.mergePages(n).map((Y,H)=>{const V=N(Y,H);return V?.length?{...Y,rows:V}:null}).filter(Y=>!!Y);L(M)},[n,o,L]);const S=i?0:ss,R=N=>N===w.length-1;O.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map(M=>M.pageId):[];I(j)})()},[I,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:m,groups:f,errors:_,sections:y,type:h});if(v)return v;const D=N=>C.includes(N),x=N=>f?.find(j=>j.pageId===N),k=(N,j)=>{if(!N.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]});const M=gt(!1,N,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(En,{row:{action:M}})})]})},P=()=>Array.from(new Set(_.map(j=>j.id))).map(j=>_.find(M=>M.id===j));return d.jsxs("div",{className:Xu,children:[e&&!a&&d.jsx(T.Heading,{size:t,children:e},"heading"),_&&_.length>0&&d.jsx(T.ErrorSummary,{errors:P()}),h===Z.TASK_CYA&&w.length>0&&y&&y.map(N=>N.tasks.filter(j=>j.state!==B.TYPES.SKIPPED).map((j,M)=>{const Y=w.filter(H=>j.pages.some(V=>V===H.name));return d.jsxs(O.Fragment,{children:[d.jsx(T.MediumHeading,{children:Y.length>0&&(j.displayName||j.name)}),Y.map((H,V)=>{const K=D(H.id)||u,J=!i&&H.title&&!D(H.id);return d.jsxs(O.Fragment,{children:[J&&k(H,"s"),d.jsx(Qt,{rows:H.rows,classModifiers:c,noChangeAction:K,noGroupAction:m,isGroup:D(H.id)})]},V)})]},M)})),h!==Z.TASK_CYA&&w&&w.map((N,j,M)=>{const Y=!p||N.collection?N.rows:N.rows.filter(ae=>ae?.value?.props?.value);if(Y.length===0)return null;const H=!i&&N.title&&!D(N.id),V=R(j)||D(M[j].id)||M.length>j+1&&D(M[j+1].id)?ss:S,K=D(N.id)?x(N.id):void 0,J=`govuk-!-margin-bottom-${V}`,de=D(N.id)||u;return d.jsxs(O.Fragment,{children:[H&&k(N,"m"),K&&d.jsx("div",{className:"group-title",children:d.jsx(T.MediumHeading,{children:K.title||g.FormPage.getTitle(N.title,N.formData)})}),d.jsx(Qt,{className:J,rows:Y,classModifiers:c,noChangeAction:de,noGroupAction:m,isGroup:D(N.id)})]},j)}),!l&&d.jsx(mn,{actions:s?.filter(N=>g.Component.show(N,n[n.length-1].formData)),onAction:N=>r(N)})]})},ed=nr,td=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=ed,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=O.useState({});let m=g.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let y=g.CollectionPage.getActiveIndex(e.collection.name,e.formData);const h=e,p=({target:_})=>{g.CollectionPage.setData(h.collection.name,_.value,e.formData),m=_.value;const U=e.collection.name.split(".").shift();u(S=>({...S,[U]:g.CollectionPage.getData(U,e.formData)}))},A=({target:_})=>{h.formData[_.name]=_.value,u(U=>({...U,[_.name]:_.value}))},w=_=>{p({target:{value:_}}),typeof n=="function"&&n(e.formData)},L=_=>{y=m.length,A({target:{name:`${f}ActiveId`,value:_}})},C=_=>{s(_,c,{})},I=({target:_})=>{if(y===null){const U=mt.v4();L(U),w([...m,{id:U,[_.name]:_.value}])}else w([...m.slice(0,y),{...m[y],[_.name]:_.value},...m.slice(y+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(pn,{page:{...e,formData:{...e.formData,...m[y],[`${f}ActiveIndex`]:y,[`${f}NumberedIndex`]:typeof y=="number"?y+1:null},components:e.components.map(_=>({..._,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:I,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},nd="hods-task-list",sd=({state:e=B.TYPES.CANNOT_START_YET})=>{const t=T.Utils.classBuilder(nd,void 0,void 0),n=B.DETAILS[e]||B.DETAILS.cannotStartYet;return d.jsx(T.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},rd="hods-task-list",od=({task:e,onClick:t})=>{const n=T.Utils.classBuilder(rd,void 0,void 0),[s,r]=O.useState(e.state!==B.TYPES.CANNOT_START_YET),[o,i]=O.useState(e.state);O.useEffect(()=>{r(e.state!==B.TYPES.CANNOT_START_YET),i(e.state)},[e.state,r,i]);const l=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:s?d.jsx(T.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(sd,{state:o})]})},id="hods-task-list",ld="Incomplete form",ad=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=ld,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=id,classModifiers:u=[],className:m="",formData:f={},annotations:y=[],...h})=>{const p=T.Utils.classBuilder(c,u,m),A=T.Utils.cleanHtmlAttributes(h),[w,L]=i.filter(S=>!S.skipped).reduce((S,R)=>[S[0]+(R.tasks?.filter(v=>v.state===B.TYPES.COMPLETE).length??0),S[1]+(R.tasks?.filter(v=>v.state!==B.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:I,text:_}=s&&s||{},U=S=>{typeof a=="function"&&a(S)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),y.length>0&&y.map(S=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:T.Utils.interpolateString(S.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:T.Utils.interpolateString(S.value,f)})]},S.key)),o&&L!==w&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:r})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${w} of ${L} sections`}),I&&_&&Ce(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:T.Utils.interpolateString(I,f)})}),d.jsx(T.TextArea,{id:C,fieldId:C,readOnly:!0,value:T.Utils.interpolateString(_,f)})]}),i.filter(S=>!S.skipped).map((S,R)=>d.jsxs(O.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${R+1}. `:" ",S.name]}),S.label&&d.jsx(T.Hint,{children:S.label}),d.jsx("ol",{className:p("items"),children:S.tasks.filter(v=>v.state!==B.TYPES.SKIPPED).map(v=>d.jsx(od,{task:v,onClick:U},`${S.name}-${v.name}`))})]},`${S.name}`))]})},Fr=(e,t)=>e?.page||t,cd=(e,t,n)=>{const s=Fr(e.action,e.pageId);s!==t&&n(s)},ud=(e,t,n,s=void 0)=>{const r=Fr(e,t);r!==t&&n(r,s)},dd=(e,t)=>{t(e)},pe={cyaAction:cd,navigate:ud,submissionError:dd},fd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,hd=(e,t)=>t(e).length===0,md=["radios","checkboxes"],pd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Ed(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ye(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const jr=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!md.includes(s.type))return;Ed(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...pd(t.collection.name,t.formData),...n};const s=Ue(t.collection.name,n);if(s){const r=It(t.collection.name,n),o=s.map(i=>i.id===r?jr(i,{...t,collection:void 0}):i);yn(t.collection.name,o,n)}}return n},Ad=(e,t,n)=>{if(e===te.HUB&&n===he.CYA)return{title:""};if(e===te.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===te.PARTIAL_CYA){const r=g.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Ur=(e,t,n)=>{if(e)return e===te.HUB?n===he.CYA||n===he.TASK?void 0:n:t.find(s=>s.id===e)},yd=(e,t,n)=>({pageId:e,cya:Ad(e,t,n),page:Ur(e,t,n)}),rs=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Td=(e,t,n)=>e.page?.type===te.PARTIAL_CYA?rs(n||t,e.pageId):n||t,os=(e,t,n,s,r)=>{if(!t&&r===Z.FORM_WITH_TASK){if(s?.formStatus?.taskPage){const i=n.find(l=>l.id===s.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:te.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{Je.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||te.HUB},Mr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!Je.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Sd=(e,t,n)=>Mr(e,t,n)||te.CYA,Cd=e=>e.length>0?e[0].id:void 0,Zt=(e,t,n,s,r)=>{if(s){if(s.type===G.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===G.TYPES.SAVE_AND_RETURN)return e===Z.HUB?te.HUB:void 0}switch(e){case Z.HUB:return os(s);case Z.CYA:return Sd(t,n,r);case Z.FORM_WITH_TASK:case Z.TASK:return os(s,n,t,r,e);case Z.WIZARD:return Mr(t,n,r);default:return Cd(t)}},gd=(e,t,n,s,r,o,i,l)=>{if(e===Z.TASK||e===Z.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(te.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===G.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:Zt(e,t,n,s,r)}:o.pages?.includes(n)&&(a.tasks[o.name]={complete:!!s?.complete,currentPage:n}):l&&l.forEach(c=>{c.tasks.forEach(u=>{const m=u.pages[u.pages.length-1];(m===n||m.id===n)&&i&&u?.type==="pre-task-list"?a.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(a.tasks[u.name]={complete:!1,currentPage:n})})}),a.taskPage=a.tasks[o.name].currentPage,a}return s?.type===G.TYPES.SAVE_AND_RETURN?{page:n}:{page:Zt(e,t,n,s,r)}},bd=({complete:e,currentPage:t},n=B.TYPES.NOT_STARTED)=>e?B.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?B.TYPES.IN_PROGRESS:n,wd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===B.TYPES.SKIPPED?s:s&&o?.complete},!0),kr=(e,t)=>{const n=e[t-1].state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:kr(e,t-1):!1},Id=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return bd(s[e.name],e.state);if(r)return e.depends_on&&!wd(s,e.depends_on,e.ignoreSkipped)?B.TYPES.CANNOT_START_YET:B.TYPES.NOT_STARTED;let i=o;return t&&(i=kr(n,t)),i?B.TYPES.NOT_STARTED:B.TYPES.CANNOT_START_YET},_d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==B.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Id(l,i,r,t,n,s)}),r},$r=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:$r(e,t-1):!1},Pd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!g.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:B.TYPES.SKIPPED}))}:{...i}});r.forEach(i=>{const l=i;l.tasks=l.tasks.map(a=>{const c=a.show_when?[a.show_when].flat():[];return s&&!g.Condition.meetsAll(c,s)?{...a,state:B.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===B.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:B.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||$r(r,l);a.tasks=_d(a,o,n,c)}),r},xd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},Oe=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)Oe(e[r],t);const n=t.split(".");let s=e;for(let r=0;r<n.length-1;r+=1)if(s=s[n[r]],s===void 0)return;s[n[n.length-1]]&&delete s[n[n.length-1]]},Br=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},gn=(e,t)=>{const n=Br(e);return n?`${n}.${t}`:t},Nd=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&e.splice(t,1)}},Od=e=>{const t=(n,s)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(r=>{t(r,s)}):Object.keys(n).forEach(r=>{r==="field"&&s.push(n[r]),t(n[r],s)})),s);return e.show_when?new Set(t(e.show_when,[])||[]):null},Rd=(e,t)=>{const n=e.split(".");for(let s=n.length;s>0;s-=1){const r=n.slice(0,s).join("."),o=t.get(r);if(o)return o}return null},ke=(e,t)=>e.show_when?e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t):!0,Yr=(e,t,n)=>{const s=t.get(e.use)??n.get(e.use)??e,r=JSON.parse(JSON.stringify(s));return e.use&&e.show_when&&(r.show_when=e.show_when),r},vd=(e,t,n)=>{const{meta:{documents:s}}=n,r=t[e.fieldId];if(!s||!r)return;const o=Array.isArray(r)?r:[r];for(let i=o.length-1;i>=0;i-=1){const l=s.findIndex(a=>a.url===o[i].url);l!==-1&&s.splice(l,1)}},en=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):en(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):en(e[t])})},Hr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Ld=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;Oe(e,t),Hr(n,r=>{const o=gn(t,r.fieldId);s[o]>1?s[o]-=1:Oe(e,o)})}},Dd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&vd(r,n,s),r.preserveInPayload)return;Oe(n,r.fieldId),Hr(r,o=>{const i=gn(r.fieldId,o.fieldId);e.has(i)||Oe(n,i)})}})},is=e=>Array.isArray(e)?e:[e],Fd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,m)=>{u.fieldId&&(m=m?`${m}.${u.fieldId}`:u.fieldId,o[m]=(o[m]||0)+1,u.path=m,c.show_when&&(u.show_when=u.show_when?[...is(c.show_when),...is(u.show_when)]:c.show_when),xd(m,u,r),u.components?u.components.forEach(f=>{a(c,f,m)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const y=!Ye(ee(s,m),f),h=f.show_when;f.nested.forEach(p=>{y&&i.push(gn(m,p.fieldId)),h&&(p.show_when=h),a(c,p,Br(m))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const m=Yr(u,t,n);a(c,m,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:Oe(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},jd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=Od(s);if(r)if(t.has(s.path)){const o=t.get(s.path);r.forEach(i=>o.add(i))}else t.set(s.path,new Set(r))})}),t},Ud=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const y=Rd(f,t);if(y)y.forEach(h=>{a.has(h)||i(a,h,u)});else{const h=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(h);if(p){const A=p[1],w=s.get(A);w&&w.childPages?.forEach(L=>{if(L.show_when){const C=JSON.stringify(L.show_when),I=`It is not possible to reliably clean hidden data when a component is dependent on a
|
|
7
10
|
collection's data, and that collection is itself dependent on data elsewhere in the form.
|
|
8
|
-
The dependency path is ${
|
|
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;
|
|
11
|
+
The dependency path is ${f}, and the chained show_when is ${C}.
|
|
12
|
+
The form will need to be changed to break this chained dependency`;throw new Error(I)}})}}}),ke(c,o)||Ld(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(m=>{l.has(m)||i(l,m,e)})})},Md=(e,t,n,s)=>{e?.forEach((r,o)=>{ke(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(m=>{const f=ke(m,a);m.components?.forEach(y=>{const h=Yr(y,n,s);if(!h.fieldId)return;const p=ke(y,a);f&&p&&ke(h,a)?c.add(h.fieldId):u.set(h.id,h)})}),Dd(c,u,l,t)}),i&&Nd(i)})},kd=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=Tr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Fd(o,s,r,n),c=jd(i);return Ud(c,i,l,a,t,n),Md(a,n,s,r),en(n),n},W={canActionProceed:fd,canCYASubmit:hd,cleanHiddenNestedData:jr,getFormState:yd,getRelevantPages:Td,getNextPageId:Zt,getPage:Ur,getSubmissionStatus:gd,getUpdatedSectionStates:Pd,clearOutUncompletedRoutes:kd},$d=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w)=>{if(t.type===G.TYPES.SUBMIT&&y!==he.TASK){if(e("submit"),W.canCYASubmit(n,s.pages)&&!A){w(!0);const L=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),C={pages:n,components:o};W.clearOutUncompletedRoutes(r,C,L),L.formStatus=W.getSubmissionStatus(a,n,c,t,L,u,!0),l(L),m.onSubmit(t.type,L,()=>{m.onFormComplete(),w(!1)},I=>{w(!1),pe.submissionError(I,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?W.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===G.TYPES.SAVE_AND_CONTINUE&&y===he.TASK&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(te.HUB)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SUBMIT&&y===he.TASK&&(e("submit"),C)){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),_={pages:n,components:o};W.clearOutUncompletedRoutes(r,_,I),I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{m.onFormComplete(),w(!1)},U=>{w(!1),pe.submissionError(U,f)})}if(t.type===G.TYPES.SAVE_AND_NAVIGATE&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(t.page)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SAVE_AND_RETURN&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!1),l(I),m.onSubmit(t.type,I,()=>{a===Z.TASK?h(void 0):h(te.HUB),w(!1)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.NAVIGATE&&(h(W.getNextPageId(a,n,c,t,p.page?.formData)),w(!1)),t.type===G.TYPES.CANCEL){const I=g.Format.form({pages:n,components:o},{...i},Te.CANCEL);m.onCancel(I),w(!1)}}},ls=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w,L,C,I,_)=>{const U={...r},S=o,R=s.onAction(S.page.formData,t,r,e.customAction);S.page.formData=R.formData;let v=R.patch;if(S.page.formData={...S.page.formData,...v},e.type===G.TYPES.CANCEL){s.onCancel(S.page.formData),I(!1);return}if(W.canActionProceed(e,S.page,i.page,_)&&(!C||e.ignoreSubmittingFlag))if(v=W.cleanHiddenNestedData(v,S.page),I(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?yn(x.field,x.value,o.page.formData):g.Data.setDataItem(o.page.formData,x.field,x.value)}),S.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===G.TYPES.NAVIGATE)pe.navigate(e,f,l),I(!1);else{let D=V=>l(W.getNextPageId(a,u,f,e,V)),x,k;e.collection&&(x=e.collection,k=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let P,N;switch(x&&(P=S.page.formData[x],P&&P.length>0&&S.page.formData[`${x}ActiveId`]&&(N=P.findIndex(V=>V.id===S.page.formData[`${x}ActiveId`]))),e.type){case G.TYPES.SUBMIT:y("submit");break;case G.TYPES.SAVE_AND_NAVIGATE:const V={...h};P&&P.length>0&&e.resetActiveId&&(S.page.formData[`${x}ActiveId`]=P[0].id),P&&P.length>0&&!e.resetActiveId&&(N!==void 0&&N+1<S.page.formData[x].length&&(S.page.formData[k]="Yes"),N!==void 0&&N+1===S.page.formData[x].length&&S.page.formData[k]&&(S.page.formData[k]="No")),D=()=>pe.navigate(e,f,l,V);break;case G.TYPES.COLLECTION_ADD:if(N===void 0||P.length===0||N+1===S.page.formData[x].length?g.CollectionPage.addEntry(e.collection,S.page.formData):S.page.formData[`${e.collection}ActiveId`]=P[N+1].id,S.page.formData[`${e.collection}`]&&S.page.formData[`${e.collection}`].length>0){const ae=S.page.formData[`${e.collection}`].length-1;Object.keys(S.page.formData[`${e.collection}`][ae]).filter(re=>re in S.page.formData&&re!=="id").forEach(re=>delete S.page.formData[re])}D=()=>pe.navigate(e,f,l);break;case G.TYPES.COLLECTION_DUPLICATE:g.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(D=()=>pe.navigate(e,f,l));break;case G.TYPES.COLLECTION_REMOVE:const K=e.targetId||S.page.formData[`${e.collection.split(".").pop()}ActiveId`],J=g.CollectionPage.removeEntry(e.collection,o.page.formData,K);e.recordRemoval&&(S.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...J});const de=S.page.formData.id;J!==null&&Object.keys(J).filter(fe=>fe in S.page.formData).forEach(fe=>delete S.page.formData[fe]),Object.assign(S.page.formData,P[P.length-1]),S.page.formData.id=de,P.length>0?S.page.formData[`${e.collection}ActiveId`]=P[P.length-1].id:(delete S.page.formData[`${e.collection}ActiveId`],delete S.page.formData[e.collection]),D=()=>pe.navigate(e,f,l);break}g.Data.deleteValues(r,o.page.formData);const j=g.Format.form({pages:u,components:m},{...r,...t,...o.page.formData},Te.SUBMIT);j.formStatus=W.getSubmissionStatus(a,u,f,e,j,h,!0,A?.sections),v&&p(j);const M={pages:u,components:m};e.type===G.TYPES.SUBMIT&&W.clearOutUncompletedRoutes(c,M,j);let Y,H;a===Z.HUB&&Object.keys(n).length>0&&(Y=Object.keys(n)[0],H=Object.values(n)[0]),s.onSubmit(e.type,j,V=>{const K={...j,...V};w({data:K}),D(K),I(!1)},(V,K=!0)=>{pe.submissionError(V,L),K&&p({...U}),I(!1)},Y,H,f)}},as=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(W.getPage(a,t))}),n(e);const l={...i};if(i.state===B.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(te.CYA,l);else if(i.state===B.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},Vr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:m=Bd,classModifiers:f=[],className:y="",hide_title:h,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:w="",viewOnly:L=!0,hideBlankRows:C=!1})=>d.jsx(Qs,{overrides:u,children:d.jsx(Zs,{children:d.jsx(Yd,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:m,classModifiers:f,className:y,hashLink:c,hide_title:h,summaryListClassModifiers:p,noChangeAction:A,newPageId:w,viewOnly:L,hideBlankRows:C})})}),Bd="hods-form",Yd=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:m,hashLink:f,hide_title:y,summaryListClassModifiers:h,noChangeAction:p,newPageId:A,viewOnly:w,hideBlankRows:L})=>{const[C,I]=O.useState({}),[_,U]=O.useState(),[S,R]=O.useState([]),[v,D]=O.useState(void 0),[x,k]=O.useState(W.getNextPageId(n,o,null,null,a)),[P,N]=O.useState(W.getFormState(x,S,v)),[j,M]=O.useState({}),[Y,H]=O.useState({}),[V,K]=O.useState("load"),[J,de]=O.useState(!1),[ae,fe]=O.useState(!1),{hooks:re}=ge(),{addErrors:_t,clearErrors:bn,errors:wn,validate:Pt}=De();window.onpopstate=$=>{if(!document.location.hash&&($.state&&$.state.fullPages!==void 0&&M(X=>({...X,fullPages:$.state?.fullPages})),bn(),de(!0),re.onGoingBack($.state?$.state:null,...P.page.formData),r&&S&&C&&P.page?.formData&&V===void 0)){const X=g.Format.form({pages:S,components:r},{...C,...P.page.formData},Te.SUBMIT);if(X?.formStatus?.taskPage){const ne=X.formStatus.tasks;Object.keys(ne).forEach(Se=>{const Pn=ne[Se];Pn.currentPage&&!Pn.complete&&delete ne[Se].currentPage}),delete X.formStatus.taskPage}I(X)}},O.useEffect(()=>{r&&o&&a&&(V==="load"||w)&&(I(g.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,I,V,w]),O.useEffect(()=>{R(g.FormPage.getAll(o,r,{...C}))},[r,o,C,R]),O.useEffect(()=>{k($=>$||W.getNextPageId(n,S))},[n,S,k]),O.useEffect(()=>{D(g.Hub.get(n,i,r,{...C}))},[n,i,C,r,D]),O.useEffect(()=>{n===Z.HUB&&J&&C&&P.page?.formData&&(P.page.formData={...C}),de(!1),N(W.getFormState(x,S,v))},[S,v,x,N,n,J,C,P.page]),O.useEffect(()=>{K(void 0),re.onFormLoad($=>{M($)})},[re]),O.useEffect(()=>{H(i)},[i]),O.useEffect(()=>{_?.data&&(I(_.data),U(void 0))},[_,I,U]);const xt=i?.sections,In=i?.nonSequential;O.useEffect(()=>{const $=j.fullPages;if($&&($.forEach(X=>{const ne=X;ne&&(ne.formData=C)}),M(X=>({...X,fullPages:$}))),xt){const X=C?.formStatus?.tasks||{},ne=W.getUpdatedSectionStates(xt,X,In,C);H(Se=>({...Se,sections:[...ne]}))}},[j.fullPages,C,xt,In]);const Pe=($,X={})=>{bn(),k($),re.onPageChange($,X)};O.useEffect(()=>{A!==void 0&&k(A)},[A]);const _n=$=>{re.onChange($)},qr=($,X)=>{if(typeof X=="function"){const ne=X({...C});ne&&I(ne)}P.page?.type===te.PARTIAL_CYA&&!l.disableTaskSwitch&&Y.sections.every(ne=>ne.tasks.every(Se=>Se.pages.includes($.pageId)&&Se.name!==j.name?(as(Se,S,M,Y,C,Pe),!1):!0)),$&&pe.cyaAction($,x,Pe)},Gr=g.classBuilder(c,u,m);if(v===he.TASK){const $=l;$.actions=[G.TYPES.SAVE_AND_CONTINUE,G.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:Hd,nonSequential:Vd,...Kr}=Y;return d.jsxs("div",{className:Gr(),children:[e&&!y&&x===te.HUB&&d.jsx(T.Heading,{size:t,children:e}),P.cya&&d.jsx(Zu,{pages:W.getRelevantPages(P,S,j.fullPages),...l,...P.page?.type===te.PARTIAL_CYA&&{actions:P.page.actions?.filter($=>g.Component.show($,C))},...P.cya,onAction:$=>{$d(K,$,S,Pt,s,r,C,I,n,x,j,re,_t,v,Pe,P,ae,fe)},onRowAction:qr,summaryListClassModifiers:h,hide_title:y,noChangeAction:P.cya.hideChangeActions??p,noGroupAction:P.cya.hideGroupActions??!1,sections:typeof Y<"u"?Y.sections:[],type:n,hideBlankRows:L}),v===he.TASK&&P.pageId===te.HUB&&d.jsx(ad,{...Kr,refNumber:C.businessKey,onTaskAction:$=>{as($,S,M,Y,C,Pe)},annotations:Y?.taskListAnnotations||[],formData:C}),P.page&&!P.cya&&!P.page.collection&&d.jsx(pn,{page:P.page,pages:[...S],onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},onChange:_n,hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae,pageId:x}),P.page&&!P.cya&&P.page.collection&&d.jsx(td,{page:P.page,pages:S,onCollectionChange:_n,onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae})]})};exports.Container=Cn;exports.FormComponent=Fe;exports.FormRenderer=Vr;exports.FormTypes=Z;exports.HooksContextProvider=Qs;exports.HubFormats=he;exports.Models=Mo;exports.PageActions=mn;exports.SummaryList=Qt;exports.Utils=g;exports.ValidationContextProvider=Zs;exports.default=Vr;
|