@openmrs/esm-form-engine-app 12.3.5-pre.12649 → 12.3.5-pre.12652
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/.turbo/turbo-build.log +1 -1
- package/dist/401.js +2 -2
- package/dist/5897.js +1 -1
- package/dist/6999.js +1 -1
- package/dist/8720.js +1 -1
- package/dist/999.js +1 -1
- package/dist/openmrs-esm-form-engine-app.js +2 -2
- package/dist/openmrs-esm-form-engine-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -3
package/dist/401.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(globalThis.webpackChunk_openmrs_esm_form_engine_app=globalThis.webpackChunk_openmrs_esm_form_engine_app||[]).push([["401"],{9908(e,t,n){"use strict";n.r(t),n.d(t,{createAttachment:()=>l,fetchClobData:()=>h,fetchOpenMRSForm:()=>m,getAllLocations:()=>c,getConcept:()=>s,getLatestObs:()=>f,getLatestObsForConceptSet:()=>p,getLocationsByTag:()=>u,getPatientEnrolledPrograms:()=>g,getPreviousEncounter:()=>d,markPatientAsDeceased:()=>_,saveEncounter:()=>a,savePatientIdentifier:()=>v,savePersonAttribute:()=>b,saveProgramEnrollment:()=>y});var r=n(2293),i=n(498),o=n(1809);function a(e,t,n){let o=n?`${r.restBaseUrl}/encounter/${n}?v=${i.RZ}`:`${r.restBaseUrl}/encounter?v=${i.RZ}`;return(0,r.openmrsFetch)(o,{headers:{"Content-Type":"application/json"},method:"POST",body:t,signal:e.signal})}async function l(e,t,n){let i=new FormData;return i.append("fileCaption",n.fileDescription),i.append("patient",e),n.file?i.append("file",n.file,n.fileName):(i.append("file",new File([""],n.fileName),n.fileName),i.append("base64Content",n.base64Content)),i.append("encounter",t),i.append("formFieldNamespace",n.formFieldNamespace),i.append("formFieldPath",n.formFieldPath),(0,r.openmrsFetch)(`${r.attachmentUrl}`,{method:"POST",body:i})}function s(e,t){return(0,r.openmrsFetch)(`${r.restBaseUrl}/concept/${e}?v=${t}`).then(({data:e})=>e.results)}function u(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?tag=${e}&v=custom:(uuid,display)`).then(({data:e})=>e.results)}function c(){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?v=custom:(uuid,display)`).then(({data:e})=>e.results)}async function d(e,t){let n=`patient=${e}&_sort=-date&_count=1&type=${t}`,o=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Encounter?${n}`);if(o?.data?.entry?.length){let e=o.data.entry[0].resource.id;return(o=await (0,r.openmrsFetch)(`${r.restBaseUrl}/encounter/${e}?v=${i.RZ}`)).data}return null}async function f(e,t,n){let i=`patient=${e}&code=${t}${n?`&encounter.type=${n}`:""}`;i+="&_sort=-date&_count=1";let{data:o}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${i}`);return o.entry?.length?o.entry[0].resource:null}async function p(e,t,n){let i=await f(e,t,n);if(!i)return[];let o=i.encounter?.reference?.split("/").pop();if(!o)return[i];let a=`patient=${e}&code=${t}&encounter=${o}`,{data:l}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${a}`);return l.entry?.map(e=>e.resource)??[]}async function m(e){if(!e)return null;let{url:t,isUUID:n}=(0,o.O)(e)?{url:`${r.restBaseUrl}/form/${e}?v=full`,isUUID:!0}:{url:`${r.restBaseUrl}/form?q=${e}&v=full`,isUUID:!1},{data:i}=await (0,r.openmrsFetch)(t);if(n)return i;if(i.results?.length){let e=i.results.find(e=>!1===e.retired);if(e)return e}throw Error(`Form with ID "${e}" was not found`)}async function h(e){if(!e)return null;let t=e.resources?.find(({name:e})=>"JSON schema"===e);if(!t)return null;let n=`${r.restBaseUrl}/clobdata/${t.valueReference}`,{data:i}=await (0,r.openmrsFetch)(n);return i}function g(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(state:(uuid,name,concept:(uuid),programWorkflow:(uuid)))`).then(({data:e})=>e||null)}function y(e,t){if(!e)throw Error("Program enrollment cannot be created because no payload is supplied");let n=e.uuid?`${r.restBaseUrl}/programenrollment/${e.uuid}`:`${r.restBaseUrl}/programenrollment`;return(0,r.openmrsFetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e,signal:t.signal})}function v(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/patient/${t}/identifier/${e.uuid}`:`${r.restBaseUrl}/patient/${t}/identifier`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)})}function b(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/person/${t}/attribute/${e.uuid}`:`${r.restBaseUrl}/person/${t}/attribute`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:e})}function _(e,t,n,i){if(!n)throw Error(e("patientCannotBeMarkedAsDeceasedBecauseNoPayloadSupplied","Patient cannot be marked as deceased because no payload is supplied"));let o=`${r.restBaseUrl}/person/${t}`;return(0,r.openmrsFetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:n,signal:i.signal})}},498(e,t,n){"use strict";n.d(t,{FU:()=>l,Mi:()=>i,RA:()=>a,RZ:()=>o,ZA:()=>s,t$:()=>r});let r="cf82933b-3f3f-45e7-a5ab-5d31aaee3da3",i="488b58ff-64f5-4f8a-8979-fa79940b1594",o="custom:(uuid,encounterDatetime,encounterType:(uuid,name,description),location:(uuid,name),patient:(uuid,display),encounterProviders:(uuid,provider:(uuid,name),encounterRole:(uuid,name)),orders:(uuid,display,concept:(uuid,display),voided),diagnoses:(uuid,certainty,condition,formFieldPath,formFieldNamespace,display,rank,voided,diagnosis:(coded:(uuid,display))),obs:(uuid,obsDatetime,comment,voided,groupMembers,formFieldNamespace,formFieldPath,concept:(uuid,name:(uuid,name)),value:(uuid,name:(uuid,name),names:(uuid,conceptNameType,name))))",a="forms-engine-store",l=["radio","checkbox","select","content-switcher"],s="OPTION_NULL"},1807(e,t,n){"use strict";n.d(t,{L:()=>r});let r="@openmrs/esm-form-engine-app"},7512(e,t,n){"use strict";n.d(t,{yh:()=>dE,y6:()=>dM,Im:()=>ts,Tn:()=>pG});var r,i={};n.r(i),n.d(i,{boolean:()=>rm,booleanish:()=>rh,commaOrSpaceSeparated:()=>r_,commaSeparated:()=>rb,number:()=>ry,overloadedBoolean:()=>rg,spaceSeparated:()=>rv});var o={};function a(e,t,n){if(!e)return t;let r=JSON.parse(JSON.stringify(t));return r.defaultPage=r.availableIntents?.find(t=>t.intent===(e?.intent||e))?.defaultPage,r.markdown&&s(r.markdown,e),r.pages=r.pages||[],r.pages.forEach(t=>{if(t.isSubform&&t.subform?.form){let n=[],r=t.subform.behaviours?.find(t=>t.intent==e?.intent||e);(r?.readonly!==void 0||r?.readonly!=null)&&n.push({name:"readonly",type:"field",value:r?.readonly}),t.subform.form=a(r?.subform_intent||"*",t.subform?.form,n)}let r=t.behaviours?.find(t=>t.intent===(e?.intent||e));if(r)t.hide=r.hide??t.hide,t.readonly=r.readonly??t.readonly;else{let e=t.behaviours?.find(e=>"*"===e.intent);e&&(t.hide=e.hide??t.hide,t.readonly=e.readonly??t.readonly)}t.markdown&&s(t.markdown,e),t.sections=t.sections||[],t.sections.forEach(t=>{let r=t.behaviours?.find(t=>t.intent===e?.intent||e);if(r)t.hide=r.hide??t.hide;else{let e=t.behaviours?.find(e=>"*"===e.intent);t.hide=e?.hide??t.hide}t.markdown&&s(t.markdown,e),t.questions=t.questions||[],t.questions.forEach(t=>{t.behaviours&&(l(t,e?.intent||e),n?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(e=>{t[e.name]=e.value})),t.questions&&t.questions.length&&t.questions.forEach(t=>{l(t,e?.intent||e),n?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(e=>{t[e.name]=e.value})})})})}),r}function l(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);if(n||r){delete n?.intent,delete r?.intent;let t=Object.assign(r||{},n||{}),i=t.defaultValue;void 0!=i&&(e.questionOptions.defaultValue=i,delete t.defaultValue),e=Object.assign(e,t),delete e.behaviours}}function s(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);n&&r?(delete n.intent,delete r.intent,e=Object.assign(e,Object.assign(r,n)),delete e.behaviours):!n&&r&&(delete r.intent,e=Object.assign(e,r),delete e.behaviours)}n.r(o),n.d(o,{attentionMarkers:()=>aM,contentInitial:()=>aC,disable:()=>aj,document:()=>aD,flow:()=>aA,flowInitial:()=>aF,insideSpan:()=>aV,string:()=>aP,text:()=>aT}),n(2722);var u=n(2293),c=n(498),d=n(5399),f=n.n(d),p=n(3373),m=n.n(p);let h={flexColumn:"-esm-form-engine__obs-group__flexColumn___Rm5Li",flexFullWidth:"-esm-form-engine__obs-group__flexFullWidth___Zd-wp",groupContainer:"-esm-form-engine__obs-group__groupContainer___DYseT",boldLegend:"-esm-form-engine__obs-group__boldLegend___ycIBQ"};var g=n(7685),y=n(324),v=e=>"checkbox"===e.type,b=e=>e instanceof Date,_=e=>null==e;let w=e=>"object"==typeof e;var x=e=>!_(e)&&!Array.isArray(e)&&w(e)&&!b(e),E=e=>x(e)&&e.target?v(e.target)?e.target.checked:e.target.value:e,k=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,S=(e,t)=>e.has(k(t)),O=e=>{let t=e.constructor&&e.constructor.prototype;return x(t)&&t.hasOwnProperty("isPrototypeOf")},D="u">typeof window&&void 0!==window.HTMLElement&&"u">typeof document;function C(e){if(e instanceof Date)return new Date(e);let t="u">typeof FileList&&e instanceof FileList;if(D&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(x(e)&&O(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=C(e[t]));return r}var F=e=>/^\w*$/.test(e),A=e=>void 0===e,P=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>P(e.replace(/["|']|\]/g,"").split(/\.|\[/)),V=(e,t,n)=>{if(!t||!x(e))return n;let r=(F(t)?[t]:T(t)).reduce((e,t)=>_(e)?e:e[t],e);return A(r)||r===e?A(e[t])?n:e[t]:r},M=e=>"boolean"==typeof e,j=e=>"function"==typeof e,I=(e,t,n)=>{let r=-1,i=F(t)?[t]:T(t),o=i.length,a=o-1;for(;++r<o;){let t=i[r],o=n;if(r!==a){let n=e[t];o=x(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}};let N="blur",L="focusout",q="change",R="submit",$="trigger",B="valid",H="onBlur",z="onChange",U="onSubmit",W="onTouched",Y="all",J="max",Z="min",G="maxLength",Q="minLength",K="pattern",X="required",ee="validate",et="form",en="root",er=f().createContext(null);er.displayName="HookFormControlContext";let ei=()=>f().useContext(er);var eo=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let o in e)Object.defineProperty(i,o,{get:()=>{let i=o;return t._proxyFormState[i]!==Y&&(t._proxyFormState[i]=!r||Y),n&&(n[i]=!0),e[i]}});return i};let ea="u">typeof window?f().useLayoutEffect:f().useEffect;function el(e){let t=ei(),{control:n=t,disabled:r,name:i,exact:o}=e||{},[a,l]=f().useState(n._formState),s=f().useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return ea(()=>n._subscribe({name:i,formState:s.current,exact:o,callback:e=>{r||l({...n._formState,...e})}}),[i,r,o]),f().useEffect(()=>{s.current.isValid&&n._setValid(!0)},[n]),f().useMemo(()=>eo(a,n,s.current,!1),[a,n])}var es=e=>"string"==typeof e,eu=(e,t,n,r,i)=>es(e)?(r&&t.watch.add(e),V(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),V(n,e))):(r&&(t.watchAll=!0),n),ec=e=>_(e)||!w(e);function ed(e,t,n=new WeakSet){if(ec(e)||ec(t))return Object.is(e,t);if(b(e)&&b(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;for(let o of(n.add(e),n.add(t),r)){let r=e[o];if(!i.includes(o))return!1;if("ref"!==o){let e=t[o];if(b(r)&&b(e)||x(r)&&x(e)||Array.isArray(r)&&Array.isArray(e)?!ed(r,e,n):!Object.is(r,e))return!1}}return!0}function ef(e){let t=ei(),{control:n=t,name:r,defaultValue:i,disabled:o,exact:a,compute:l}=e||{},s=f().useRef(i),u=f().useRef(l),c=f().useRef(void 0),d=f().useRef(n),p=f().useRef(r);u.current=l;let[m,h]=f().useState(()=>{let e=n._getWatch(r,s.current);return u.current?u.current(e):e}),g=f().useCallback(e=>{let t=eu(r,n._names,e||n._formValues,!1,s.current);return u.current?u.current(t):t},[n._formValues,n._names,r]),y=f().useCallback(e=>{if(!o){let t=eu(r,n._names,e||n._formValues,!1,s.current);if(u.current){let e=u.current(t);ed(e,c.current)||(h(e),c.current=e)}else h(t)}},[n._formValues,n._names,o,r]);ea(()=>(d.current===n&&ed(p.current,r)||(d.current=n,p.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:e=>{y(e.values)}})),[n,a,r,y]),f().useEffect(()=>n._removeUnmounted());let v=d.current!==n,b=p.current,_=f().useMemo(()=>{if(o)return null;let e=!v&&!ed(b,r);return v||e?g():null},[o,v,r,b,g]);return null!==_?_:m}function ep(e){let t=ei(),{name:n,disabled:r,control:i=t,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,s=S(i._names.array,n),u=f().useMemo(()=>V(i._formValues,n,V(i._defaultValues,n,a)),[i,n,a]),c=ef({control:i,name:n,defaultValue:u,exact:l}),d=el({control:i,name:n,exact:l}),p=f().useRef(e),m=f().useRef(void 0),h=f().useRef(i.register(n,{...e.rules,value:c,...M(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;let g=f().useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!V(d.errors,n)},isDirty:{enumerable:!0,get:()=>!!V(d.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!V(d.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!V(d.validatingFields,n)},error:{enumerable:!0,get:()=>V(d.errors,n)}}),[d,n]),y=f().useCallback(e=>h.current.onChange({target:{value:E(e),name:n},type:q}),[n]),v=f().useCallback(()=>h.current.onBlur({target:{value:V(i._formValues,n),name:n},type:N}),[n,i._formValues]),b=f().useCallback(e=>{let t=V(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>j(e.focus)&&e.focus(),select:()=>j(e.select)&&e.select(),setCustomValidity:t=>j(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>j(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),_=f().useMemo(()=>({name:n,value:c,...M(r)||d.disabled?{disabled:d.disabled||r}:{},onChange:y,onBlur:v,ref:b}),[n,r,d.disabled,y,v,b,c]);return f().useEffect(()=>{let e=i._options.shouldUnregister||o,t=m.current;t&&t!==n&&!s&&i.unregister(t),i.register(n,{...p.current.rules,...M(p.current.disabled)?{disabled:p.current.disabled}:{}});let r=(e,t)=>{let n=V(i._fields,e);n&&n._f&&(n._f.mount=t)};if(r(n,!0),e){let e=C(V(i._options.defaultValues,n,p.current.defaultValue));I(i._defaultValues,n,e),A(V(i._formValues,n))&&I(i._formValues,n,e)}return s||i.register(n),m.current=n,()=>{(s?e&&!i._state.action:e)?i.unregister(n):r(n,!1)}},[n,i,s,o]),f().useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),f().useMemo(()=>({field:_,formState:d,fieldState:g}),[_,d,g])}let em=e=>e.render(ep(e));f().createContext(null).displayName="HookFormContext";var eh=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},eg=e=>Array.isArray(e)?e:[e],ey=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function ev(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],o=t[r];if(i&&x(i)&&o){let e=ev(i,o);x(e)&&(n[r]=e)}else e[r]&&(n[r]=o)}return n}var eb=e=>x(e)&&!Object.keys(e).length,e_=e=>"file"===e.type,ew=e=>{if(!D)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ex=e=>"select-multiple"===e.type,eE=e=>"radio"===e.type,ek=e=>eE(e)||v(e),eS=e=>ew(e)&&e.isConnected;function eO(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=A(e)?r++:e[t[r++]];return e}function eD(e){for(let t in e)if(e.hasOwnProperty(t)&&!A(e[t]))return!1;return!0}function eC(e,t){let n=Array.isArray(t)?t:F(t)?[t]:T(t),r=1===n.length?e:eO(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(x(r)&&eb(r)||Array.isArray(r)&&eD(r))&&eC(e,n.slice(0,-1)),e}var eF=e=>{for(let t in e)if(j(e[t]))return!0;return!1};function eA(e){return Array.isArray(e)||x(e)&&!eF(e)}function eP(e,t={}){for(let n in e){let r=e[n];eA(r)?(t[n]=Array.isArray(r)?[]:{},eP(r,t[n])):A(r)||(t[n]=!0)}return t}function eT(e,t,n){for(let r in n||(n=eP(t)),e){let i=e[r];if(eA(i))A(t)||ec(n[r])?n[r]=eP(i,Array.isArray(i)?[]:{}):eT(i,_(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!ed(i,e)}}return n}let eV={value:!1,isValid:!1},eM={value:!0,isValid:!0};var ej=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!A(e[0].attributes.value)?A(e[0].value)||""===e[0].value?eM:{value:e[0].value,isValid:!0}:eM:eV}return eV},eI=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>A(e)?e:t?""===e?NaN:e?+e:e:n&&es(e)?new Date(e):r?r(e):e;let eN={isValid:!1,value:null};var eL=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,eN):eN;function eq(e){let t=e.ref;return e_(t)?t.files:eE(t)?eL(e.refs).value:ex(t)?[...t.selectedOptions].map(({value:e})=>e):v(t)?ej(e.refs).value:eI(A(t.value)?e.ref.value:t.value,e)}var eR=(e,t,n,r)=>{let i={};for(let n of e){let e=V(t,n);e&&I(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},e$=e=>e instanceof RegExp,eB=e=>A(e)?e:e$(e)?e.source:x(e)?e$(e.value)?e.value.source:e.value:e,eH=e=>({isOnSubmit:!e||e===U,isOnBlur:e===H,isOnChange:e===z,isOnAll:e===Y,isOnTouch:e===W});let ez="AsyncFunction";var eU=e=>!!e&&!!e.validate&&!!(j(e.validate)&&e.validate.constructor.name===ez||x(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===ez)),eW=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),eY=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));let eJ=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=V(e,i);if(n){let{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;else if(e.ref&&t(e.ref,e.name)&&!r)return!0;else if(eJ(o,t))break}else if(x(o)&&eJ(o,t))break}}};function eZ(e,t,n){let r=V(e,n);if(r||F(n))return{error:r,name:n};let i=n.split(".");for(;i.length;){let r=i.join("."),o=V(t,r),a=V(e,r);if(o&&!Array.isArray(o)&&n!==r)break;if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};i.pop()}return{name:n}}var eG=(e,t,n,r)=>{n(e);let{name:i,...o}=e;return eb(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(e=>t[e]===(!r||Y))},eQ=(e,t,n)=>!e||!t||e===t||eg(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),eK=(e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?!r.isOnChange:!i.isOnChange)||e),eX=(e,t)=>!P(V(e,t)).length&&eC(e,t),e0=(e,t,n)=>{let r=eg(V(e,n));return I(r,en,t[n]),I(e,n,r),e};function e1(e,t,n="validate"){if(es(e)||Array.isArray(e)&&e.every(es)||M(e)&&!e)return{type:n,message:es(e)?e:"",ref:t}}var e2=e=>x(e)&&!e$(e)?e:{value:e,message:""},e4=async(e,t,n,r,i,o)=>{let{ref:a,refs:l,required:s,maxLength:u,minLength:c,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:y}=e._f,b=V(n,h);if(!y||t.has(h))return{};let w=l?l[0]:a,E=e=>{i&&w.reportValidity&&(w.setCustomValidity(M(e)?"":e||""),w.reportValidity())},k={},S=eE(a),O=v(a),D=S||O,C=(g||e_(a))&&A(a.value)&&A(b)||ew(a)&&""===a.value||""===b||Array.isArray(b)&&!b.length,F=eh.bind(null,h,r,k),P=(e,t,n,r=G,i=Q)=>{let o=e?t:n;k[h]={type:e?r:i,message:o,ref:a,...F(e?r:i,o)}};if(o?!Array.isArray(b)||!b.length:s&&(!D&&(C||_(b))||M(b)&&!b||O&&!ej(l).isValid||S&&!eL(l).isValid)){let{value:e,message:t}=es(s)?{value:!!s,message:s}:e2(s);if(e&&(k[h]={type:X,message:t,ref:w,...F(X,t)},!r))return E(t),k}if(!C&&(!_(d)||!_(f))){let e,t,n=e2(f),i=e2(d);if(_(b)||isNaN(b)){let r=a.valueAsDate||new Date(b),o=e=>new Date(new Date().toDateString()+" "+e),l="time"==a.type,s="week"==a.type;es(n.value)&&b&&(e=l?o(b)>o(n.value):s?b>n.value:r>new Date(n.value)),es(i.value)&&b&&(t=l?o(b)<o(i.value):s?b<i.value:r<new Date(i.value))}else{let r=a.valueAsNumber||(b?+b:b);_(n.value)||(e=r>n.value),_(i.value)||(t=r<i.value)}if((e||t)&&(P(!!e,n.message,i.message,J,Z),!r))return E(k[h].message),k}if((u||c)&&!C&&(es(b)||o&&Array.isArray(b))){let e=e2(u),t=e2(c),n=!_(e.value)&&b.length>+e.value,i=!_(t.value)&&b.length<+t.value;if((n||i)&&(P(n,e.message,t.message),!r))return E(k[h].message),k}if(p&&!C&&es(b)){let{value:e,message:t}=e2(p);if(e$(e)&&!b.match(e)&&(k[h]={type:K,message:t,ref:a,...F(K,t)},!r))return E(t),k}if(m){if(j(m)){let e=e1(await m(b,n),w);if(e&&(k[h]={...e,...F(ee,e.message)},!r))return E(e.message),k}else if(x(m)){let e={};for(let t in m){if(!eb(e)&&!r)break;let i=e1(await m[t](b,n),w,t);i&&(e={...i,...F(t,i.message)},E(i.message),r&&(k[h]=e))}if(!eb(e)&&(k[h]={ref:w,...e},!r))return k}}return E(!0),k};let e5={mode:U,reValidateMode:z,shouldFocusError:!0};function e3(e={}){let t,n={...e5,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:j(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(x(n.defaultValues)||x(n.values))&&C(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:C(o),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0,c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...c},f={...d},p={array:ey(),state:ey()},m=n.criteriaMode===Y,h=e=>t=>{clearTimeout(u),u=setTimeout(e,t)},g=async e=>{if(!l.keepIsValid&&!n.disabled&&(d.isValid||f.isValid||e)){let e;n.resolver?(e=eb((await H()).errors),y()):e=await W({fields:i,onlyCheckValid:!0,eventType:B}),e!==r.isValid&&p.state.next({isValid:e})}},y=(e,t)=>{!n.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(t?I(r.validatingFields,e,t):eC(r.validatingFields,e))}),p.state.next({validatingFields:r.validatingFields,isValidating:!eb(r.validatingFields)}))},w=(e,t=[],s,u,c=!0,m=!0)=>{if(u&&s&&!n.disabled){if(l.action=!0,m&&Array.isArray(V(i,e))){let t=s(V(i,e),u.argA,u.argB);c&&I(i,e,t)}if(m&&Array.isArray(V(r.errors,e))){let t=s(V(r.errors,e),u.argA,u.argB);c&&I(r.errors,e,t),eX(r.errors,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(V(r.touchedFields,e))){let t=s(V(r.touchedFields,e),u.argA,u.argB);c&&I(r.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=eT(o,a),n=k(e);I(r.dirtyFields,n,V(t,n))}p.state.next({name:e,isDirty:Z(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else I(a,e,t)},O=(e,t)=>{I(r.errors,e,t),p.state.next({errors:r.errors})},F=(e,t,n,r)=>{let s=V(i,e);if(s){let i=V(a,e,A(n)?V(o,e):n);A(i)||r&&r.defaultChecked||t?I(a,e,t?i:eq(s._f)):Q(e,i),l.mount&&!l.action&&g()}},T=(e,t,i,a,l)=>{let s=!1,u=!1,c={name:e};if(!n.disabled){if(!i||a){(d.isDirty||f.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=Z(),s=u!==c.isDirty);let n=ed(V(o,e),t);u=!!V(r.dirtyFields,e),n?eC(r.dirtyFields,e):I(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,s=s||(d.dirtyFields||f.dirtyFields)&&!n!==u}if(i){let t=V(r.touchedFields,e);t||(I(r.touchedFields,e,i),c.touchedFields=r.touchedFields,s=s||(d.touchedFields||f.touchedFields)&&t!==i)}s&&l&&p.state.next(c)}return s?c:{}},q=(e,i,o,a)=>{let l=V(r.errors,e),s=(d.isValid||f.isValid)&&M(i)&&r.isValid!==i;if(n.delayError&&o?(t=h(()=>O(e,o)))(n.delayError):(clearTimeout(u),t=null,o?I(r.errors,e,o):eC(r.errors,e)),(o?!ed(l,o):l)||!eb(a)||s){let t={...a,...s&&M(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},p.state.next(t)}},H=async e=>(y(e,!0),await n.resolver(a,n.context,eR(e||s.mount,i,n.criteriaMode,n.shouldUseNativeValidation))),z=async e=>{let{errors:t}=await H(e);if(y(e),e)for(let n of e){let e=V(t,n);e?I(r.errors,n,e):eC(r.errors,n)}else r.errors=t;return t},U=async({name:t,eventType:n})=>{if(e.validate){let i=await e.validate({formValues:a,formState:r,name:t,eventType:n});if(x(i))for(let e in i)i[e]&&ef(`${et}.${e}`,{message:es(i.message)?i.message:"",type:ee});else es(i)||!i?ef(et,{message:i||"",type:ee}):ec(et);return i}return!0},W=async({fields:t,onlyCheckValid:i,name:o,eventType:l,context:u={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(u.runRootValidation=!0,!await U({name:o,eventType:l}))&&(u.valid=!1,i))return u.valid;for(let o in t){let c=t[o];if(c){let{_f:t,...f}=c;if(t){let o=s.array.has(t.name),l=c._f&&eU(c._f);l&&d.validatingFields&&y([t.name],!0);let f=await e4(c,s.disabled,a,m,n.shouldUseNativeValidation&&!i,o);if(l&&d.validatingFields&&y([t.name]),f[t.name]&&(u.valid=!1,i)||(i||(V(f,t.name)?o?e0(r.errors,f,t.name):I(r.errors,t.name,f[t.name]):eC(r.errors,t.name)),e.shouldUseNativeValidation&&f[t.name]))break}eb(f)||await W({context:u,onlyCheckValid:i,fields:f,name:o,eventType:l})}}return u.valid},J=()=>{for(let e of s.unMount){let t=V(i,e);t&&(t._f.refs?t._f.refs.every(e=>!eS(e)):!eS(t._f.ref))&&eE(e)}s.unMount=new Set},Z=(e,t)=>!n.disabled&&(e&&t&&I(a,e,t),!ed(ea(),o)),G=(e,t,n)=>eu(e,s,{...l.mount?a:A(t)?o:es(e)?{[e]:t}:t},n,t),Q=(e,t,n={})=>{let r=V(i,e),o=t;if(r){let n=r._f;n&&(n.disabled||I(a,e,eI(t,n)),o=ew(n.ref)&&_(t)?"":t,ex(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?v(n.ref)?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):e_(n.ref)?n.ref.value="":(n.ref.value=o,n.ref.type||p.state.next({name:e,values:C(a)})))}(n.shouldDirty||n.shouldTouch)&&T(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&eo(e)},K=(e,t,n)=>{for(let r in t){if(!t.hasOwnProperty(r))return;let o=t[r],a=e+"."+r,l=V(i,a);(s.array.has(e)||x(o)||l&&!l._f)&&!b(o)?K(a,o,n):Q(a,o,n)}},X=(e,t,n={})=>{let u=V(i,e),c=s.array.has(e),m=C(t);I(a,e,m),c?(p.array.next({name:e,values:C(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&n.shouldDirty&&p.state.next({name:e,dirtyFields:eT(o,a),isDirty:Z(e,m)})):!u||u._f||_(m)?Q(e,m,n):K(e,m,n),eY(e,s)?p.state.next({...r,name:e,values:C(a)}):p.state.next({name:l.mount?e:void 0,values:C(a)})},er=async o=>{l.mount=!0;let u=o.target,c=u.name,h=!0,v=V(i,c),_=e=>{h=Number.isNaN(e)||b(e)&&isNaN(e.getTime())||ed(e,V(a,c,e))},w=eH(n.mode),x=eH(n.reValidateMode);if(v){let l,b,k=u.type?eq(v._f):E(o),S=o.type===N||o.type===L,O=!eW(v._f)&&!e.validate&&!n.resolver&&!V(r.errors,c)&&!v._f.deps||eK(S,V(r.touchedFields,c),r.isSubmitted,x,w),D=eY(c,s,S);I(a,c,k),S?u&&u.readOnly||(v._f.onBlur&&v._f.onBlur(o),t&&t(0)):v._f.onChange&&v._f.onChange(o);let F=T(c,k,S),A=!eb(F)||D;if(S||p.state.next({name:c,type:o.type,values:C(a)}),O)return(d.isValid||f.isValid)&&("onBlur"===n.mode?S&&g():S||g()),A&&p.state.next({name:c,...D?{}:F});if(!n.resolver&&e.validate&&await U({name:c,eventType:o.type}),!S&&D&&p.state.next({...r}),n.resolver){let{errors:e}=await H([c]);if(y([c]),_(k),h){let t=eZ(r.errors,i,c),n=eZ(e,i,t.name||c);l=n.error,c=n.name,b=eb(e)}}else y([c],!0),l=(await e4(v,s.disabled,a,m,n.shouldUseNativeValidation))[c],y([c]),_(k),h&&(l?b=!1:(d.isValid||f.isValid)&&(b=await W({fields:i,onlyCheckValid:!0,name:c,eventType:o.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&eo(v._f.deps),q(c,b,l,F))}},ei=(e,t)=>{if(V(r.errors,t)&&e.focus)return e.focus(),1},eo=async(e,t={})=>{let o,a,l=eg(e);if(n.resolver){let t=await z(A(e)?e:l);o=eb(t),a=e?!l.some(e=>V(t,e)):o}else e?((a=(await Promise.all(l.map(async e=>{let t=V(i,e);return await W({fields:t&&t._f?{[e]:t}:t,eventType:$})}))).every(Boolean))||r.isValid)&&g():a=o=await W({fields:i,name:e,eventType:$});return p.state.next({...!es(e)||(d.isValid||f.isValid)&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&eJ(i,ei,e?l:s.mount),a},ea=(e,t)=>{let n={...l.mount?a:o};return t&&(n=ev(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),A(e)?n:es(e)?V(n,e):e.map(e=>V(n,e))},el=(e,t)=>({invalid:!!V((t||r).errors,e),isDirty:!!V((t||r).dirtyFields,e),error:V((t||r).errors,e),isValidating:!!V(r.validatingFields,e),isTouched:!!V((t||r).touchedFields,e)}),ec=e=>{let t=e?eg(e):void 0;null==t||t.forEach(e=>eC(r.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:r.errors})}):p.state.next({errors:{}})},ef=(e,t,n)=>{let o=(V(i,e,{_f:{}})._f||{}).ref,{ref:a,message:l,type:s,...u}=V(r.errors,e)||{};I(r.errors,e,{...u,...t,ref:o}),p.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},ep=(e,t)=>j(e)?p.state.subscribe({next:n=>"values"in n&&e(G(void 0,t),n)}):G(e,t,!0),em=e=>p.state.subscribe({next:t=>{eQ(e.name,t.name,e.exact)&&eG(t,e.formState||d,eN,e.reRenderRoot)&&e.callback({values:{...a},...r,...t,defaultValues:o})}}).unsubscribe,eh=e=>(l.mount=!0,f={...f,...e.formState},em({...e,formState:{...c,...e.formState}})),eE=(e,t={})=>{for(let l of e?eg(e):s.mount)s.mount.delete(l),s.array.delete(l),t.keepValue||(eC(i,l),eC(a,l)),t.keepError||eC(r.errors,l),t.keepDirty||eC(r.dirtyFields,l),t.keepTouched||eC(r.touchedFields,l),t.keepIsValidating||eC(r.validatingFields,l),n.shouldUnregister||t.keepDefaultValue||eC(o,l);p.state.next({values:C(a)}),p.state.next({...r,...!t.keepDirty?{}:{isDirty:Z()}}),t.keepIsValid||g()},eO=({disabled:e,name:t})=>{if(M(e)&&l.mount||e||s.disabled.has(t)){let n=!!e!==s.disabled.has(t);e?s.disabled.add(t):s.disabled.delete(t),n&&l.mount&&!l.action&&g()}},eD=(e,t={})=>{let r=V(i,e),a=M(t.disabled)||M(n.disabled);return I(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),s.mount.add(e),r?eO({disabled:M(t.disabled)?t.disabled:n.disabled,name:e}):F(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:eB(t.min),max:eB(t.max),minLength:eB(t.minLength),maxLength:eB(t.maxLength),pattern:eB(t.pattern)}:{},name:e,onChange:er,onBlur:er,ref:a=>{if(a){eD(e,t),r=V(i,e);let n=A(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,l=ek(n),s=r._f.refs||[];(l?s.find(e=>e===n):n===r._f.ref)||(I(i,e,{_f:{...r._f,...l?{refs:[...s.filter(eS),n,...Array.isArray(V(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),F(e,!1,void 0,n))}else(r=V(i,e,{}))._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&!(S(s.array,e)&&l.action)&&s.unMount.add(e)}}},eF=()=>n.shouldFocusError&&eJ(i,ei,s.mount),eA=(e,t)=>async o=>{let l;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let u=C(a);if(p.state.next({isSubmitting:!0}),n.resolver){let{errors:e,values:t}=await H();y(),r.errors=e,u=C(t)}else await W({fields:i,eventType:R});if(s.disabled.size)for(let e of s.disabled)eC(u,e);if(eC(r.errors,en),eb(r.errors)){p.state.next({errors:{}});try{await e(u,o)}catch(e){l=e}}else t&&await t({...r.errors},o),eF(),setTimeout(eF);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:eb(r.errors)&&!l,submitCount:r.submitCount+1,errors:r.errors}),l)throw l},eP=(e,t={})=>{V(i,e)&&(A(t.defaultValue)?X(e,C(V(o,e))):(X(e,t.defaultValue),I(o,e,C(t.defaultValue))),t.keepTouched||eC(r.touchedFields,e),t.keepDirty||(eC(r.dirtyFields,e),r.isDirty=t.defaultValue?Z(e,C(V(o,e))):Z()),!t.keepError&&(eC(r.errors,e),d.isValid&&g()),p.state.next({...r}))},eV=(e,t={})=>{let u=e?C(e):o,c=C(u),f=eb(e),m=f?o:c;if(t.keepDefaultValues||(o=u),!t.keepValues){if(t.keepDirtyValues)for(let e of Array.from(new Set([...s.mount,...Object.keys(eT(o,a))]))){let t=V(r.dirtyFields,e),n=V(a,e),i=V(m,e);t&&!A(n)?I(m,e,n):t||A(i)||X(e,i)}else{if(D&&A(e))for(let e of s.mount){let t=V(i,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(ew(e)){let t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(let e of s.mount)X(e,V(m,e));else i={}}a=n.shouldUnregister?t.keepDefaultValues?C(o):{}:C(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:t.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!eb(m),l.watch=!!n.shouldUnregister,l.keepIsValid=!!t.keepIsValid,l.action=!1,t.keepErrors||(r.errors={}),p.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!f&&(t.keepDirty?r.isDirty:!!(t.keepDefaultValues&&!ed(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:f?{}:t.keepDirtyValues?t.keepDefaultValues&&a?eT(o,a):r.dirtyFields:t.keepDefaultValues&&e?eT(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:o})},eM=(e,t)=>eV(j(e)?e(a):e,{...n.resetOptions,...t}),ej=(e,t={})=>{let n=V(i,e),r=n&&n._f;if(r){let e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&j(e.select)&&e.select()})}},eN=e=>{r={...r,...e}},eL={control:{register:eD,unregister:eE,getFieldState:el,handleSubmit:eA,setError:ef,_subscribe:em,_runSchema:H,_updateIsValidating:y,_focusError:eF,_getWatch:G,_getDirty:Z,_setValid:g,_setFieldArray:w,_setDisabledField:eO,_setErrors:e=>{r.errors=e,p.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>P(V(l.mount?a:o,e,n.shouldUnregister?V(o,e,[]):[])),_reset:eV,_resetDefaultValues:()=>j(n.defaultValues)&&n.defaultValues().then(e=>{eM(e,n.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:e=>{M(e)&&(p.state.next({disabled:e}),eJ(i,(t,n)=>{let r=V(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:p,_proxyFormState:d,get _fields(){return i},get _formValues(){return a},get _state(){return l},set _state(value){l=value},get _defaultValues(){return o},get _names(){return s},set _names(value){s=value},get _formState(){return r},get _options(){return n},set _options(value){n={...n,...value}}},subscribe:eh,trigger:eo,register:eD,handleSubmit:eA,watch:ep,setValue:X,getValues:ea,reset:eM,resetField:eP,clearErrors:ec,unregister:eE,setError:ef,setFocus:ej,getFieldState:el};return{...eL,formControl:eL}}function e6(e={}){let t=f().useRef(void 0),n=f().useRef(void 0),[r,i]=f().useState({isDirty:!1,isValidating:!1,isLoading:j(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:j(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!j(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=e3(e);t.current={...i,formState:r}}let o=t.current.control;return o._options=e,ea(()=>{let e=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),f().useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),f().useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),f().useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),f().useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),f().useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}},[o,r.isDirty]),f().useEffect(()=>{var t;e.values&&!ed(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null==(t=o._options.resetOptions)?void 0:t.keepIsValid)||o._setValid(),n.current=e.values,i(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),f().useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=f().useMemo(()=>eo(r,o),[o,r]),t.current}var e9=n(7807);let e7=(0,d.createContext)(null),e8={didCatch:!1,error:null};class te extends d.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=e8}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=Array(r),o=0;o<r;o++)i[o]=arguments[o];null==(t=(n=this.props).onReset)||t.call(n,{args:i,reason:"imperative-api"}),this.setState(e8)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&tt(e.resetKeys,r)){var i,o;null==(i=(o=this.props).onReset)||i.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(e8)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:o}=this.state,a=e;if(i){let e={error:o,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=(0,d.createElement)(n,e);else if(null===r||(0,d.isValidElement)(r))a=r;else throw o}return(0,d.createElement)(e7.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},a)}}function tt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var tn=n(222),tr=n.n(tn);let ti="field.required",to="field.outOfBound",ta={validate:(e,t)=>{if(e.meta?.submission?.unspecified)return[];if(ts(t)&&e.isRequired){if("object"==typeof e.required&&"conditionalRequired"===e.required.type&&e.isRequired)return tc(ti,e.required.message??"Field is mandatory");else if(e.isRequired)return tc(ti,"Field is mandatory")}if("text"===e.questionOptions.rendering)return tu(e.questionOptions.minLength,e.questionOptions.maxLength,t?.length)??[];if("number"===e.questionOptions.rendering){let n=Number(e.questionOptions.min),r=Number(e.questionOptions.max),i=e.questionOptions.disallowDecimals||e.meta?.concept?.allowDecimal;if(ts(t))return[];if(i&&!Number.isInteger(t))return tc(to,"Decimal values are not allowed for this field");if(!Number.isNaN(n)||!Number.isNaN(r))return tl(n,r,t)}return[]}};function tl(e,t,n){return!Number.isNaN(e)&&n<e?tc(to,`Value must be greater than ${e}`):!Number.isNaN(t)&&n>t?tc(to,`Value must be lower than ${t}`):[]}function ts(e){return!!(null==e||""===e||"string"==typeof e&&!e?.trim()||Array.isArray(e)&&!e.length)}function tu(e,t,n){let r=Number(e),i=Number(t);if("number"==typeof n&&!Number.isNaN(n)){if(r&&i&&n>=r&&n<=i)return[];if(r&&n<r)return tc(to,`Length should be at least ${r} characters`);if(i&&n>i)return tc(to,`Length should not exceed ${i} characters`);if(i&&r&&n<r&&n>i)return tc(to,`Length should be between ${r} and ${i} characters`)}}function tc(e,t){return[{resultType:"error",errCode:e,message:t}]}function td(e){let t=[];function n(e){t.push(e),e.groupMembers?.length&&e.groupMembers.forEach(e=>{n(e)})}return e.forEach(e=>{n(e)}),t}function tf(e,t){return e.questionOptions.rendering===t}function tp(e){e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),e.meta.submission={...e.meta.submission,voidedValue:null,newValue:null}}function tm(e,t,n){return e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),ts(t)||(e.meta.submission.newValue=t),ts(n)||(e.meta.submission.voidedValue=n),e.meta.submission.newValue}function th(e){return!!e.meta.submission?.newValue||!!e.meta.submission?.voidedValue}function tg(e){return"view"===e||"embedded-view"===e}function ty(e){let t=tr()(e).toDate();if(isNaN(t.getTime()))return new Date(NaN);try{let n=e.split("T")[1];if(n){let e=n.split(":");t.setHours(parseInt(e[0]),parseInt(e[1]),0)}}catch(e){console.error(e)}return t}function tv(e,t){if(!t)return e;let n=t.startDatetime?new Date(t.startDatetime):null,r=t.stopDatetime?new Date(t.stopDatetime):null;return n&&e<n||r&&e>r?n??r:e}function tb(e,t){let n={noToday:!0};return"calendar"===e.datePickerFormat?n.time=!1:n.time=!0,(0,u.formatDate)(t,n)}function t_(e){return e.pages=e.pages.map(e=>(e.sections=Array.from(e.sections),e)),{...e}}function tw(e,t=16){return e/t}var tx=n(5992),tE=n(1630),tk=n.n(tE),tS=n(2154),tO=n.n(tS),tD=n(7581),tC=n.n(tD),tF=n(7289),tA=n.n(tF),tP=n(3657),tT=n.n(tP),tV=n(8087),tM=n.n(tV),tj=n(9908);let tI={wflFemaleBelow5:()=>n.e("4926").then(n.t.bind(n,877,19)),wflMaleBelow5:()=>n.e("908").then(n.t.bind(n,4775,19)),hfaFemaleBelow5:()=>n.e("212").then(n.t.bind(n,6095,19)),hfaMaleBelow5:()=>n.e("4958").then(n.t.bind(n,5501,19)),hfaFemale5Above:()=>n.e("1229").then(n.t.bind(n,8844,19)),hfaMale5Above:()=>n.e("383").then(n.t.bind(n,7890,19)),bfaFemale5Above:()=>n.e("9899").then(n.t.bind(n,5878,19)),bfaMale5Above:()=>n.e("8577").then(n.t.bind(n,6008,19))},tN={calcWeightForHeightZscore:["wflFemaleBelow5","wflMaleBelow5"],calcHeightForAgeZscore:["hfaFemaleBelow5","hfaMaleBelow5","hfaFemale5Above","hfaMale5Above"],calcBMIForAgeZscore:["bfaFemale5Above","bfaMale5Above"]},tL=new Map;async function tq(e){let t=JSON.stringify(e??{}),n=Object.entries(tN).filter(([e])=>t.includes(e)).flatMap(([,e])=>e).filter(e=>!tL.has(e)),r=(await Promise.allSettled(n.map(async e=>{let t=await tI[e]();tL.set(e,t.default)}))).find(e=>"rejected"===e.status);if(r)throw r.reason}function tR(e){let t=tL.get(e);return t||console.warn(`Z-score calculation: the ${e} reference table hasn't been loaded`),t}function t$(e,t,n){let r=tU(t,n,"years");return"F"===e&&r<5?tR("wflFemaleBelow5"):"M"===e&&r<5?tR("wflMaleBelow5"):null}function tB(e,t,n){let r=tU(t,n,"years"),i=tU(t,n,"months"),o=tU(t,n,"days");if("F"===e){if(r<5)return tz(tR("hfaFemaleBelow5"),"Day",o);if(r>=5&&r<18)return tz(tR("hfaFemale5Above"),"Month",i)}if("M"===e){if(r<5)return tz(tR("hfaMaleBelow5"),"Day",o);if(r>=5&&r<18)return tz(tR("hfaMale5Above"),"Month",i)}return null}function tH(e,t,n){let r=tU(t,n,"years"),i=tU(t,n,"months");return"F"===e&&r>=5&&r<18?tz(tR("bfaFemale5Above"),"Month",i):"M"===e&&r>=5&&r<18?tz(tR("bfaMale5Above"),"Month",i):null}function tz(e,t,n){return tC()(e,e=>e[t]===n)}function tU(e,t,n){if(e&&t&&n){let r=tr()(t),i=tr()(e);return r.diff(i,n)}return null}function tW(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}tr().extend(tk());class tY{constructor(e,t,n,r){tW(this,"node",null),tW(this,"patient",null),tW(this,"allFields",[]),tW(this,"allFieldValues",{}),tW(this,"api",tj),tW(this,"isEmpty",ts),tW(this,"dayjs",tr()),tW(this,"calculateZScoreFromRef",(e,t)=>{if(!e)return console.warn("Z-score calculation: No reference data object provided"),null;let n=Object.keys(e),r=n.map(t=>e[t]),i=r[1],o=[];t<i?o.push(i):tT()(r,e=>{e<=t&&o.push(e)});let a=tM()(o),l=n[tO()(r,e=>e===a)],s=l?.replace("SD","");return s?.includes("neg")&&(s="-"+s.substring(0,1)),("S"===s||"L"===s||"M"===s||"-5"===s)&&(s="-4"),s??null}),tW(this,"today",()=>new Date),tW(this,"includes",(e,t)=>e?.includes(t)),tW(this,"isDateBefore",(e,t,n)=>{let r=t instanceof Date?t:n?tr()(t,n,!0).toDate():tr()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()<r.getTime()}),tW(this,"isDateAfter",(e,t,n,r)=>{let i,o=tr()(t);switch(r){case"months":i=o.add(n,"month").toDate();break;case"weeks":i=o.add(n,"week").toDate();break;case"days":i=o.add(n,"day").toDate();break;case"years":i=o.add(n,"year").toDate();break;default:i=new Date(0)}return e.getTime()>=i.getTime()}),tW(this,"addWeeksToDate",(e,t)=>tr()(e).add(t,"week").toDate()),tW(this,"addDaysToDate",(e,t)=>tr()(e).add(t,"day").toDate()),tW(this,"isDateAfterSimple",(e,t,n)=>{let r=t instanceof Date?t:n?tr()(t,n,!0).toDate():tr()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()>r.getTime()}),tW(this,"useFieldValue",e=>{let t=this.allFields.find(t=>t.id===e);return t&&tZ(this.node,t),this.allFieldValues[e]??null}),tW(this,"doesNotMatchExpression",(e,t)=>!!(!t||["undefined","null",""].includes(t.toString()))||!new RegExp(e).test(t)),tW(this,"calcBMI",(e,t)=>{if(!e||!t)return null;let n=e/100;return parseFloat((t/(n*n)).toFixed(1))}),tW(this,"calcEDD",e=>e?new Date(e.getTime()+24192e6):null),tW(this,"calcMonthsOnART",e=>{if(null==e)return null;if(!(e instanceof Date))throw Error("DateFormatException: value passed is not a valid date");let t=new Date;return 30>Math.round((t.getTime()-e.getTime())/864e5)?0:tr()(t).diff(e,"month")}),tW(this,"calcViralLoadStatus",e=>{let t;return e&&(t=e>50?"a6768be6-c08e-464d-8f53-5f4229508e54":"5d5e42cc-acc4-4069-b3a8-7163e0db5d96"),t??null}),tW(this,"calcNextVisitDate",(e,t)=>e&&t?new Date(e.getTime()+24*t*36e5):null),tW(this,"calcTreatmentEndDate",(e,t,n)=>{if(!e||!t||"160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"!==n)return null;let r=30+t;return new Date(e.getTime()+24*r*36e5)}),tW(this,"calcAgeBasedOnDate",e=>(e?new Date(e).getFullYear():new Date().getFullYear())-new Date(this.patient.birthDate).getFullYear()),tW(this,"calcBSA",(e,t)=>e&&t?parseFloat(Math.sqrt(e*t/3600).toFixed(2)):null),tW(this,"arrayContains",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1===e.indexOf(n))return!1;return!0}),tW(this,"arrayContainsAny",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1!==e.indexOf(n))return!0;return!1}),tW(this,"parseDate",e=>(0,u.parseDate)(e)),tW(this,"formatDate",(e,t)=>{if(!(e instanceof Date)&&isNaN((e=new Date(e)).getTime()))throw Error("DateFormatException: value passed is not a valid date");return t?tr()(e).format(t):(0,u.formatDate)(e)}),tW(this,"extractRepeatingGroupValues",(e,t)=>t.map(function(t){return t[e]})),tW(this,"calcGravida",(e,t)=>{let n="number"==typeof e?e:parseInt(e,10),r="number"==typeof t?t:parseInt(t,10);if(!Number.isInteger(n)||!Number.isInteger(r))throw Error("Both inputs must be valid numbers.");return n+r}),tW(this,"calcWeightForHeightZscore",(e,t)=>{if(!e||!t)return null;let n=new Date(this.patient.birthDate),r=t$(this.patient.sex,n,new Date);if(!r)return null;let i=110;if(e<45||e>i)return null;let o=e.toFixed(1),a=tC()(r,e=>parseFloat(e.Length).toFixed(1)===o),l=tA()(a);return this.calculateZScoreFromRef(l,t)}),tW(this,"calcBMIForAgeZscore",(e,t)=>{if(!e||!t)return null;let n=new Date(this.patient.birthDate),r=tH(this.patient.sex,n,new Date),i=e/100,o=parseFloat((t/(i*i)).toFixed(1)),a=tA()(r);return this.calculateZScoreFromRef(a,o)}),tW(this,"calcHeightForAgeZscore",(e,t)=>{if(!e)return null;let n=new Date(this.patient.birthDate),r=tB(this.patient.sex,n,new Date),i=tA()(r);return this.calculateZScoreFromRef(i,e)}),tW(this,"calcTimeDifference",(e,t)=>{if(!e)return 0;let n=tr()();switch(t){case"d":return Math.abs(Math.round(n.diff(e,"day",!0)));case"w":return Math.abs(Math.round(n.diff(e,"week",!0)));case"m":return Math.abs(Math.round(n.diff(e,"month",!0)));case"y":return Math.abs(Math.round(n.diff(e,"year",!0)))}}),tW(this,"resolve",e=>Promise.resolve(e)),this.allFields=n,this.allFieldValues=r,this.node=e,this.patient=t}}function tJ(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function tZ(e,t){if(e&&t)switch(e.type){case"page":t.pageDependents||(t.pageDependents=new Set),t.pageDependents.add(e.value.label);break;case"section":t.sectionDependents||(t.sectionDependents=new Set),t.sectionDependents.add(e.value.label);break;default:t.fieldDependents||(t.fieldDependents=new Set),t.fieldDependents.add(e.value.id)}}function tG(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class tQ{putObject(e,t){this.dataSourceMap[e]=t}getObject(e){return this.dataSourceMap[e]}constructor(){tG(this,"dataSourceMap",{})}}let tK=new Map;function tX(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||"object"==typeof e||null==e}function t0(e,t,n,r,i){if(!e?.trim())return null;let o=t4(e);t5(o,t,n);try{return(0,u.evaluateAsType)(o,t2(t,n,r,i),tX)}catch(t){console.error(`Error: ${t}
|
|
1
|
+
(globalThis.webpackChunk_openmrs_esm_form_engine_app=globalThis.webpackChunk_openmrs_esm_form_engine_app||[]).push([["401"],{9908(e,t,n){"use strict";n.r(t),n.d(t,{createAttachment:()=>l,fetchClobData:()=>h,fetchOpenMRSForm:()=>m,getAllLocations:()=>c,getConcept:()=>s,getLatestObs:()=>f,getLatestObsForConceptSet:()=>p,getLocationsByTag:()=>u,getPatientEnrolledPrograms:()=>g,getPreviousEncounter:()=>d,markPatientAsDeceased:()=>_,saveEncounter:()=>a,savePatientIdentifier:()=>v,savePersonAttribute:()=>b,saveProgramEnrollment:()=>y});var r=n(2664),i=n(498),o=n(1809);function a(e,t,n){let o=n?`${r.restBaseUrl}/encounter/${n}?v=${i.RZ}`:`${r.restBaseUrl}/encounter?v=${i.RZ}`;return(0,r.openmrsFetch)(o,{headers:{"Content-Type":"application/json"},method:"POST",body:t,signal:e.signal})}async function l(e,t,n){let i=new FormData;return i.append("fileCaption",n.fileDescription),i.append("patient",e),n.file?i.append("file",n.file,n.fileName):(i.append("file",new File([""],n.fileName),n.fileName),i.append("base64Content",n.base64Content)),i.append("encounter",t),i.append("formFieldNamespace",n.formFieldNamespace),i.append("formFieldPath",n.formFieldPath),(0,r.openmrsFetch)(`${r.attachmentUrl}`,{method:"POST",body:i})}function s(e,t){return(0,r.openmrsFetch)(`${r.restBaseUrl}/concept/${e}?v=${t}`).then(({data:e})=>e.results)}function u(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?tag=${e}&v=custom:(uuid,display)`).then(({data:e})=>e.results)}function c(){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?v=custom:(uuid,display)`).then(({data:e})=>e.results)}async function d(e,t){let n=`patient=${e}&_sort=-date&_count=1&type=${t}`,o=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Encounter?${n}`);if(o?.data?.entry?.length){let e=o.data.entry[0].resource.id;return(o=await (0,r.openmrsFetch)(`${r.restBaseUrl}/encounter/${e}?v=${i.RZ}`)).data}return null}async function f(e,t,n){let i=`patient=${e}&code=${t}${n?`&encounter.type=${n}`:""}`;i+="&_sort=-date&_count=1";let{data:o}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${i}`);return o.entry?.length?o.entry[0].resource:null}async function p(e,t,n){let i=await f(e,t,n);if(!i)return[];let o=i.encounter?.reference?.split("/").pop();if(!o)return[i];let a=`patient=${e}&code=${t}&encounter=${o}`,{data:l}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${a}`);return l.entry?.map(e=>e.resource)??[]}async function m(e){if(!e)return null;let{url:t,isUUID:n}=(0,o.O)(e)?{url:`${r.restBaseUrl}/form/${e}?v=full`,isUUID:!0}:{url:`${r.restBaseUrl}/form?q=${e}&v=full`,isUUID:!1},{data:i}=await (0,r.openmrsFetch)(t);if(n)return i;if(i.results?.length){let e=i.results.find(e=>!1===e.retired);if(e)return e}throw Error(`Form with ID "${e}" was not found`)}async function h(e){if(!e)return null;let t=e.resources?.find(({name:e})=>"JSON schema"===e);if(!t)return null;let n=`${r.restBaseUrl}/clobdata/${t.valueReference}`,{data:i}=await (0,r.openmrsFetch)(n);return i}function g(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(state:(uuid,name,concept:(uuid),programWorkflow:(uuid)))`).then(({data:e})=>e||null)}function y(e,t){if(!e)throw Error("Program enrollment cannot be created because no payload is supplied");let n=e.uuid?`${r.restBaseUrl}/programenrollment/${e.uuid}`:`${r.restBaseUrl}/programenrollment`;return(0,r.openmrsFetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e,signal:t.signal})}function v(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/patient/${t}/identifier/${e.uuid}`:`${r.restBaseUrl}/patient/${t}/identifier`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)})}function b(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/person/${t}/attribute/${e.uuid}`:`${r.restBaseUrl}/person/${t}/attribute`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:e})}function _(e,t,n,i){if(!n)throw Error(e("patientCannotBeMarkedAsDeceasedBecauseNoPayloadSupplied","Patient cannot be marked as deceased because no payload is supplied"));let o=`${r.restBaseUrl}/person/${t}`;return(0,r.openmrsFetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:n,signal:i.signal})}},498(e,t,n){"use strict";n.d(t,{FU:()=>l,Mi:()=>i,RA:()=>a,RZ:()=>o,ZA:()=>s,t$:()=>r});let r="cf82933b-3f3f-45e7-a5ab-5d31aaee3da3",i="488b58ff-64f5-4f8a-8979-fa79940b1594",o="custom:(uuid,encounterDatetime,encounterType:(uuid,name,description),location:(uuid,name),patient:(uuid,display),encounterProviders:(uuid,provider:(uuid,name),encounterRole:(uuid,name)),orders:(uuid,display,concept:(uuid,display),voided),diagnoses:(uuid,certainty,condition,formFieldPath,formFieldNamespace,display,rank,voided,diagnosis:(coded:(uuid,display))),obs:(uuid,obsDatetime,comment,voided,groupMembers,formFieldNamespace,formFieldPath,concept:(uuid,name:(uuid,name)),value:(uuid,name:(uuid,name),names:(uuid,conceptNameType,name))))",a="forms-engine-store",l=["radio","checkbox","select","content-switcher"],s="OPTION_NULL"},1807(e,t,n){"use strict";n.d(t,{L:()=>r});let r="@openmrs/esm-form-engine-app"},7512(e,t,n){"use strict";n.d(t,{yh:()=>dE,y6:()=>dM,Im:()=>ts,Tn:()=>pG});var r,i={};n.r(i),n.d(i,{boolean:()=>rm,booleanish:()=>rh,commaOrSpaceSeparated:()=>r_,commaSeparated:()=>rb,number:()=>ry,overloadedBoolean:()=>rg,spaceSeparated:()=>rv});var o={};function a(e,t,n){if(!e)return t;let r=JSON.parse(JSON.stringify(t));return r.defaultPage=r.availableIntents?.find(t=>t.intent===(e?.intent||e))?.defaultPage,r.markdown&&s(r.markdown,e),r.pages=r.pages||[],r.pages.forEach(t=>{if(t.isSubform&&t.subform?.form){let n=[],r=t.subform.behaviours?.find(t=>t.intent==e?.intent||e);(r?.readonly!==void 0||r?.readonly!=null)&&n.push({name:"readonly",type:"field",value:r?.readonly}),t.subform.form=a(r?.subform_intent||"*",t.subform?.form,n)}let r=t.behaviours?.find(t=>t.intent===(e?.intent||e));if(r)t.hide=r.hide??t.hide,t.readonly=r.readonly??t.readonly;else{let e=t.behaviours?.find(e=>"*"===e.intent);e&&(t.hide=e.hide??t.hide,t.readonly=e.readonly??t.readonly)}t.markdown&&s(t.markdown,e),t.sections=t.sections||[],t.sections.forEach(t=>{let r=t.behaviours?.find(t=>t.intent===e?.intent||e);if(r)t.hide=r.hide??t.hide;else{let e=t.behaviours?.find(e=>"*"===e.intent);t.hide=e?.hide??t.hide}t.markdown&&s(t.markdown,e),t.questions=t.questions||[],t.questions.forEach(t=>{t.behaviours&&(l(t,e?.intent||e),n?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(e=>{t[e.name]=e.value})),t.questions&&t.questions.length&&t.questions.forEach(t=>{l(t,e?.intent||e),n?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(e=>{t[e.name]=e.value})})})})}),r}function l(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);if(n||r){delete n?.intent,delete r?.intent;let t=Object.assign(r||{},n||{}),i=t.defaultValue;void 0!=i&&(e.questionOptions.defaultValue=i,delete t.defaultValue),e=Object.assign(e,t),delete e.behaviours}}function s(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);n&&r?(delete n.intent,delete r.intent,e=Object.assign(e,Object.assign(r,n)),delete e.behaviours):!n&&r&&(delete r.intent,e=Object.assign(e,r),delete e.behaviours)}n.r(o),n.d(o,{attentionMarkers:()=>aM,contentInitial:()=>aC,disable:()=>aj,document:()=>aD,flow:()=>aA,flowInitial:()=>aF,insideSpan:()=>aV,string:()=>aP,text:()=>aT}),n(2722);var u=n(2664),c=n(498),d=n(5399),f=n.n(d),p=n(3373),m=n.n(p);let h={flexColumn:"-esm-form-engine__obs-group__flexColumn___Rm5Li",flexFullWidth:"-esm-form-engine__obs-group__flexFullWidth___Zd-wp",groupContainer:"-esm-form-engine__obs-group__groupContainer___DYseT",boldLegend:"-esm-form-engine__obs-group__boldLegend___ycIBQ"};var g=n(7685),y=n(324),v=e=>"checkbox"===e.type,b=e=>e instanceof Date,_=e=>null==e;let w=e=>"object"==typeof e;var x=e=>!_(e)&&!Array.isArray(e)&&w(e)&&!b(e),E=e=>x(e)&&e.target?v(e.target)?e.target.checked:e.target.value:e,k=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,S=(e,t)=>e.has(k(t)),O=e=>{let t=e.constructor&&e.constructor.prototype;return x(t)&&t.hasOwnProperty("isPrototypeOf")},D="u">typeof window&&void 0!==window.HTMLElement&&"u">typeof document;function C(e){if(e instanceof Date)return new Date(e);let t="u">typeof FileList&&e instanceof FileList;if(D&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(x(e)&&O(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=C(e[t]));return r}var F=e=>/^\w*$/.test(e),A=e=>void 0===e,P=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>P(e.replace(/["|']|\]/g,"").split(/\.|\[/)),V=(e,t,n)=>{if(!t||!x(e))return n;let r=(F(t)?[t]:T(t)).reduce((e,t)=>_(e)?e:e[t],e);return A(r)||r===e?A(e[t])?n:e[t]:r},M=e=>"boolean"==typeof e,j=e=>"function"==typeof e,I=(e,t,n)=>{let r=-1,i=F(t)?[t]:T(t),o=i.length,a=o-1;for(;++r<o;){let t=i[r],o=n;if(r!==a){let n=e[t];o=x(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}};let N="blur",L="focusout",q="change",R="submit",$="trigger",B="valid",H="onBlur",z="onChange",U="onSubmit",W="onTouched",Y="all",J="max",Z="min",G="maxLength",Q="minLength",K="pattern",X="required",ee="validate",et="form",en="root",er=f().createContext(null);er.displayName="HookFormControlContext";let ei=()=>f().useContext(er);var eo=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let o in e)Object.defineProperty(i,o,{get:()=>{let i=o;return t._proxyFormState[i]!==Y&&(t._proxyFormState[i]=!r||Y),n&&(n[i]=!0),e[i]}});return i};let ea="u">typeof window?f().useLayoutEffect:f().useEffect;function el(e){let t=ei(),{control:n=t,disabled:r,name:i,exact:o}=e||{},[a,l]=f().useState(n._formState),s=f().useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return ea(()=>n._subscribe({name:i,formState:s.current,exact:o,callback:e=>{r||l({...n._formState,...e})}}),[i,r,o]),f().useEffect(()=>{s.current.isValid&&n._setValid(!0)},[n]),f().useMemo(()=>eo(a,n,s.current,!1),[a,n])}var es=e=>"string"==typeof e,eu=(e,t,n,r,i)=>es(e)?(r&&t.watch.add(e),V(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),V(n,e))):(r&&(t.watchAll=!0),n),ec=e=>_(e)||!w(e);function ed(e,t,n=new WeakSet){if(ec(e)||ec(t))return Object.is(e,t);if(b(e)&&b(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;for(let o of(n.add(e),n.add(t),r)){let r=e[o];if(!i.includes(o))return!1;if("ref"!==o){let e=t[o];if(b(r)&&b(e)||x(r)&&x(e)||Array.isArray(r)&&Array.isArray(e)?!ed(r,e,n):!Object.is(r,e))return!1}}return!0}function ef(e){let t=ei(),{control:n=t,name:r,defaultValue:i,disabled:o,exact:a,compute:l}=e||{},s=f().useRef(i),u=f().useRef(l),c=f().useRef(void 0),d=f().useRef(n),p=f().useRef(r);u.current=l;let[m,h]=f().useState(()=>{let e=n._getWatch(r,s.current);return u.current?u.current(e):e}),g=f().useCallback(e=>{let t=eu(r,n._names,e||n._formValues,!1,s.current);return u.current?u.current(t):t},[n._formValues,n._names,r]),y=f().useCallback(e=>{if(!o){let t=eu(r,n._names,e||n._formValues,!1,s.current);if(u.current){let e=u.current(t);ed(e,c.current)||(h(e),c.current=e)}else h(t)}},[n._formValues,n._names,o,r]);ea(()=>(d.current===n&&ed(p.current,r)||(d.current=n,p.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:e=>{y(e.values)}})),[n,a,r,y]),f().useEffect(()=>n._removeUnmounted());let v=d.current!==n,b=p.current,_=f().useMemo(()=>{if(o)return null;let e=!v&&!ed(b,r);return v||e?g():null},[o,v,r,b,g]);return null!==_?_:m}function ep(e){let t=ei(),{name:n,disabled:r,control:i=t,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,s=S(i._names.array,n),u=f().useMemo(()=>V(i._formValues,n,V(i._defaultValues,n,a)),[i,n,a]),c=ef({control:i,name:n,defaultValue:u,exact:l}),d=el({control:i,name:n,exact:l}),p=f().useRef(e),m=f().useRef(void 0),h=f().useRef(i.register(n,{...e.rules,value:c,...M(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;let g=f().useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!V(d.errors,n)},isDirty:{enumerable:!0,get:()=>!!V(d.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!V(d.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!V(d.validatingFields,n)},error:{enumerable:!0,get:()=>V(d.errors,n)}}),[d,n]),y=f().useCallback(e=>h.current.onChange({target:{value:E(e),name:n},type:q}),[n]),v=f().useCallback(()=>h.current.onBlur({target:{value:V(i._formValues,n),name:n},type:N}),[n,i._formValues]),b=f().useCallback(e=>{let t=V(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>j(e.focus)&&e.focus(),select:()=>j(e.select)&&e.select(),setCustomValidity:t=>j(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>j(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),_=f().useMemo(()=>({name:n,value:c,...M(r)||d.disabled?{disabled:d.disabled||r}:{},onChange:y,onBlur:v,ref:b}),[n,r,d.disabled,y,v,b,c]);return f().useEffect(()=>{let e=i._options.shouldUnregister||o,t=m.current;t&&t!==n&&!s&&i.unregister(t),i.register(n,{...p.current.rules,...M(p.current.disabled)?{disabled:p.current.disabled}:{}});let r=(e,t)=>{let n=V(i._fields,e);n&&n._f&&(n._f.mount=t)};if(r(n,!0),e){let e=C(V(i._options.defaultValues,n,p.current.defaultValue));I(i._defaultValues,n,e),A(V(i._formValues,n))&&I(i._formValues,n,e)}return s||i.register(n),m.current=n,()=>{(s?e&&!i._state.action:e)?i.unregister(n):r(n,!1)}},[n,i,s,o]),f().useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),f().useMemo(()=>({field:_,formState:d,fieldState:g}),[_,d,g])}let em=e=>e.render(ep(e));f().createContext(null).displayName="HookFormContext";var eh=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},eg=e=>Array.isArray(e)?e:[e],ey=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function ev(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],o=t[r];if(i&&x(i)&&o){let e=ev(i,o);x(e)&&(n[r]=e)}else e[r]&&(n[r]=o)}return n}var eb=e=>x(e)&&!Object.keys(e).length,e_=e=>"file"===e.type,ew=e=>{if(!D)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ex=e=>"select-multiple"===e.type,eE=e=>"radio"===e.type,ek=e=>eE(e)||v(e),eS=e=>ew(e)&&e.isConnected;function eO(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=A(e)?r++:e[t[r++]];return e}function eD(e){for(let t in e)if(e.hasOwnProperty(t)&&!A(e[t]))return!1;return!0}function eC(e,t){let n=Array.isArray(t)?t:F(t)?[t]:T(t),r=1===n.length?e:eO(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(x(r)&&eb(r)||Array.isArray(r)&&eD(r))&&eC(e,n.slice(0,-1)),e}var eF=e=>{for(let t in e)if(j(e[t]))return!0;return!1};function eA(e){return Array.isArray(e)||x(e)&&!eF(e)}function eP(e,t={}){for(let n in e){let r=e[n];eA(r)?(t[n]=Array.isArray(r)?[]:{},eP(r,t[n])):A(r)||(t[n]=!0)}return t}function eT(e,t,n){for(let r in n||(n=eP(t)),e){let i=e[r];if(eA(i))A(t)||ec(n[r])?n[r]=eP(i,Array.isArray(i)?[]:{}):eT(i,_(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!ed(i,e)}}return n}let eV={value:!1,isValid:!1},eM={value:!0,isValid:!0};var ej=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!A(e[0].attributes.value)?A(e[0].value)||""===e[0].value?eM:{value:e[0].value,isValid:!0}:eM:eV}return eV},eI=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>A(e)?e:t?""===e?NaN:e?+e:e:n&&es(e)?new Date(e):r?r(e):e;let eN={isValid:!1,value:null};var eL=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,eN):eN;function eq(e){let t=e.ref;return e_(t)?t.files:eE(t)?eL(e.refs).value:ex(t)?[...t.selectedOptions].map(({value:e})=>e):v(t)?ej(e.refs).value:eI(A(t.value)?e.ref.value:t.value,e)}var eR=(e,t,n,r)=>{let i={};for(let n of e){let e=V(t,n);e&&I(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},e$=e=>e instanceof RegExp,eB=e=>A(e)?e:e$(e)?e.source:x(e)?e$(e.value)?e.value.source:e.value:e,eH=e=>({isOnSubmit:!e||e===U,isOnBlur:e===H,isOnChange:e===z,isOnAll:e===Y,isOnTouch:e===W});let ez="AsyncFunction";var eU=e=>!!e&&!!e.validate&&!!(j(e.validate)&&e.validate.constructor.name===ez||x(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===ez)),eW=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),eY=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));let eJ=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=V(e,i);if(n){let{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;else if(e.ref&&t(e.ref,e.name)&&!r)return!0;else if(eJ(o,t))break}else if(x(o)&&eJ(o,t))break}}};function eZ(e,t,n){let r=V(e,n);if(r||F(n))return{error:r,name:n};let i=n.split(".");for(;i.length;){let r=i.join("."),o=V(t,r),a=V(e,r);if(o&&!Array.isArray(o)&&n!==r)break;if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};i.pop()}return{name:n}}var eG=(e,t,n,r)=>{n(e);let{name:i,...o}=e;return eb(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(e=>t[e]===(!r||Y))},eQ=(e,t,n)=>!e||!t||e===t||eg(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),eK=(e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?!r.isOnChange:!i.isOnChange)||e),eX=(e,t)=>!P(V(e,t)).length&&eC(e,t),e0=(e,t,n)=>{let r=eg(V(e,n));return I(r,en,t[n]),I(e,n,r),e};function e1(e,t,n="validate"){if(es(e)||Array.isArray(e)&&e.every(es)||M(e)&&!e)return{type:n,message:es(e)?e:"",ref:t}}var e2=e=>x(e)&&!e$(e)?e:{value:e,message:""},e4=async(e,t,n,r,i,o)=>{let{ref:a,refs:l,required:s,maxLength:u,minLength:c,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:y}=e._f,b=V(n,h);if(!y||t.has(h))return{};let w=l?l[0]:a,E=e=>{i&&w.reportValidity&&(w.setCustomValidity(M(e)?"":e||""),w.reportValidity())},k={},S=eE(a),O=v(a),D=S||O,C=(g||e_(a))&&A(a.value)&&A(b)||ew(a)&&""===a.value||""===b||Array.isArray(b)&&!b.length,F=eh.bind(null,h,r,k),P=(e,t,n,r=G,i=Q)=>{let o=e?t:n;k[h]={type:e?r:i,message:o,ref:a,...F(e?r:i,o)}};if(o?!Array.isArray(b)||!b.length:s&&(!D&&(C||_(b))||M(b)&&!b||O&&!ej(l).isValid||S&&!eL(l).isValid)){let{value:e,message:t}=es(s)?{value:!!s,message:s}:e2(s);if(e&&(k[h]={type:X,message:t,ref:w,...F(X,t)},!r))return E(t),k}if(!C&&(!_(d)||!_(f))){let e,t,n=e2(f),i=e2(d);if(_(b)||isNaN(b)){let r=a.valueAsDate||new Date(b),o=e=>new Date(new Date().toDateString()+" "+e),l="time"==a.type,s="week"==a.type;es(n.value)&&b&&(e=l?o(b)>o(n.value):s?b>n.value:r>new Date(n.value)),es(i.value)&&b&&(t=l?o(b)<o(i.value):s?b<i.value:r<new Date(i.value))}else{let r=a.valueAsNumber||(b?+b:b);_(n.value)||(e=r>n.value),_(i.value)||(t=r<i.value)}if((e||t)&&(P(!!e,n.message,i.message,J,Z),!r))return E(k[h].message),k}if((u||c)&&!C&&(es(b)||o&&Array.isArray(b))){let e=e2(u),t=e2(c),n=!_(e.value)&&b.length>+e.value,i=!_(t.value)&&b.length<+t.value;if((n||i)&&(P(n,e.message,t.message),!r))return E(k[h].message),k}if(p&&!C&&es(b)){let{value:e,message:t}=e2(p);if(e$(e)&&!b.match(e)&&(k[h]={type:K,message:t,ref:a,...F(K,t)},!r))return E(t),k}if(m){if(j(m)){let e=e1(await m(b,n),w);if(e&&(k[h]={...e,...F(ee,e.message)},!r))return E(e.message),k}else if(x(m)){let e={};for(let t in m){if(!eb(e)&&!r)break;let i=e1(await m[t](b,n),w,t);i&&(e={...i,...F(t,i.message)},E(i.message),r&&(k[h]=e))}if(!eb(e)&&(k[h]={ref:w,...e},!r))return k}}return E(!0),k};let e5={mode:U,reValidateMode:z,shouldFocusError:!0};function e3(e={}){let t,n={...e5,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:j(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(x(n.defaultValues)||x(n.values))&&C(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:C(o),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0,c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...c},f={...d},p={array:ey(),state:ey()},m=n.criteriaMode===Y,h=e=>t=>{clearTimeout(u),u=setTimeout(e,t)},g=async e=>{if(!l.keepIsValid&&!n.disabled&&(d.isValid||f.isValid||e)){let e;n.resolver?(e=eb((await H()).errors),y()):e=await W({fields:i,onlyCheckValid:!0,eventType:B}),e!==r.isValid&&p.state.next({isValid:e})}},y=(e,t)=>{!n.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(t?I(r.validatingFields,e,t):eC(r.validatingFields,e))}),p.state.next({validatingFields:r.validatingFields,isValidating:!eb(r.validatingFields)}))},w=(e,t=[],s,u,c=!0,m=!0)=>{if(u&&s&&!n.disabled){if(l.action=!0,m&&Array.isArray(V(i,e))){let t=s(V(i,e),u.argA,u.argB);c&&I(i,e,t)}if(m&&Array.isArray(V(r.errors,e))){let t=s(V(r.errors,e),u.argA,u.argB);c&&I(r.errors,e,t),eX(r.errors,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(V(r.touchedFields,e))){let t=s(V(r.touchedFields,e),u.argA,u.argB);c&&I(r.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=eT(o,a),n=k(e);I(r.dirtyFields,n,V(t,n))}p.state.next({name:e,isDirty:Z(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else I(a,e,t)},O=(e,t)=>{I(r.errors,e,t),p.state.next({errors:r.errors})},F=(e,t,n,r)=>{let s=V(i,e);if(s){let i=V(a,e,A(n)?V(o,e):n);A(i)||r&&r.defaultChecked||t?I(a,e,t?i:eq(s._f)):Q(e,i),l.mount&&!l.action&&g()}},T=(e,t,i,a,l)=>{let s=!1,u=!1,c={name:e};if(!n.disabled){if(!i||a){(d.isDirty||f.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=Z(),s=u!==c.isDirty);let n=ed(V(o,e),t);u=!!V(r.dirtyFields,e),n?eC(r.dirtyFields,e):I(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,s=s||(d.dirtyFields||f.dirtyFields)&&!n!==u}if(i){let t=V(r.touchedFields,e);t||(I(r.touchedFields,e,i),c.touchedFields=r.touchedFields,s=s||(d.touchedFields||f.touchedFields)&&t!==i)}s&&l&&p.state.next(c)}return s?c:{}},q=(e,i,o,a)=>{let l=V(r.errors,e),s=(d.isValid||f.isValid)&&M(i)&&r.isValid!==i;if(n.delayError&&o?(t=h(()=>O(e,o)))(n.delayError):(clearTimeout(u),t=null,o?I(r.errors,e,o):eC(r.errors,e)),(o?!ed(l,o):l)||!eb(a)||s){let t={...a,...s&&M(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},p.state.next(t)}},H=async e=>(y(e,!0),await n.resolver(a,n.context,eR(e||s.mount,i,n.criteriaMode,n.shouldUseNativeValidation))),z=async e=>{let{errors:t}=await H(e);if(y(e),e)for(let n of e){let e=V(t,n);e?I(r.errors,n,e):eC(r.errors,n)}else r.errors=t;return t},U=async({name:t,eventType:n})=>{if(e.validate){let i=await e.validate({formValues:a,formState:r,name:t,eventType:n});if(x(i))for(let e in i)i[e]&&ef(`${et}.${e}`,{message:es(i.message)?i.message:"",type:ee});else es(i)||!i?ef(et,{message:i||"",type:ee}):ec(et);return i}return!0},W=async({fields:t,onlyCheckValid:i,name:o,eventType:l,context:u={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(u.runRootValidation=!0,!await U({name:o,eventType:l}))&&(u.valid=!1,i))return u.valid;for(let o in t){let c=t[o];if(c){let{_f:t,...f}=c;if(t){let o=s.array.has(t.name),l=c._f&&eU(c._f);l&&d.validatingFields&&y([t.name],!0);let f=await e4(c,s.disabled,a,m,n.shouldUseNativeValidation&&!i,o);if(l&&d.validatingFields&&y([t.name]),f[t.name]&&(u.valid=!1,i)||(i||(V(f,t.name)?o?e0(r.errors,f,t.name):I(r.errors,t.name,f[t.name]):eC(r.errors,t.name)),e.shouldUseNativeValidation&&f[t.name]))break}eb(f)||await W({context:u,onlyCheckValid:i,fields:f,name:o,eventType:l})}}return u.valid},J=()=>{for(let e of s.unMount){let t=V(i,e);t&&(t._f.refs?t._f.refs.every(e=>!eS(e)):!eS(t._f.ref))&&eE(e)}s.unMount=new Set},Z=(e,t)=>!n.disabled&&(e&&t&&I(a,e,t),!ed(ea(),o)),G=(e,t,n)=>eu(e,s,{...l.mount?a:A(t)?o:es(e)?{[e]:t}:t},n,t),Q=(e,t,n={})=>{let r=V(i,e),o=t;if(r){let n=r._f;n&&(n.disabled||I(a,e,eI(t,n)),o=ew(n.ref)&&_(t)?"":t,ex(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?v(n.ref)?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):e_(n.ref)?n.ref.value="":(n.ref.value=o,n.ref.type||p.state.next({name:e,values:C(a)})))}(n.shouldDirty||n.shouldTouch)&&T(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&eo(e)},K=(e,t,n)=>{for(let r in t){if(!t.hasOwnProperty(r))return;let o=t[r],a=e+"."+r,l=V(i,a);(s.array.has(e)||x(o)||l&&!l._f)&&!b(o)?K(a,o,n):Q(a,o,n)}},X=(e,t,n={})=>{let u=V(i,e),c=s.array.has(e),m=C(t);I(a,e,m),c?(p.array.next({name:e,values:C(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&n.shouldDirty&&p.state.next({name:e,dirtyFields:eT(o,a),isDirty:Z(e,m)})):!u||u._f||_(m)?Q(e,m,n):K(e,m,n),eY(e,s)?p.state.next({...r,name:e,values:C(a)}):p.state.next({name:l.mount?e:void 0,values:C(a)})},er=async o=>{l.mount=!0;let u=o.target,c=u.name,h=!0,v=V(i,c),_=e=>{h=Number.isNaN(e)||b(e)&&isNaN(e.getTime())||ed(e,V(a,c,e))},w=eH(n.mode),x=eH(n.reValidateMode);if(v){let l,b,k=u.type?eq(v._f):E(o),S=o.type===N||o.type===L,O=!eW(v._f)&&!e.validate&&!n.resolver&&!V(r.errors,c)&&!v._f.deps||eK(S,V(r.touchedFields,c),r.isSubmitted,x,w),D=eY(c,s,S);I(a,c,k),S?u&&u.readOnly||(v._f.onBlur&&v._f.onBlur(o),t&&t(0)):v._f.onChange&&v._f.onChange(o);let F=T(c,k,S),A=!eb(F)||D;if(S||p.state.next({name:c,type:o.type,values:C(a)}),O)return(d.isValid||f.isValid)&&("onBlur"===n.mode?S&&g():S||g()),A&&p.state.next({name:c,...D?{}:F});if(!n.resolver&&e.validate&&await U({name:c,eventType:o.type}),!S&&D&&p.state.next({...r}),n.resolver){let{errors:e}=await H([c]);if(y([c]),_(k),h){let t=eZ(r.errors,i,c),n=eZ(e,i,t.name||c);l=n.error,c=n.name,b=eb(e)}}else y([c],!0),l=(await e4(v,s.disabled,a,m,n.shouldUseNativeValidation))[c],y([c]),_(k),h&&(l?b=!1:(d.isValid||f.isValid)&&(b=await W({fields:i,onlyCheckValid:!0,name:c,eventType:o.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&eo(v._f.deps),q(c,b,l,F))}},ei=(e,t)=>{if(V(r.errors,t)&&e.focus)return e.focus(),1},eo=async(e,t={})=>{let o,a,l=eg(e);if(n.resolver){let t=await z(A(e)?e:l);o=eb(t),a=e?!l.some(e=>V(t,e)):o}else e?((a=(await Promise.all(l.map(async e=>{let t=V(i,e);return await W({fields:t&&t._f?{[e]:t}:t,eventType:$})}))).every(Boolean))||r.isValid)&&g():a=o=await W({fields:i,name:e,eventType:$});return p.state.next({...!es(e)||(d.isValid||f.isValid)&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&eJ(i,ei,e?l:s.mount),a},ea=(e,t)=>{let n={...l.mount?a:o};return t&&(n=ev(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),A(e)?n:es(e)?V(n,e):e.map(e=>V(n,e))},el=(e,t)=>({invalid:!!V((t||r).errors,e),isDirty:!!V((t||r).dirtyFields,e),error:V((t||r).errors,e),isValidating:!!V(r.validatingFields,e),isTouched:!!V((t||r).touchedFields,e)}),ec=e=>{let t=e?eg(e):void 0;null==t||t.forEach(e=>eC(r.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:r.errors})}):p.state.next({errors:{}})},ef=(e,t,n)=>{let o=(V(i,e,{_f:{}})._f||{}).ref,{ref:a,message:l,type:s,...u}=V(r.errors,e)||{};I(r.errors,e,{...u,...t,ref:o}),p.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},ep=(e,t)=>j(e)?p.state.subscribe({next:n=>"values"in n&&e(G(void 0,t),n)}):G(e,t,!0),em=e=>p.state.subscribe({next:t=>{eQ(e.name,t.name,e.exact)&&eG(t,e.formState||d,eN,e.reRenderRoot)&&e.callback({values:{...a},...r,...t,defaultValues:o})}}).unsubscribe,eh=e=>(l.mount=!0,f={...f,...e.formState},em({...e,formState:{...c,...e.formState}})),eE=(e,t={})=>{for(let l of e?eg(e):s.mount)s.mount.delete(l),s.array.delete(l),t.keepValue||(eC(i,l),eC(a,l)),t.keepError||eC(r.errors,l),t.keepDirty||eC(r.dirtyFields,l),t.keepTouched||eC(r.touchedFields,l),t.keepIsValidating||eC(r.validatingFields,l),n.shouldUnregister||t.keepDefaultValue||eC(o,l);p.state.next({values:C(a)}),p.state.next({...r,...!t.keepDirty?{}:{isDirty:Z()}}),t.keepIsValid||g()},eO=({disabled:e,name:t})=>{if(M(e)&&l.mount||e||s.disabled.has(t)){let n=!!e!==s.disabled.has(t);e?s.disabled.add(t):s.disabled.delete(t),n&&l.mount&&!l.action&&g()}},eD=(e,t={})=>{let r=V(i,e),a=M(t.disabled)||M(n.disabled);return I(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),s.mount.add(e),r?eO({disabled:M(t.disabled)?t.disabled:n.disabled,name:e}):F(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:eB(t.min),max:eB(t.max),minLength:eB(t.minLength),maxLength:eB(t.maxLength),pattern:eB(t.pattern)}:{},name:e,onChange:er,onBlur:er,ref:a=>{if(a){eD(e,t),r=V(i,e);let n=A(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,l=ek(n),s=r._f.refs||[];(l?s.find(e=>e===n):n===r._f.ref)||(I(i,e,{_f:{...r._f,...l?{refs:[...s.filter(eS),n,...Array.isArray(V(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),F(e,!1,void 0,n))}else(r=V(i,e,{}))._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&!(S(s.array,e)&&l.action)&&s.unMount.add(e)}}},eF=()=>n.shouldFocusError&&eJ(i,ei,s.mount),eA=(e,t)=>async o=>{let l;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let u=C(a);if(p.state.next({isSubmitting:!0}),n.resolver){let{errors:e,values:t}=await H();y(),r.errors=e,u=C(t)}else await W({fields:i,eventType:R});if(s.disabled.size)for(let e of s.disabled)eC(u,e);if(eC(r.errors,en),eb(r.errors)){p.state.next({errors:{}});try{await e(u,o)}catch(e){l=e}}else t&&await t({...r.errors},o),eF(),setTimeout(eF);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:eb(r.errors)&&!l,submitCount:r.submitCount+1,errors:r.errors}),l)throw l},eP=(e,t={})=>{V(i,e)&&(A(t.defaultValue)?X(e,C(V(o,e))):(X(e,t.defaultValue),I(o,e,C(t.defaultValue))),t.keepTouched||eC(r.touchedFields,e),t.keepDirty||(eC(r.dirtyFields,e),r.isDirty=t.defaultValue?Z(e,C(V(o,e))):Z()),!t.keepError&&(eC(r.errors,e),d.isValid&&g()),p.state.next({...r}))},eV=(e,t={})=>{let u=e?C(e):o,c=C(u),f=eb(e),m=f?o:c;if(t.keepDefaultValues||(o=u),!t.keepValues){if(t.keepDirtyValues)for(let e of Array.from(new Set([...s.mount,...Object.keys(eT(o,a))]))){let t=V(r.dirtyFields,e),n=V(a,e),i=V(m,e);t&&!A(n)?I(m,e,n):t||A(i)||X(e,i)}else{if(D&&A(e))for(let e of s.mount){let t=V(i,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(ew(e)){let t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(let e of s.mount)X(e,V(m,e));else i={}}a=n.shouldUnregister?t.keepDefaultValues?C(o):{}:C(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:t.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!eb(m),l.watch=!!n.shouldUnregister,l.keepIsValid=!!t.keepIsValid,l.action=!1,t.keepErrors||(r.errors={}),p.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!f&&(t.keepDirty?r.isDirty:!!(t.keepDefaultValues&&!ed(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:f?{}:t.keepDirtyValues?t.keepDefaultValues&&a?eT(o,a):r.dirtyFields:t.keepDefaultValues&&e?eT(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:o})},eM=(e,t)=>eV(j(e)?e(a):e,{...n.resetOptions,...t}),ej=(e,t={})=>{let n=V(i,e),r=n&&n._f;if(r){let e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&j(e.select)&&e.select()})}},eN=e=>{r={...r,...e}},eL={control:{register:eD,unregister:eE,getFieldState:el,handleSubmit:eA,setError:ef,_subscribe:em,_runSchema:H,_updateIsValidating:y,_focusError:eF,_getWatch:G,_getDirty:Z,_setValid:g,_setFieldArray:w,_setDisabledField:eO,_setErrors:e=>{r.errors=e,p.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>P(V(l.mount?a:o,e,n.shouldUnregister?V(o,e,[]):[])),_reset:eV,_resetDefaultValues:()=>j(n.defaultValues)&&n.defaultValues().then(e=>{eM(e,n.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:e=>{M(e)&&(p.state.next({disabled:e}),eJ(i,(t,n)=>{let r=V(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:p,_proxyFormState:d,get _fields(){return i},get _formValues(){return a},get _state(){return l},set _state(value){l=value},get _defaultValues(){return o},get _names(){return s},set _names(value){s=value},get _formState(){return r},get _options(){return n},set _options(value){n={...n,...value}}},subscribe:eh,trigger:eo,register:eD,handleSubmit:eA,watch:ep,setValue:X,getValues:ea,reset:eM,resetField:eP,clearErrors:ec,unregister:eE,setError:ef,setFocus:ej,getFieldState:el};return{...eL,formControl:eL}}function e6(e={}){let t=f().useRef(void 0),n=f().useRef(void 0),[r,i]=f().useState({isDirty:!1,isValidating:!1,isLoading:j(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:j(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!j(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=e3(e);t.current={...i,formState:r}}let o=t.current.control;return o._options=e,ea(()=>{let e=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),f().useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),f().useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),f().useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),f().useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),f().useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}},[o,r.isDirty]),f().useEffect(()=>{var t;e.values&&!ed(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null==(t=o._options.resetOptions)?void 0:t.keepIsValid)||o._setValid(),n.current=e.values,i(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),f().useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=f().useMemo(()=>eo(r,o),[o,r]),t.current}var e9=n(7807);let e7=(0,d.createContext)(null),e8={didCatch:!1,error:null};class te extends d.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=e8}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=Array(r),o=0;o<r;o++)i[o]=arguments[o];null==(t=(n=this.props).onReset)||t.call(n,{args:i,reason:"imperative-api"}),this.setState(e8)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&tt(e.resetKeys,r)){var i,o;null==(i=(o=this.props).onReset)||i.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(e8)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:o}=this.state,a=e;if(i){let e={error:o,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=(0,d.createElement)(n,e);else if(null===r||(0,d.isValidElement)(r))a=r;else throw o}return(0,d.createElement)(e7.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},a)}}function tt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var tn=n(222),tr=n.n(tn);let ti="field.required",to="field.outOfBound",ta={validate:(e,t)=>{if(e.meta?.submission?.unspecified)return[];if(ts(t)&&e.isRequired){if("object"==typeof e.required&&"conditionalRequired"===e.required.type&&e.isRequired)return tc(ti,e.required.message??"Field is mandatory");else if(e.isRequired)return tc(ti,"Field is mandatory")}if("text"===e.questionOptions.rendering)return tu(e.questionOptions.minLength,e.questionOptions.maxLength,t?.length)??[];if("number"===e.questionOptions.rendering){let n=Number(e.questionOptions.min),r=Number(e.questionOptions.max),i=e.questionOptions.disallowDecimals||e.meta?.concept?.allowDecimal;if(ts(t))return[];if(i&&!Number.isInteger(t))return tc(to,"Decimal values are not allowed for this field");if(!Number.isNaN(n)||!Number.isNaN(r))return tl(n,r,t)}return[]}};function tl(e,t,n){return!Number.isNaN(e)&&n<e?tc(to,`Value must be greater than ${e}`):!Number.isNaN(t)&&n>t?tc(to,`Value must be lower than ${t}`):[]}function ts(e){return!!(null==e||""===e||"string"==typeof e&&!e?.trim()||Array.isArray(e)&&!e.length)}function tu(e,t,n){let r=Number(e),i=Number(t);if("number"==typeof n&&!Number.isNaN(n)){if(r&&i&&n>=r&&n<=i)return[];if(r&&n<r)return tc(to,`Length should be at least ${r} characters`);if(i&&n>i)return tc(to,`Length should not exceed ${i} characters`);if(i&&r&&n<r&&n>i)return tc(to,`Length should be between ${r} and ${i} characters`)}}function tc(e,t){return[{resultType:"error",errCode:e,message:t}]}function td(e){let t=[];function n(e){t.push(e),e.groupMembers?.length&&e.groupMembers.forEach(e=>{n(e)})}return e.forEach(e=>{n(e)}),t}function tf(e,t){return e.questionOptions.rendering===t}function tp(e){e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),e.meta.submission={...e.meta.submission,voidedValue:null,newValue:null}}function tm(e,t,n){return e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),ts(t)||(e.meta.submission.newValue=t),ts(n)||(e.meta.submission.voidedValue=n),e.meta.submission.newValue}function th(e){return!!e.meta.submission?.newValue||!!e.meta.submission?.voidedValue}function tg(e){return"view"===e||"embedded-view"===e}function ty(e){let t=tr()(e).toDate();if(isNaN(t.getTime()))return new Date(NaN);try{let n=e.split("T")[1];if(n){let e=n.split(":");t.setHours(parseInt(e[0]),parseInt(e[1]),0)}}catch(e){console.error(e)}return t}function tv(e,t){if(!t)return e;let n=t.startDatetime?new Date(t.startDatetime):null,r=t.stopDatetime?new Date(t.stopDatetime):null;return n&&e<n||r&&e>r?n??r:e}function tb(e,t){let n={noToday:!0};return"calendar"===e.datePickerFormat?n.time=!1:n.time=!0,(0,u.formatDate)(t,n)}function t_(e){return e.pages=e.pages.map(e=>(e.sections=Array.from(e.sections),e)),{...e}}function tw(e,t=16){return e/t}var tx=n(5992),tE=n(1630),tk=n.n(tE),tS=n(2154),tO=n.n(tS),tD=n(7581),tC=n.n(tD),tF=n(7289),tA=n.n(tF),tP=n(3657),tT=n.n(tP),tV=n(8087),tM=n.n(tV),tj=n(9908);let tI={wflFemaleBelow5:()=>n.e("4926").then(n.t.bind(n,877,19)),wflMaleBelow5:()=>n.e("908").then(n.t.bind(n,4775,19)),hfaFemaleBelow5:()=>n.e("212").then(n.t.bind(n,6095,19)),hfaMaleBelow5:()=>n.e("4958").then(n.t.bind(n,5501,19)),hfaFemale5Above:()=>n.e("1229").then(n.t.bind(n,8844,19)),hfaMale5Above:()=>n.e("383").then(n.t.bind(n,7890,19)),bfaFemale5Above:()=>n.e("9899").then(n.t.bind(n,5878,19)),bfaMale5Above:()=>n.e("8577").then(n.t.bind(n,6008,19))},tN={calcWeightForHeightZscore:["wflFemaleBelow5","wflMaleBelow5"],calcHeightForAgeZscore:["hfaFemaleBelow5","hfaMaleBelow5","hfaFemale5Above","hfaMale5Above"],calcBMIForAgeZscore:["bfaFemale5Above","bfaMale5Above"]},tL=new Map;async function tq(e){let t=JSON.stringify(e??{}),n=Object.entries(tN).filter(([e])=>t.includes(e)).flatMap(([,e])=>e).filter(e=>!tL.has(e)),r=(await Promise.allSettled(n.map(async e=>{let t=await tI[e]();tL.set(e,t.default)}))).find(e=>"rejected"===e.status);if(r)throw r.reason}function tR(e){let t=tL.get(e);return t||console.warn(`Z-score calculation: the ${e} reference table hasn't been loaded`),t}function t$(e,t,n){let r=tU(t,n,"years");return"F"===e&&r<5?tR("wflFemaleBelow5"):"M"===e&&r<5?tR("wflMaleBelow5"):null}function tB(e,t,n){let r=tU(t,n,"years"),i=tU(t,n,"months"),o=tU(t,n,"days");if("F"===e){if(r<5)return tz(tR("hfaFemaleBelow5"),"Day",o);if(r>=5&&r<18)return tz(tR("hfaFemale5Above"),"Month",i)}if("M"===e){if(r<5)return tz(tR("hfaMaleBelow5"),"Day",o);if(r>=5&&r<18)return tz(tR("hfaMale5Above"),"Month",i)}return null}function tH(e,t,n){let r=tU(t,n,"years"),i=tU(t,n,"months");return"F"===e&&r>=5&&r<18?tz(tR("bfaFemale5Above"),"Month",i):"M"===e&&r>=5&&r<18?tz(tR("bfaMale5Above"),"Month",i):null}function tz(e,t,n){return tC()(e,e=>e[t]===n)}function tU(e,t,n){if(e&&t&&n){let r=tr()(t),i=tr()(e);return r.diff(i,n)}return null}function tW(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}tr().extend(tk());class tY{constructor(e,t,n,r){tW(this,"node",null),tW(this,"patient",null),tW(this,"allFields",[]),tW(this,"allFieldValues",{}),tW(this,"api",tj),tW(this,"isEmpty",ts),tW(this,"dayjs",tr()),tW(this,"calculateZScoreFromRef",(e,t)=>{if(!e)return console.warn("Z-score calculation: No reference data object provided"),null;let n=Object.keys(e),r=n.map(t=>e[t]),i=r[1],o=[];t<i?o.push(i):tT()(r,e=>{e<=t&&o.push(e)});let a=tM()(o),l=n[tO()(r,e=>e===a)],s=l?.replace("SD","");return s?.includes("neg")&&(s="-"+s.substring(0,1)),("S"===s||"L"===s||"M"===s||"-5"===s)&&(s="-4"),s??null}),tW(this,"today",()=>new Date),tW(this,"includes",(e,t)=>e?.includes(t)),tW(this,"isDateBefore",(e,t,n)=>{let r=t instanceof Date?t:n?tr()(t,n,!0).toDate():tr()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()<r.getTime()}),tW(this,"isDateAfter",(e,t,n,r)=>{let i,o=tr()(t);switch(r){case"months":i=o.add(n,"month").toDate();break;case"weeks":i=o.add(n,"week").toDate();break;case"days":i=o.add(n,"day").toDate();break;case"years":i=o.add(n,"year").toDate();break;default:i=new Date(0)}return e.getTime()>=i.getTime()}),tW(this,"addWeeksToDate",(e,t)=>tr()(e).add(t,"week").toDate()),tW(this,"addDaysToDate",(e,t)=>tr()(e).add(t,"day").toDate()),tW(this,"isDateAfterSimple",(e,t,n)=>{let r=t instanceof Date?t:n?tr()(t,n,!0).toDate():tr()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()>r.getTime()}),tW(this,"useFieldValue",e=>{let t=this.allFields.find(t=>t.id===e);return t&&tZ(this.node,t),this.allFieldValues[e]??null}),tW(this,"doesNotMatchExpression",(e,t)=>!!(!t||["undefined","null",""].includes(t.toString()))||!new RegExp(e).test(t)),tW(this,"calcBMI",(e,t)=>{if(!e||!t)return null;let n=e/100;return parseFloat((t/(n*n)).toFixed(1))}),tW(this,"calcEDD",e=>e?new Date(e.getTime()+24192e6):null),tW(this,"calcMonthsOnART",e=>{if(null==e)return null;if(!(e instanceof Date))throw Error("DateFormatException: value passed is not a valid date");let t=new Date;return 30>Math.round((t.getTime()-e.getTime())/864e5)?0:tr()(t).diff(e,"month")}),tW(this,"calcViralLoadStatus",e=>{let t;return e&&(t=e>50?"a6768be6-c08e-464d-8f53-5f4229508e54":"5d5e42cc-acc4-4069-b3a8-7163e0db5d96"),t??null}),tW(this,"calcNextVisitDate",(e,t)=>e&&t?new Date(e.getTime()+24*t*36e5):null),tW(this,"calcTreatmentEndDate",(e,t,n)=>{if(!e||!t||"160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"!==n)return null;let r=30+t;return new Date(e.getTime()+24*r*36e5)}),tW(this,"calcAgeBasedOnDate",e=>(e?new Date(e).getFullYear():new Date().getFullYear())-new Date(this.patient.birthDate).getFullYear()),tW(this,"calcBSA",(e,t)=>e&&t?parseFloat(Math.sqrt(e*t/3600).toFixed(2)):null),tW(this,"arrayContains",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1===e.indexOf(n))return!1;return!0}),tW(this,"arrayContainsAny",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1!==e.indexOf(n))return!0;return!1}),tW(this,"parseDate",e=>(0,u.parseDate)(e)),tW(this,"formatDate",(e,t)=>{if(!(e instanceof Date)&&isNaN((e=new Date(e)).getTime()))throw Error("DateFormatException: value passed is not a valid date");return t?tr()(e).format(t):(0,u.formatDate)(e)}),tW(this,"extractRepeatingGroupValues",(e,t)=>t.map(function(t){return t[e]})),tW(this,"calcGravida",(e,t)=>{let n="number"==typeof e?e:parseInt(e,10),r="number"==typeof t?t:parseInt(t,10);if(!Number.isInteger(n)||!Number.isInteger(r))throw Error("Both inputs must be valid numbers.");return n+r}),tW(this,"calcWeightForHeightZscore",(e,t)=>{if(!e||!t)return null;let n=new Date(this.patient.birthDate),r=t$(this.patient.sex,n,new Date);if(!r)return null;let i=110;if(e<45||e>i)return null;let o=e.toFixed(1),a=tC()(r,e=>parseFloat(e.Length).toFixed(1)===o),l=tA()(a);return this.calculateZScoreFromRef(l,t)}),tW(this,"calcBMIForAgeZscore",(e,t)=>{if(!e||!t)return null;let n=new Date(this.patient.birthDate),r=tH(this.patient.sex,n,new Date),i=e/100,o=parseFloat((t/(i*i)).toFixed(1)),a=tA()(r);return this.calculateZScoreFromRef(a,o)}),tW(this,"calcHeightForAgeZscore",(e,t)=>{if(!e)return null;let n=new Date(this.patient.birthDate),r=tB(this.patient.sex,n,new Date),i=tA()(r);return this.calculateZScoreFromRef(i,e)}),tW(this,"calcTimeDifference",(e,t)=>{if(!e)return 0;let n=tr()();switch(t){case"d":return Math.abs(Math.round(n.diff(e,"day",!0)));case"w":return Math.abs(Math.round(n.diff(e,"week",!0)));case"m":return Math.abs(Math.round(n.diff(e,"month",!0)));case"y":return Math.abs(Math.round(n.diff(e,"year",!0)))}}),tW(this,"resolve",e=>Promise.resolve(e)),this.allFields=n,this.allFieldValues=r,this.node=e,this.patient=t}}function tJ(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function tZ(e,t){if(e&&t)switch(e.type){case"page":t.pageDependents||(t.pageDependents=new Set),t.pageDependents.add(e.value.label);break;case"section":t.sectionDependents||(t.sectionDependents=new Set),t.sectionDependents.add(e.value.label);break;default:t.fieldDependents||(t.fieldDependents=new Set),t.fieldDependents.add(e.value.id)}}function tG(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class tQ{putObject(e,t){this.dataSourceMap[e]=t}getObject(e){return this.dataSourceMap[e]}constructor(){tG(this,"dataSourceMap",{})}}let tK=new Map;function tX(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||"object"==typeof e||null==e}function t0(e,t,n,r,i){if(!e?.trim())return null;let o=t4(e);t5(o,t,n);try{return(0,u.evaluateAsType)(o,t2(t,n,r,i),tX)}catch(t){console.error(`Error: ${t}
|
|
2
2
|
|
|
3
3
|
failing expression: ${e}`)}return null}async function t1(e,t,n,r,i){if(!e?.trim())return null;let o=t4(e);t5(o,t,n);try{return(0,u.evaluateAsTypeAsync)(o,t2(t,n,r,i),tX)}catch(t){console.error(`Error: ${t}
|
|
4
4
|
|
|
5
|
-
failing expression: ${e}`)}return null}function t2(e,t,n,r){let{myValue:i,patient:o}=r,{sex:a,age:l}=o??{};"field"===e.type&&void 0===i&&e.value&&(i=n[e.value.id]);let s=new tQ;s.putObject("prevEnc",{value:r.previousEncounter||{obs:[]},getValue(e){return this.value.obs.find(t=>t.concept.uuid==e)}});let u=r?.visit??{},c=u?.visitType||{uuid:""},d=c.uuid??"",f={isEmpty:tx.A};return{...new tY(e,o,t,n),...dP(),...r,...n,patient:o,myValue:i,sex:a,age:l,HD:s,visit:u,visitType:c,visitTypeUuid:d,_:f}}function t4(e){let t=tJ(e);if(tK.has(t))return tK.get(t);let n=(0,u.compile)(e);return tK.set(t,n),n}function t5(e,t,n){for(let r of(0,u.extractVariableNames)(e)){let e=n.find(e=>e.id===r);e&&tZ(t,e)}}function t3(e,t,n,r){return"embedded-view"==r||("automatic"==e?"maximized"==n&&t.endsWith("desktop"):"single-line"==e)}function t6(e,t){let n=e.validators.find(e=>"conditionalAnswered"===e.type).referenceQuestionId,r=t.find(e=>e.id==n);r&&(r.fieldDependents||(r.fieldDependents=new Set)).add(e.id)}function t9(e,t,n){if("object"!=typeof e.required)return!1;let{referenceQuestionAnswers:r,referenceQuestionId:i}=e.required,o=t.find(e=>e.id==i);return!!o&&((o.fieldDependents||(o.fieldDependents=new Set)).add(e.id),r?.includes(n[i]))}function t7(e,t,n,r,i,o){let{value:a}=e;return o(a.disabled?.disableWhenExpression,e,t,n,{mode:r,patient:i})}function t8(e,t,n,r,i,o,a){let{value:l,type:s}=e,u=o(l.hide?.hideWhenExpression,e,t,n,{mode:r,patient:i});e.value.isHidden=u,"field"==s&&e.value?.questions?.length&&e.value?.questions.forEach(e=>{e.isParentHidden=u}),"page"==s&&l.sections.forEach(e=>{e.isParentHidden=u,ne(u,e,t,a)}),"section"==s&&ne(u,l,t,a)}function ne(e,t,n,r){let i=t.questions.map(e=>e.id);n.filter(e=>i.includes(e.id)).forEach(t=>{t.isParentHidden=e,"group"==t.questionOptions.rendering&&t.questions.forEach(t=>{t.isParentHidden=e}),r?.(t)})}function nt(e,t){if(!e?.includes(":"))return t?.find(t=>t.uuid===e);{let[n,r]=e.split(":");return t?.find(e=>e?.conceptMappings?.find(e=>e?.conceptReferenceTerm?.conceptSource?.name.toUpperCase()===n.toUpperCase()&&e?.conceptReferenceTerm?.code.toUpperCase()===r.toUpperCase()))}}function nn(e,t=!1){let n=document.getElementById(e);n?.scrollIntoView({behavior:"smooth",block:"start",inline:"center"}),t&&n?.focus()}let nr=(e,t)=>{let n=e.questionOptions.rendering;if("object"!=typeof t)return{value:t,display:t};let r="Observation"===t.resourceType?no(t,n):t;if(!r)return{value:null,display:null};if("string"==typeof r.value||"number"==typeof r.value){if("date"===n||"datetime"===n){let e=ty(`${r.value}`);return{value:e,display:tr()(e).format("YYYY-MM-DD HH:mm")}}return{value:r.value,display:r.value}}return["toggle","checkbox"].includes(n)?{value:r.value?.uuid,display:r.value?.name?.name}:{value:r.value?.uuid,display:e.questionOptions.answers?.find(e=>e.concept===r.value?.uuid)?.label}};function ni(e){return!e.isHidden&&(e.sections?.some(e=>!e.isHidden&&e.questions?.some(e=>!e.isHidden))??!1)}function no(e,t){try{return{obsDatetime:e.effectiveDateTime,uuid:e.id,concept:{uuid:e.code.coding[0]?.code,display:e.code.coding[0]?.display},value:na(e,t)}}catch(e){return console.error("Error converting FHIR Obs to OpenMRS modelling",e),null}}function na(e,t){switch(t){case"toggle":return e.valueBoolean?{uuid:c.t$}:{uuid:c.Mi};case"date":case"datetime":return e.valueDateTime;case"number":return e.valueQuantity?.value??null;case"radio":case"checkbox":case"select":case"content-switcher":return e.valueCodeableConcept?.coding[0]?{uuid:e.valueCodeableConcept?.coding[0].code,name:{name:e.valueCodeableConcept?.coding[0].display}}:null;default:return e.valueString}}function nl(e,t){let n=e.pages.find(e=>t.meta.pageId===e.id);return n?.sections.find(e=>e.questions.find(e=>e.id===t.id))}var ns=n(8059);function nu(e,t){let{methods:{getValues:n}}=t,r=n();c.FU.includes(e.questionOptions.rendering)&&nc(e,r,t),nd(e,r,t)}function nc(e,t,n){let{sessionMode:r,formFields:i,patient:o,visit:a}=n;e.questionOptions.answers.forEach(n=>{let l=n.disable?.disableWhenExpression;l&&l.includes("myValue")&&(n.disable.isDisabled=t0(n.disable?.disableWhenExpression,{value:e,type:"field"},i,t,{mode:r,patient:o,visit:a}))})}function nd(e,t,n){let{sessionMode:r,formFields:i,patient:o,formFieldValidators:a,formJson:l,methods:{setValue:s},updateFormField:u,setForm:c,visit:d}=n,f=!1;e.fieldDependents&&e.fieldDependents.forEach(e=>{let c=i.find(t=>t.id==e);if(c){if(c.questionOptions.calculate?.calculateExpression&&t1(c.questionOptions.calculate.calculateExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d}).then(e=>{s(c.id,e);let{errors:a,warnings:l}=nf(c,e,n.formFieldValidators,{formFields:i,values:t,expressionContext:{patient:o,mode:r}});c.meta.submission||(c.meta.submission={}),c.meta.submission.errors=a,c.meta.submission.warnings=l,a.length||n.formFieldAdapters[c.type].transformFieldValue(c,e,n),u(c)}).catch(e=>{(0,ns.N)(e,"Error evaluating calculate expression")}),c.hide){let e=nl(l,c),n=e?.questions.some(e=>!e.isHidden);if(t8({value:c,type:"field"},i,t,r,o,t0,u),e){e.questions=e?.questions.map(e=>e.id===c.id?c:e);let t=c.isHidden,r=[...e.questions,c].some(e=>!e.isHidden);n||t?n&&!r&&(e.isHidden=!0,f=!0):(e.isHidden=!1,f=!0)}}if("object"==typeof c.disabled&&c.disabled.disableWhenExpression&&(c.isDisabled=t7({value:c,type:"field"},i,t,r,o,t0)),"object"==typeof c.required&&c.required?.type==="conditionalRequired"&&(c.isRequired=t9(c,i,t)),c.validators?.some(e=>"conditionalAnswered"===e.type)){let e=c.validators?.find(e=>"conditionalAnswered"===e.type),n=a.conditionalAnswered.validate(c,c.meta.submission?.newValue,{...e,expressionContext:{patient:o,mode:r},values:t,formFields:i});c.meta.submission={...c.meta.submission,errors:n}}c?.questionOptions.answers?.filter(e=>!ts(e.hide?.hideWhenExpression)).forEach(e=>{e.isHidden=t0(e.hide?.hideWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),c?.questionOptions.answers?.filter(e=>!ts(e.disable?.isDisabled)).forEach(e=>{e.disable.isDisabled=t0(e.disable?.disableWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),!c.isHidden&&c.meta.readonlyExpression&&(c.readonly=t0(c.meta.readonlyExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),tf(c,"repeating")&&!ts(c.questionOptions.repeatOptions?.limitExpression)&&(c.questionOptions.repeatOptions.limit=t0(c.questionOptions.repeatOptions?.limitExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),u(c)}}),e.sectionDependents&&e.sectionDependents.forEach(e=>{for(let n=0;n<l.pages.length;n++){let a=l.pages[n].sections.find(t=>t.label==e);if(a){t8({value:a,type:"section"},i,t,r,o,t0,u),f=!0;break}}}),e.pageDependents&&e.pageDependents?.forEach(e=>{t8({value:l.pages.find(t=>t.label==e),type:"page"},i,t,r,o,t0,u),f=!0}),f&&c(l)}function nf(e,t,n,r){let i=[],o=[];if(e.meta.submission?.unspecified)return{errors:[],warnings:[]};try{e.validators.forEach(a=>{let l=n[a.type]?.validate?.(e,t,{...a,...r});l&&l.forEach(e=>{"error"===e.resultType?i.push(e):"warning"===e.resultType&&o.push(e)})})}catch(e){console.error(e)}return{errors:i,warnings:o}}var np=n(1809);let nm=f().createContext(void 0),nh=({methods:e,children:t,...n})=>f().createElement(nm.Provider,{value:{...n,methods:e}},t),ng=()=>{let e=f().useContext(nm);if(!e)throw Error("FormProviderContext must be used within a FormProviderContext");return e},ny="-esm-form-engine__value__value___ltyQT",nv="-esm-form-engine__value__item___2GHPw",nb="-esm-form-engine__value__empty___hEe5L",n_=()=>{let{t:e}=(0,e9.useTranslation)();return f().createElement("div",null,f().createElement("span",{className:nb},"(",e("blank","Blank"),")"))},nw=({value:e})=>Array.isArray(e)?f().createElement(nx,{valueArray:e}):f().createElement("div",{className:ny},e),nx=({valueArray:e})=>f().createElement("ul",null,e.map(e=>f().createElement("li",{className:nv},e))),nE="-esm-form-engine__previous-value-review__formField___usT6m",nk="-esm-form-engine__previous-value-review__row___uDsJL",nS="-esm-form-engine__previous-value-review__value___ySFyl",nO="-esm-form-engine__previous-value-review__reuseButton___n4XbJ",nD=({previousValue:e,displayText:t,field:n,hideHeader:r,onAfterChange:i})=>{let{t:o}=(0,e9.useTranslation)(),{methods:{setValue:a}}=ng(),l=t=>{t.preventDefault(),a(n.id,e),i(e)};return f().createElement("div",{className:nE},f().createElement("div",{className:nk},!r&&f().createElement("div",null,o("previousValue","Previous value:")),f().createElement("div",{className:nS},f().createElement(nw,{value:t}))),f().createElement("div",{className:nO,role:"button",tabIndex:0,onClick:l},o("reuseValue","Reuse value")))},nC="-esm-form-engine__unspecified__unspecified___kJgif",nF=({field:e,fieldValue:t,setFieldValue:n,onAfterChange:r})=>{let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)(!1),{sessionMode:l,updateFormField:s}=ng();(0,d.useEffect)(()=>{ts(t)&&"edit"===l&&(a(!0),e.meta.submission||(e.meta.submission={}),e.meta.submission.unspecified=!0)},[]),(0,d.useEffect)(()=>{e.meta.submission?.unspecified&&(e.meta.submission.newValue||!ts(t))&&(e.meta.submission.unspecified=!1,s(e)),a(!!e.meta.submission?.unspecified)},[e.meta?.submission,e.meta.submission?.unspecified,t]);let u=(0,d.useCallback)(t=>{let i=e.questionOptions.rendering;if(t.target.checked){a(!0);let t="checkbox"===i?[]:"";tp(e),e.meta.submission.unspecified=!0,e.meta.submission.errors=[],e.meta.submission.warnings=[],s(e),n(t),r(t)}else a(!1),e.meta.submission.unspecified=!1,s(e)},[e.questionOptions.rendering]);return!e.isHidden&&!(0,np.H)(e.readonly)&&!tg(l)&&f().createElement("div",{className:nC},f().createElement(y.Checkbox,{id:`${e.id}-unspecified`,labelText:i("unspecified","Unspecified"),value:i("unspecified","Unspecified"),onChange:u,checked:o,disabled:e.isDisabled}))};function nA(e,t,n,r){return!("embedded-view"===e&&n&&(t||r))}let nP="-esm-form-engine__form-field-renderer__unspecifiedContainer___MoH57",nT=({fieldId:e,valueAdapter:t,repeatOptions:n})=>{let[r,i]=(0,d.useState)(null),[o,a]=(0,d.useState)([]),[l,s]=(0,d.useState)([]),[c,p]=(0,d.useState)(null),m=ng(),h=!1;try{let e=(0,u.useConfig)({externalModuleName:"@openmrs/esm-form-engine-app"});h=e?.hideUnansweredQuestionsInReadonlyForms??!1}catch(e){console.warn("Failed to load @openmrs/esm-form engine-app config - using hideUnansweredQuestionsInReadonlyForms=false (empty fields will be visible in readonly mode): ",e)}let{methods:{control:y,getValues:v,getFieldState:b},patient:_,sessionMode:w,formFields:x,formFieldValidators:E,addInvalidField:k,removeInvalidField:S,updateFormField:O}=m,D=(0,d.useRef)(null),C=ef({control:y,name:e,exact:!0}),F=()=>{},A=(0,d.useMemo)(()=>x.find(t=>t.id===e),[e,x]);(0,d.useEffect)(()=>{if(tf(A,"repeating")&&n?.targetRendering?dk(n.targetRendering).then(e=>{e&&i({value:e})}):dS(A).then(e=>{e&&i({value:e})}),"enter"===w&&(A.historicalExpression||m.previousDomainObjectValue))try{m.processor.getHistoricalValue(A,m).then(e=>{p(e)})}catch(e){console.error(e)}},[]),(0,d.useEffect)(()=>{let{isDirty:e,isTouched:n}=b(A.id),{submission:r,unspecified:i}=A.meta,{calculate:o,defaultValue:a}=A.questionOptions;!ts(C)&&!r?.newValue&&!e&&!i&&(o?.calculateExpression||a)&&t.transformFieldValue(A,C,m);let l=D.current;D.current=null,(e||n)&&(!l||!(0,g.A)(l.value,C))&&P(C)},[C]),(0,d.useEffect)(()=>{A.meta.submission?.errors&&a(A.meta.submission.errors),A.meta.submission?.warnings&&s(A.meta.submission.warnings),A.meta.submission?.unspecified&&(a([]),S(A.id))},[A.meta.submission]);let P=e=>{A.meta.submission?.unspecified&&!ts(e)&&(A.meta.submission.unspecified=!1);let{errors:n,warnings:r}=nf(A,e,E,{formFields:x,values:v(),expressionContext:{patient:_,mode:w}});if(A.meta.submission&&(A.meta.submission.errors=void 0,A.meta.submission.warnings=void 0),o.length&&!n.length?(S(A.id),a([])):n.length&&(a(n),k(A)),n.length||t.transformFieldValue(A,e,m),s(r),nu(A,m),A.meta.groupId){let e=x.find(e=>e.id===A.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===A.id?A:e),O(e))}},T=e=>{D.current={value:e},P(e)};if(!r)return null;let V=r.value;return!n?.targetRendering&&nj(A.questionOptions.rendering)?f().createElement(V,{key:A.id,field:A,value:null,errors:o,warnings:l,setFieldValue:null}):nA(w,!!A.questionOptions.isTransient,ts(C),h)?f().createElement(te,{FallbackComponent:nV,onReset:F},f().createElement(em,{control:y,name:A.id,render:({field:{value:e,onChange:t,onBlur:n}})=>f().createElement("div",null,f().createElement(V,{key:`${A.id}-input-component`,field:A,value:e,errors:o,warnings:l,setFieldValue:e=>{t(e),T(e),n()}}),nM(A)&&f().createElement("div",{className:nP},A.unspecified&&f().createElement(nF,{key:`${A.id}-unspecified`,field:A,setFieldValue:t,onAfterChange:T,fieldValue:e})),c?.value&&f().createElement("div",null,f().createElement(nD,{key:`${A.id}-previous-value-review`,previousValue:c.value,displayText:c.display,onAfterChange:T,field:A})))})):null};function nV({error:e}){let{t}=(0,e9.useTranslation)();return f().createElement(y.ToastNotification,{"aria-label":t("closesNotification","Closes notification"),caption:"",hideCloseButton:!0,lowContrast:!0,onClose:function(){},onCloseButtonClick:function(){},statusIconDescription:t("notification","Notification"),subtitle:e.message,title:t("errorRenderingField","Error rendering field")})}function nM(e){let{rendering:t}=e.questionOptions;return(0,np.H)(e.unspecified)&&"toggle"!=t&&"group"!=t&&"repeating"!=t&&"markdown"!=t&&"extension-widget"!=t&&"workspace-launcher"!=t}function nj(e){return"group"===e||"repeating"===e}let nI=({field:e,...t})=>{let{t:n}=(0,e9.useTranslation)(),{formFieldAdapters:r,formFields:i}=ng(),o=(0,d.useMemo)(()=>e.questions.map(e=>i.find(t=>t.id===e.id)).filter(e=>!e.isHidden).map((n,i)=>{let o=`${n.id}_${i}`;return n.id===e.id?f().createElement(nV,{error:Error("ObsGroup child has same id as parent question")}):"obsGroup"===n.type&&nj(n.questionOptions.rendering)?f().createElement("div",{key:o,className:h.nestedGroupContainer},f().createElement(nI,{field:n,...t})):r[n.type]?f().createElement("div",{className:m()(h.flexColumn),key:o},f().createElement("div",{className:h.groupContainer},f().createElement(nT,{fieldId:n.id,valueAdapter:r[n.type]}))):void 0}),[e,i]);return f().createElement("div",{className:h.groupContainer},o.length>1?f().createElement(y.FormGroup,{legendText:n(e.label),className:h.boldLegend},o):o)},nN=nI,nL="-esm-form-engine__label__label___d9pB3",nq=({value:e,tooltipText:t})=>f().createElement("div",{className:nL},f().createElement(y.DefinitionTooltip,{autoAlign:!0,tabIndex:0,definition:t??""},f().createElement("span",{className:"cds--label"},`${e}:`))),nR="-esm-form-engine__field-value-view__formField___aiANn",n$="-esm-form-engine__field-value-view__readonly___4EhBN",nB="-esm-form-engine__field-value-view__value___cgPr1",nH="-esm-form-engine__field-value-view__inlineFlexRow___Rk2F-",nz="-esm-form-engine__field-value-view__inlineFlexColumn___Yd9Fp",nU=({label:e,conceptName:t,value:n,isInline:r})=>f().createElement(f().Fragment,null,r?f().createElement("div",{className:nH},f().createElement("div",{className:nz},f().createElement(nq,{value:e,tooltipText:t})),f().createElement("div",{className:nz},ts(n)?f().createElement(n_,null):f().createElement(nw,{value:n}))):f().createElement("div",{className:n$},f().createElement("div",{className:nR},f().createElement(nq,{value:e,tooltipText:t}),f().createElement("div",{className:nB},ts(n)?f().createElement(n_,null):f().createElement(nw,{value:n}))))),nW="-esm-form-engine__content-switcher__formField___vZnsA",nY="-esm-form-engine__content-switcher__errorLegend___JGh37",nJ="-esm-form-engine__content-switcher__boldedLegend___DEeyj",nZ="-esm-form-engine__content-switcher__selectedOption___KMGst";var nG=n(4807);let nQ="-esm-form-engine__field-label__required___QIc-5",nK="-esm-form-engine__field-label__questionLabel___mFOqM",nX="-esm-form-engine__field-label__tooltipIcon___vCSZl",n0=({field:e,children:t})=>{let{t:n}=(0,e9.useTranslation)();return e.questionInfo?f().createElement(y.Tooltip,{autoAlign:!0,label:n(e.questionInfo)},f().createElement("div",null,t)):f().createElement(f().Fragment,null,t)},n1=({field:e,customLabel:t})=>{let{t:n}=(0,e9.useTranslation)(),r=!!e.questionInfo,i=t||n(e.label);return f().createElement(n0,{field:e},f().createElement("div",{className:nK,"data-testid":`${e.id}-label`},f().createElement("span",null,i),e.isRequired&&f().createElement("span",{title:n("required","Required"),className:nQ},"*"),r&&f().createElement(nG.$$,{size:16,"aria-hidden":"true",className:nX,"data-testid":`${e.id}-information-icon`})))},n2=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),c=(0,d.useCallback)(e=>{i(e.name)},[i]),p=(0,d.useMemo)(()=>e.questionOptions.answers.filter(e=>!e.isHidden),[e.questionOptions.answers]),h=(0,d.useMemo)(()=>p.findIndex(e=>e.concept==t),[t,p]),g=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,np.H)(e.readonly)?f().createElement("div",{className:nW},f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:g})):!e.isHidden&&f().createElement(y.FormGroup,{legendText:f().createElement("div",{className:nJ},f().createElement(n1,{field:e})),className:m()({[nY]:n.length>0,[nJ]:0===n.length})},f().createElement(y.ContentSwitcher,{onChange:c,selectedIndex:h,className:nZ,size:"md"},p.map((t,n)=>f().createElement(y.Switch,{name:t.concept||t.value,text:o(t.label),key:n,disabled:e.isDisabled}))))},n4="-esm-form-engine__date__datePickerWarn___GDUCO",n5="-esm-form-engine__date__datePickerLabel___gCHIg",n3="-esm-form-engine__date__boldedLabel___cGCdn",n6="-esm-form-engine__date__datetime___z+i2e",n9="-esm-form-engine__date__datePickerSpacing___Lprw3",n7="-esm-form-engine__date__timeInput___E1vhw",n8=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),[a,l]=(0,d.useState)(""),{layoutType:s,sessionMode:c,workspaceLayout:p}=ng(),h=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(c)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,s,p,c),[c,e.readonly,e.inlineRendering,s,p]),g=(0,d.useCallback)(e=>{v(e,a),i(e)},[i,a]),v=(0,d.useCallback)((e,t)=>{if(!ts(t)){let[n,r]=t.split(":").map(Number);e.setHours(n??0,r??0)}},[]),b=(0,d.useCallback)(n=>{let r=n.target.value;l(r);let o="timer"===e.datePickerFormat?new Date:new Date(t);v(o,r),i(o)},[i,v,t]);(0,d.useEffect)(()=>{t&&t instanceof Date&&l([10>t.getHours()?`0${t.getHours()}`:`${t.getHours()}`,10>t.getMinutes()?`0${t.getMinutes()}`:`${t.getMinutes()}`].join(":"))},[t]);let _=(0,d.useMemo)(()=>"timer"===e.datePickerFormat?f().createElement(n1,{field:e}):f().createElement(n1,{field:e,customLabel:o("time","Time")}),[e.datePickerFormat,e.label,o]);return"view"==c||"embedded-view"==c||(0,np.H)(e.readonly)?f().createElement(nU,{label:o(e.label),value:t instanceof Date?tb(e,t):t,conceptName:e.meta?.concept?.display,isInline:h}):!e.isHidden&&f().createElement("div",{className:n6},("calendar"===e.datePickerFormat||"both"===e.datePickerFormat)&&f().createElement("div",{className:n9},f().createElement(y.Layer,null,f().createElement(u.OpenmrsDatePicker,{id:e.id,onChange:g,labelText:f().createElement("span",{className:n5},f().createElement(n1,{field:e})),isDisabled:e.isDisabled,isReadOnly:(0,np.H)(e.readonly),isRequired:e.isRequired??!1,isInvalid:n.length>0,invalidText:n[0]?.message,value:t})),r.length>0?f().createElement("div",{className:n4},r[0]?.message):null),"both"===e.datePickerFormat||"timer"===e.datePickerFormat?f().createElement("div",null,f().createElement(y.Layer,null,f().createElement(y.TimePicker,{className:m()(n3,n7),id:e.id,labelText:_,placeholder:"HH:MM",pattern:"(1[012]|[1-9]):[0-5][0-9]$",type:"time",disabled:"timer"===e.datePickerFormat?e.isDisabled:!t,invalid:n.length>0,invalidText:n[0]?.message,readOnly:(0,np.H)(e.readonly),warning:r.length>0,warningText:r[0]?.message,value:a||(t instanceof Date?t.toLocaleDateString(window.navigator.language):t),onChange:b}))):null)},re=({field:e,setFieldValue:t})=>{let n=ng();return(0,d.useEffect)(()=>{e.meta?.initialValue?.omrsObject||ts(e.meta.fixedValue)||(t(e.meta.fixedValue),n.formFieldAdapters[e.type].transformFieldValue(e,e.meta.fixedValue,n))},[]),f().createElement(f().Fragment,null)};function rt(e,t){let n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}let rn=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rr=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ri={};function ro(e,t){return((t||ri).jsx?rr:rn).test(e)}let ra=/[ \t\n\f\r]/g;function rl(e){return"object"==typeof e?"text"===e.type&&rs(e.value):rs(e)}function rs(e){return""===e.replace(ra,"")}class ru{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function rc(e,t){let n={},r={},i=-1;for(;++i<e.length;)Object.assign(n,e[i].property),Object.assign(r,e[i].normal);return new ru(n,r,t)}function rd(e){return e.toLowerCase()}ru.prototype.property={},ru.prototype.normal={},ru.prototype.space=null;class rf{constructor(e,t){this.property=e,this.attribute=t}}rf.prototype.space=null,rf.prototype.boolean=!1,rf.prototype.booleanish=!1,rf.prototype.overloadedBoolean=!1,rf.prototype.number=!1,rf.prototype.commaSeparated=!1,rf.prototype.spaceSeparated=!1,rf.prototype.commaOrSpaceSeparated=!1,rf.prototype.mustUseProperty=!1,rf.prototype.defined=!1;let rp=0,rm=rw(),rh=rw(),rg=rw(),ry=rw(),rv=rw(),rb=rw(),r_=rw();function rw(){return 2**++rp}let rx=Object.keys(i);class rE extends rf{constructor(e,t,n,r){let o=-1;if(super(e,t),rk(this,"space",r),"number"==typeof n)for(;++o<rx.length;){const e=rx[o];rk(this,rx[o],(n&i[e])===i[e])}}}function rk(e,t,n){n&&(e[t]=n)}rE.prototype.defined=!0;let rS={}.hasOwnProperty;function rO(e){let t,n={},r={};for(t in e.properties)if(rS.call(e.properties,t)){let i=e.properties[t],o=new rE(t,e.transform(e.attributes||{},t),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(t)&&(o.mustUseProperty=!0),n[t]=o,r[rd(t)]=t,r[rd(o.attribute)]=t}return new ru(n,r,e.space)}let rD=rO({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),rC=rO({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function rF(e,t){return t in e?e[t]:t}function rA(e,t){return rF(e,t.toLowerCase())}let rP=rO({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:rA,properties:{xmlns:null,xmlnsXLink:null}}),rT=rO({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:rh,ariaAutoComplete:null,ariaBusy:rh,ariaChecked:rh,ariaColCount:ry,ariaColIndex:ry,ariaColSpan:ry,ariaControls:rv,ariaCurrent:null,ariaDescribedBy:rv,ariaDetails:null,ariaDisabled:rh,ariaDropEffect:rv,ariaErrorMessage:null,ariaExpanded:rh,ariaFlowTo:rv,ariaGrabbed:rh,ariaHasPopup:null,ariaHidden:rh,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rv,ariaLevel:ry,ariaLive:null,ariaModal:rh,ariaMultiLine:rh,ariaMultiSelectable:rh,ariaOrientation:null,ariaOwns:rv,ariaPlaceholder:null,ariaPosInSet:ry,ariaPressed:rh,ariaReadOnly:rh,ariaRelevant:null,ariaRequired:rh,ariaRoleDescription:rv,ariaRowCount:ry,ariaRowIndex:ry,ariaRowSpan:ry,ariaSelected:rh,ariaSetSize:ry,ariaSort:null,ariaValueMax:ry,ariaValueMin:ry,ariaValueNow:ry,ariaValueText:null,role:null}}),rV=rO({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:rA,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:rb,acceptCharset:rv,accessKey:rv,action:null,allow:null,allowFullScreen:rm,allowPaymentRequest:rm,allowUserMedia:rm,alt:null,as:null,async:rm,autoCapitalize:null,autoComplete:rv,autoFocus:rm,autoPlay:rm,capture:rm,charSet:null,checked:rm,cite:null,className:rv,cols:ry,colSpan:null,content:null,contentEditable:rh,controls:rm,controlsList:rv,coords:ry|rb,crossOrigin:null,data:null,dateTime:null,decoding:null,default:rm,defer:rm,dir:null,dirName:null,disabled:rm,download:rg,draggable:rh,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:rm,formTarget:null,headers:rv,height:ry,hidden:rm,high:ry,href:null,hrefLang:null,htmlFor:rv,httpEquiv:rv,id:null,imageSizes:null,imageSrcSet:null,inputMode:null,integrity:null,is:null,isMap:rm,itemId:null,itemProp:rv,itemRef:rv,itemScope:rm,itemType:rv,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:rm,low:ry,manifest:null,max:null,maxLength:ry,media:null,method:null,min:null,minLength:ry,multiple:rm,muted:rm,name:null,nonce:null,noModule:rm,noValidate:rm,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:rm,optimum:ry,pattern:null,ping:rv,placeholder:null,playsInline:rm,poster:null,preload:null,readOnly:rm,referrerPolicy:null,rel:rv,required:rm,reversed:rm,rows:ry,rowSpan:ry,sandbox:rv,scope:null,scoped:rm,seamless:rm,selected:rm,shape:null,size:ry,sizes:null,slot:null,span:ry,spellCheck:rh,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ry,step:null,style:null,tabIndex:ry,target:null,title:null,translate:null,type:null,typeMustMatch:rm,useMap:null,value:rh,width:ry,wrap:null,align:null,aLink:null,archive:rv,axis:null,background:null,bgColor:null,border:ry,borderColor:null,bottomMargin:ry,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:rm,declare:rm,event:null,face:null,frame:null,frameBorder:null,hSpace:ry,leftMargin:ry,link:null,longDesc:null,lowSrc:null,marginHeight:ry,marginWidth:ry,noResize:rm,noHref:rm,noShade:rm,noWrap:rm,object:null,profile:null,prompt:null,rev:null,rightMargin:ry,rules:null,scheme:null,scrolling:rh,standby:null,summary:null,text:null,topMargin:ry,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ry,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:rm,disableRemotePlayback:rm,prefix:null,property:null,results:ry,security:null,unselectable:null}}),rM=rO({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:rF,properties:{about:r_,accentHeight:ry,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ry,amplitude:ry,arabicForm:null,ascent:ry,attributeName:null,attributeType:null,azimuth:ry,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ry,by:null,calcMode:null,capHeight:ry,className:rv,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ry,diffuseConstant:ry,direction:null,display:null,dur:null,divisor:ry,dominantBaseline:null,download:rm,dx:null,dy:null,edgeMode:null,editable:null,elevation:ry,enableBackground:null,end:null,event:null,exponent:ry,externalResourcesRequired:null,fill:null,fillOpacity:ry,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:rb,g2:rb,glyphName:rb,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ry,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ry,horizOriginX:ry,horizOriginY:ry,id:null,ideographic:ry,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ry,k:ry,k1:ry,k2:ry,k3:ry,k4:ry,kernelMatrix:r_,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ry,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ry,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ry,overlineThickness:ry,paintOrder:null,panose1:null,path:null,pathLength:ry,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rv,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ry,pointsAtY:ry,pointsAtZ:ry,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:r_,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:r_,rev:r_,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:r_,requiredFeatures:r_,requiredFonts:r_,requiredFormats:r_,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ry,specularExponent:ry,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ry,strikethroughThickness:ry,string:null,stroke:null,strokeDashArray:r_,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ry,strokeOpacity:ry,strokeWidth:null,style:null,surfaceScale:ry,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:r_,tabIndex:ry,tableValues:null,target:null,targetX:ry,targetY:ry,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:r_,to:null,transform:null,u1:null,u2:null,underlinePosition:ry,underlineThickness:ry,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ry,values:null,vAlphabetic:ry,vMathematical:ry,vectorEffect:null,vHanging:ry,vIdeographic:ry,version:null,vertAdvY:ry,vertOriginX:ry,vertOriginY:ry,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ry,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),rj=rc([rC,rD,rP,rT,rV],"html"),rI=rc([rC,rD,rP,rT,rM],"svg"),rN=/^data[-\w.:]+$/i,rL=/-[a-z]/g,rq=/[A-Z]/g;function rR(e,t){let n=rd(t),r=t,i=rf;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&rN.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(rL,rB);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!rL.test(e)){let n=e.replace(rq,r$);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=rE}return new i(r,t)}function r$(e){return"-"+e.toLowerCase()}function rB(e){return e.charAt(1).toUpperCase()}let rH={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};function rz(e){return e.join(" ").trim()}var rU=n(8052);let rW=rU.default||rU,rY=rZ("end"),rJ=rZ("start");function rZ(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function rG(e){let t=rJ(e),n=rY(e);if(t&&n)return{start:t,end:n}}function rQ(e){return e&&"object"==typeof e?"position"in e||"type"in e?rX(e.position):"start"in e||"end"in e?rX(e):"line"in e||"column"in e?rK(e):"":""}function rK(e){return r0(e&&e.line)+":"+r0(e&&e.column)}function rX(e){return rK(e&&e.start)+"-"+rK(e&&e.end)}function r0(e){return e&&"number"==typeof e?e:1}class r1 extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=rQ(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual,this.expected,this.note,this.url}}r1.prototype.file="",r1.prototype.name="",r1.prototype.reason="",r1.prototype.message="",r1.prototype.stack="",r1.prototype.column=void 0,r1.prototype.line=void 0,r1.prototype.ancestors=void 0,r1.prototype.cause=void 0,r1.prototype.fatal=void 0,r1.prototype.place=void 0,r1.prototype.ruleId=void 0,r1.prototype.source=void 0;let r2={}.hasOwnProperty,r4=new Map,r5=/[A-Z]/g,r3=/-([a-z])/g,r6=new Set(["table","tbody","thead","tfoot","tr"]),r9=new Set(["td","th"]),r7="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function r8(e,t){let n;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let r=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=id(r,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");n=ic(r,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?rI:rj,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},o=ie(i,e,void 0);return o&&"string"!=typeof o?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function ie(e,t,n){return"element"===t.type?it(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?ir(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?io(e,t,n):"mdxjsEsm"===t.type?ii(e,t):"root"===t.type?ia(e,t,n):"text"===t.type?il(e,t):void 0}function it(e,t,n){let r=e.schema;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(e.schema=rI),e.ancestors.push(t);let i=iv(e,t.tagName,!1),o=ip(e,t),a=ih(e,t);return r6.has(t.tagName)&&(a=a.filter(function(e){return"string"!=typeof e||!rl(e)})),is(e,o,i,t),iu(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function ir(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ib(e,t.position)}function ii(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ib(e,t.position)}function io(e,t,n){let r=e.schema;"svg"===t.name&&"html"===r.space&&(e.schema=rI),e.ancestors.push(t);let i=null===t.name?e.Fragment:iv(e,t.name,!0),o=im(e,t),a=ih(e,t);return is(e,o,i,t),iu(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function ia(e,t,n){let r={};return iu(r,ih(e,t)),e.create(t,e.Fragment,r,n)}function il(e,t){return t.value}function is(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function iu(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function ic(e,t,n){return r;function r(e,r,i,o){let a=Array.isArray(i.children)?n:t;return o?a(r,i,o):a(r,i)}}function id(e,t){return n;function n(n,r,i,o){let a=Array.isArray(i.children),l=rJ(n);return t(r,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function ip(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&r2.call(t.properties,r)){let o=ig(e,r,t.properties[r]);if(o){let[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&r9.has(t.tagName)?n=a:i[r]=a}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}function im(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let o=i.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else ib(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,i=e.evaluater.evaluateExpression(t.expression)}else ib(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}function ih(e,t){let n=[],r=-1,i=e.passKeys?new Map:r4;for(;++r<t.children.length;){let o,a=t.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let l=ie(e,a,o);void 0!==l&&n.push(l)}return n}function ig(e,t,n){let r=rR(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?rt(n):rz(n)),"style"===r.property){let t="object"==typeof n?n:iy(e,String(n));return"css"===e.stylePropertyNameCase&&(t=i_(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?rH[r.property]||r.property:r.attribute,n]}}function iy(e,t){let n={};try{rW(t,r)}catch(t){if(!e.ignoreInvalidStyle){let n=t,r=new r1("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=r7+"#cannot-parse-style-attribute",r}}return n;function r(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(r3,ix)),n[r]=t}}function iv(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=ro(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}r=e}else r=ro(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return r2.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ib(e)}function ib(e,t){let n=new r1("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=r7+"#cannot-handle-mdx-estrees-without-createevaluater",n}function i_(e){let t,n={};for(t in e)r2.call(e,t)&&(n[iw(t)]=e[t]);return n}function iw(e){let t=e.replace(r5,iE);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function ix(e,t){return t.toUpperCase()}function iE(e){return"-"+e.toLowerCase()}let ik={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};var iS=n(1085);let iO={};function iD(e,t){let n=t||iO;return iC(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function iC(e,t,n){if(iA(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return iF(e.children,t,n)}return Array.isArray(e)?iF(e,t,n):""}function iF(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=iC(e[i],t,n);return r.join("")}function iA(e){return!!(e&&"object"==typeof e)}function iP(e,t,n,r){let i,o=e.length,a=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function iT(e,t){return e.length>0?(iP(e,e.length,0,t),e):t}class iV{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&iM(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),iM(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),iM(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);iM(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);iM(this.left,t.reverse())}}}function iM(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ij(e){let t,n,r,i,o,a,l,s={},u=-1,c=new iV(e);for(;++u<c.length;){for(;u in s;)u=s[u];if(t=c.get(u),u&&"chunkFlow"===t[1].type&&"listItemPrefix"===c.get(u-1)[1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(s,iI(c,u)),u=s[u],l=!0);else if(t[1]._container){for(r=u,n=void 0;r--;)if("lineEnding"===(i=c.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(c.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else break;n&&(t[1].end={...c.get(n)[1].start},(o=c.slice(n,u)).unshift(t),c.splice(n,u-n+1,o))}}return iP(e,0,1/0,c.slice(0)),!l}function iI(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],a=t-1,l=[],s=i._tokenizer||o.parser[i.contentType](i.start),u=s.events,c=[],d={},f=-1,p=i,m=0,h=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(n),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++f<u.length;)"exit"===u[f][0]&&"enter"===u[f-1][0]&&u[f][1].type===u[f-1][1].type&&u[f][1].start.line!==u[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=u.slice(g[f],g[f+1]),n=l.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)d[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return d}function iN(e){for(;!ij(e););return e}let iL={}.hasOwnProperty;function iq(e){let t={},n=-1;for(;++n<e.length;)iR(t,e[n]);return t}function iR(e,t){let n;for(n in t){let r,i=(iL.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){iL.call(i,r)||(i[r]=[]);let e=o[r];i$(i[r],Array.isArray(e)?e:e?[e]:[])}}}function i$(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);iP(e,0,0,r)}let iB=i0(/[A-Za-z]/),iH=i0(/[\dA-Za-z]/),iz=i0(/[#-'*+\--9=?A-Z^-~]/);function iU(e){return null!==e&&(e<32||127===e)}let iW=i0(/\d/),iY=i0(/[\dA-Fa-f]/),iJ=i0(/[!-/:-@[-`{-~]/);function iZ(e){return null!==e&&e<-2}function iG(e){return null!==e&&(e<0||32===e)}function iQ(e){return -2===e||-1===e||32===e}let iK=i0(/\p{P}|\p{S}/u),iX=i0(/\s/);function i0(e){return t;function t(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function i1(e,t,n,r){let i=r?r-1:1/0,o=0;return a;function a(r){return iQ(r)?(e.enter(n),l(r)):t(r)}function l(r){return iQ(r)&&o++<i?(e.consume(r),l):(e.exit(n),t(r))}}let i2={tokenize:i4};function i4(e){let t,n=e.attempt(this.parser.constructs.contentInitial,r,i);return n;function r(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,n,"linePrefix"))}function i(t){return e.enter("paragraph"),o(t)}function o(n){let r=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=r),t=r,a(n)}function a(t){if(null===t){e.exit("chunkText"),e.exit("paragraph"),e.consume(t);return}return iZ(t)?(e.consume(t),e.exit("chunkText"),o):(e.consume(t),a)}}let i5={tokenize:i6},i3={tokenize:i9};function i6(e){let t,n,r,i=this,o=[],a=0;return l;function l(t){if(a<o.length){let n=o[a];return i.containerState=n[1],e.attempt(n[0].continuation,s,u)(t)}return u(t)}function s(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&v();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}y(a);let l=r;for(;l<i.events.length;)i.events[l][1].end={...n},l++;return iP(i.events,o+1,0,i.events.slice(r)),i.events.length=l,u(e)}return l(e)}function u(n){if(a===o.length){if(!t)return f(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(i3,c,d)(n)}function c(e){return t&&v(),y(a),f(e)}function d(e){return i.parser.lazy[i.now().line]=a!==o.length,r=i.now().offset,m(e)}function f(t){return i.containerState={},e.attempt(i3,p,m)(t)}function p(e){return a++,o.push([i.currentConstruct,i.containerState]),f(e)}function m(r){if(null===r){t&&v(),y(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),h(r)}function h(t){if(null===t){g(e.exit("chunkFlow"),!0),y(0),e.consume(t);return}return iZ(t)?(e.consume(t),g(e.exit("chunkFlow")),a=0,i.interrupt=void 0,l):(e.consume(t),h)}function g(e,o){let l=i.sliceStream(e);if(o&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let l=i.events.length,s=l;for(;s--;)if("exit"===i.events[s][0]&&"chunkFlow"===i.events[s][1].type){if(e){n=i.events[s][1].end;break}e=!0}for(y(a),o=l;o<i.events.length;)i.events[o][1].end={...n},o++;iP(i.events,s+1,0,i.events.slice(l)),i.events.length=o}}function y(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function v(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}function i9(e,t,n){return i1(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}let i7={partial:!0,tokenize:i8};function i8(e,t,n){return r;function r(t){return iQ(t)?i1(e,i,"linePrefix")(t):i(t)}function i(e){return null===e||iZ(e)?t(e):n(e)}}let oe={resolve:on,tokenize:or},ot={partial:!0,tokenize:oi};function on(e){return ij(e),e}function or(e,t){let n;return r;function r(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(t)}function i(t){return null===t?o(t):iZ(t)?e.check(ot,a,o)(t):(e.consume(t),i)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function oi(e,t,n){let r=this;return i;function i(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,o,"linePrefix")}function o(i){if(null===i||iZ(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}let oo={tokenize:oa};function oa(e){let t=this,n=e.attempt(i7,r,e.attempt(this.parser.constructs.flowInitial,i,i1(e,e.attempt(this.parser.constructs.flow,i,e.attempt(oe,i)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)}function i(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}let ol={resolveAll:od()},os=oc("string"),ou=oc("text");function oc(e){return{resolveAll:od("text"===e?of:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,a);return o;function o(e){return s(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return s(e)?(t.exit("data"),i(e)):(t.consume(e),l)}function s(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function od(e){return t;function t(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function of(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),a=o.length,l=-1,s=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)s++,l--;if(l)break;l=-1}else if(-2===e)r=!0,s++;else if(-1===e);else{a++;break}}if(s){let o={type:n===e.length||r||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:i.start._bufferIndex+l,_index:i.start._index+a,line:i.end.line,column:i.end.column-s,offset:i.end.offset-s},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}let op={name:"thematicBreak",tokenize:om};function om(e,t,n){let r,i=0;return o;function o(t){return e.enter("thematicBreak"),a(t)}function a(e){return r=e,l(e)}function l(o){return o===r?(e.enter("thematicBreakSequence"),s(o)):i>=3&&(null===o||iZ(o))?(e.exit("thematicBreak"),t(o)):n(o)}function s(t){return t===r?(e.consume(t),i++,s):(e.exit("thematicBreakSequence"),iQ(t)?i1(e,l,"whitespace")(t):l(t))}}let oh={continuation:{tokenize:ob},exit:ow,name:"list",tokenize:ov},og={partial:!0,tokenize:ox},oy={partial:!0,tokenize:o_};function ov(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:iW(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(op,n,u)(t):u(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(t)}return n(t)}function s(t){return iW(t)&&++a<10?(e.consume(t),s):(!r.interrupt||a<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),u(t)):n(t)}function u(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(i7,r.interrupt?n:c,e.attempt(og,f,d))}function c(e){return r.containerState.initialBlankLine=!0,o++,f(e)}function d(t){return iQ(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),f):n(t)}function f(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}function ob(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(i7,i,o);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,i1(e,t,"listItemIndent",r.containerState.size+1)(n)}function o(n){return r.containerState.furtherBlankLines||!iQ(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(oy,t,a)(n))}function a(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,i1(e,e.attempt(oh,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}function o_(e,t,n){let r=this;return i1(e,i,"listItemIndent",r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function ow(e){e.exit(this.containerState.type)}function ox(e,t,n){let r=this;return i1(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(e){let i=r.events[r.events.length-1];return!iQ(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)}}let oE={continuation:{tokenize:oS},exit:oO,name:"blockQuote",tokenize:ok};function ok(e,t,n){let r=this;return i;function i(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)}function o(n){return iQ(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}function oS(e,t,n){let r=this;return i;function i(t){return iQ(t)?i1(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)}function o(r){return e.attempt(oE,t,n)(r)}}function oO(e){e.exit("blockQuote")}function oD(e,t,n,r,i,o,a,l,s){let u=s||1/0,c=0;return d;function d(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),f):null===t||32===t||41===t||iU(t)?n(t):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),h(t))}function f(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(l),f(t)):null===t||60===t||iZ(t)?n(t):(e.consume(t),92===t?m:p)}function m(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function h(i){return!c&&(null===i||41===i||iG(i))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(i)):c<u&&40===i?(e.consume(i),c++,h):41===i?(e.consume(i),c--,h):null===i||32===i||40===i||iU(i)?n(i):(e.consume(i),92===i?g:h)}function g(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function oC(e,t,n,r,i,o){let a,l=this,s=0;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),c}function c(u){return s>999||null===u||91===u||93===u&&!a||94===u&&!s&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(o),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):iZ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||iZ(t)||s++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!iQ(t)),92===t?f:d)}function f(t){return 91===t||92===t||93===t?(e.consume(t),s++,d):d(t)}}function oF(e,t,n,r,i,o){let a;return l;function l(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,s):n(t)}function s(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),u(n))}function u(t){return t===a?(e.exit(o),s(a)):null===t?n(t):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===a||null===t||iZ(t)?(e.exit("chunkString"),u(t)):(e.consume(t),92===t?d:c)}function d(t){return t===a||92===t?(e.consume(t),c):c(t)}}function oA(e,t){let n;return r;function r(i){return iZ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):iQ(i)?i1(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function oP(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let oT={name:"definition",tokenize:oM},oV={partial:!0,tokenize:oj};function oM(e,t,n){let r,i=this;return o;function o(t){return e.enter("definition"),a(t)}function a(t){return oC.call(i,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}function l(t){return(r=oP(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return iG(t)?oA(e,u)(t):u(t)}function u(t){return oD(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function c(t){return e.attempt(oV,d,d)(t)}function d(t){return iQ(t)?i1(e,f,"whitespace")(t):f(t)}function f(o){return null===o||iZ(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}function oj(e,t,n){return r;function r(t){return iG(t)?oA(e,i)(t):n(t)}function i(t){return oF(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return iQ(t)?i1(e,a,"whitespace")(t):a(t)}function a(e){return null===e||iZ(e)?t(e):n(e)}}let oI={name:"codeIndented",tokenize:oL},oN={partial:!0,tokenize:oq};function oL(e,t,n){let r=this;return i;function i(t){return e.enter("codeIndented"),i1(e,o,"linePrefix",5)(t)}function o(e){let t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?a(e):n(e)}function a(t){return null===t?s(t):iZ(t)?e.attempt(oN,a,s)(t):(e.enter("codeFlowValue"),l(t))}function l(t){return null===t||iZ(t)?(e.exit("codeFlowValue"),a(t)):(e.consume(t),l)}function s(n){return e.exit("codeIndented"),t(n)}}function oq(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):i1(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):iZ(e)?i(e):n(e)}}let oR={name:"headingAtx",resolve:o$,tokenize:oB};function o$(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},iP(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e}function oB(e,t,n){let r=0;return i;function i(t){return e.enter("atxHeading"),o(t)}function o(t){return e.enter("atxHeadingSequence"),a(t)}function a(t){return 35===t&&r++<6?(e.consume(t),a):null===t||iG(t)?(e.exit("atxHeadingSequence"),l(t)):n(t)}function l(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||iZ(n)?(e.exit("atxHeading"),t(n)):iQ(n)?i1(e,l,"whitespace")(n):(e.enter("atxHeadingText"),u(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),l(t))}function u(t){return null===t||35===t||iG(t)?(e.exit("atxHeadingText"),l(t)):(e.consume(t),u)}}let oH={name:"setextUnderline",resolveTo:oz,tokenize:oU};function oz(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=a,e.push(["exit",a,t]),e}function oU(e,t,n){let r,i=this;return o;function o(t){let o,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){o="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||o)?(e.enter("setextHeadingLine"),r=t,a(t)):n(t)}function a(t){return e.enter("setextHeadingLineSequence"),l(t)}function l(t){return t===r?(e.consume(t),l):(e.exit("setextHeadingLineSequence"),iQ(t)?i1(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||iZ(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}let oW=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],oY=["pre","script","style","textarea"],oJ={concrete:!0,name:"htmlFlow",resolveTo:oQ,tokenize:oK},oZ={partial:!0,tokenize:o0},oG={partial:!0,tokenize:oX};function oQ(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oK(e,t,n){let r,i,o,a,l,s=this;return u;function u(e){return c(e)}function c(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),d}function d(a){return 33===a?(e.consume(a),f):47===a?(e.consume(a),i=!0,h):63===a?(e.consume(a),r=3,s.interrupt?t:I):iB(a)?(e.consume(a),o=String.fromCharCode(a),g):n(a)}function f(i){return 45===i?(e.consume(i),r=2,p):91===i?(e.consume(i),r=5,a=0,m):iB(i)?(e.consume(i),r=4,s.interrupt?t:I):n(i)}function p(r){return 45===r?(e.consume(r),s.interrupt?t:I):n(r)}function m(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?s.interrupt?t:C:m:n(r)}function h(t){return iB(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(a){if(null===a||47===a||62===a||iG(a)){let l=47===a,u=o.toLowerCase();return!l&&!i&&oY.includes(u)?(r=1,s.interrupt?t(a):C(a)):oW.includes(o.toLowerCase())?(r=6,l)?(e.consume(a),y):s.interrupt?t(a):C(a):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(a):i?v(a):b(a))}return 45===a||iH(a)?(e.consume(a),o+=String.fromCharCode(a),g):n(a)}function y(r){return 62===r?(e.consume(r),s.interrupt?t:C):n(r)}function v(t){return iQ(t)?(e.consume(t),v):O(t)}function b(t){return 47===t?(e.consume(t),O):58===t||95===t||iB(t)?(e.consume(t),_):iQ(t)?(e.consume(t),b):O(t)}function _(t){return 45===t||46===t||58===t||95===t||iH(t)?(e.consume(t),_):w(t)}function w(t){return 61===t?(e.consume(t),x):iQ(t)?(e.consume(t),w):b(t)}function x(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,E):iQ(t)?(e.consume(t),x):k(t)}function E(t){return t===l?(e.consume(t),l=null,S):null===t||iZ(t)?n(t):(e.consume(t),E)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||iG(t)?w(t):(e.consume(t),k)}function S(e){return 47===e||62===e||iQ(e)?b(e):n(e)}function O(t){return 62===t?(e.consume(t),D):n(t)}function D(t){return null===t||iZ(t)?C(t):iQ(t)?(e.consume(t),D):n(t)}function C(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),V):62===t&&4===r?(e.consume(t),N):63===t&&3===r?(e.consume(t),I):93===t&&5===r?(e.consume(t),j):iZ(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(oZ,L,F)(t)):null===t||iZ(t)?(e.exit("htmlFlowData"),F(t)):(e.consume(t),C)}function F(t){return e.check(oG,A,L)(t)}function A(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),P}function P(t){return null===t||iZ(t)?F(t):(e.enter("htmlFlowData"),C(t))}function T(t){return 45===t?(e.consume(t),I):C(t)}function V(t){return 47===t?(e.consume(t),o="",M):C(t)}function M(t){if(62===t){let n=o.toLowerCase();return oY.includes(n)?(e.consume(t),N):C(t)}return iB(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),M):C(t)}function j(t){return 93===t?(e.consume(t),I):C(t)}function I(t){return 62===t?(e.consume(t),N):45===t&&2===r?(e.consume(t),I):C(t)}function N(t){return null===t||iZ(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),N)}function L(n){return e.exit("htmlFlow"),t(n)}}function oX(e,t,n){let r=this;return i;function i(t){return iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):n(t)}function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function o0(e,t,n){return r;function r(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(i7,t,n)}}let o1={partial:!0,tokenize:o5},o2={concrete:!0,name:"codeFenced",tokenize:o4};function o4(e,t,n){let r,i=this,o={partial:!0,tokenize:w},a=0,l=0;return s;function s(e){return u(e)}function u(t){let n=i.events[i.events.length-1];return a=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,r=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(t)}function c(t){return t===r?(l++,e.consume(t),c):l<3?n(t):(e.exit("codeFencedFenceSequence"),iQ(t)?i1(e,d,"whitespace")(t):d(t))}function d(n){return null===n||iZ(n)?(e.exit("codeFencedFence"),i.interrupt?t(n):e.check(o1,h,_)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return null===t||iZ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(t)):iQ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),i1(e,p,"whitespace")(t)):96===t&&t===r?n(t):(e.consume(t),f)}function p(t){return null===t||iZ(t)?d(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||iZ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(t)):96===t&&t===r?n(t):(e.consume(t),m)}function h(t){return e.attempt(o,_,g)(t)}function g(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),y}function y(t){return a>0&&iQ(t)?i1(e,v,"linePrefix",a+1)(t):v(t)}function v(t){return null===t||iZ(t)?e.check(o1,h,_)(t):(e.enter("codeFlowValue"),b(t))}function b(t){return null===t||iZ(t)?(e.exit("codeFlowValue"),v(t)):(e.consume(t),b)}function _(n){return e.exit("codeFenced"),t(n)}function w(e,t,n){let o=0;return a;function a(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s}function s(t){return e.enter("codeFencedFence"),iQ(t)?i1(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):u(t)}function u(t){return t===r?(e.enter("codeFencedFenceSequence"),c(t)):n(t)}function c(t){return t===r?(o++,e.consume(t),c):o>=l?(e.exit("codeFencedFenceSequence"),iQ(t)?i1(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||iZ(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}}function o5(e,t,n){let r=this;return i;function i(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o)}function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}let o3=document.createElement("i");function o6(e){let t="&"+e+";";o3.innerHTML=t;let n=o3.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let o9={name:"characterReference",tokenize:o7};function o7(e,t,n){let r,i,o=this,a=0;return l;function l(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s}function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),r=31,i=iH,c(t))}function u(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=iY,c):(e.enter("characterReferenceValue"),r=7,i=iW,c(t))}function c(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return i!==iH||o6(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&a++<r?(e.consume(l),c):n(l)}}let o8={name:"characterEscape",tokenize:ae};function ae(e,t,n){return r;function r(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),i}function i(r){return iJ(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}let at={name:"lineEnding",tokenize:an};function an(e,t){return n;function n(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),i1(e,t,"linePrefix")}}function ar(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let ai={name:"labelEnd",resolveAll:as,resolveTo:au,tokenize:ac},ao={tokenize:ad},aa={tokenize:af},al={tokenize:ap};function as(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&iP(e,0,e.length,n),e}function au(e,t){let n,r,i,o,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(i=a);let s={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},c={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[i-2][1].start}};return o=iT(o=[["enter",s,t],["enter",u,t]],e.slice(r+1,r+l+3)),o=iT(o,[["enter",c,t]]),o=iT(o,ar(t.parser.constructs.insideSpan.null,e.slice(r+l+4,i-3),t)),o=iT(o,[["exit",c,t],e[i-2],e[i-1],["exit",u,t]]),o=iT(o,e.slice(i+1)),o=iT(o,[["exit",s,t]]),iP(e,r,e.length,o),e}function ac(e,t,n){let r,i,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return l;function l(t){return r?r._inactive?d(t):(i=o.parser.defined.includes(oP(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)}function s(t){return 40===t?e.attempt(ao,c,i?c:d)(t):91===t?e.attempt(aa,c,i?u:d)(t):i?c(t):d(t)}function u(t){return e.attempt(al,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}function ad(e,t,n){return r;function r(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),i}function i(t){return iG(t)?oA(e,o)(t):o(t)}function o(t){return 41===t?c(t):oD(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return iG(t)?oA(e,s)(t):c(t)}function l(e){return n(e)}function s(t){return 34===t||39===t||40===t?oF(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function u(t){return iG(t)?oA(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}function af(e,t,n){let r=this;return i;function i(t){return oC.call(r,e,o,a,"reference","referenceMarker","referenceString")(t)}function o(e){return r.parser.defined.includes(oP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}function ap(e,t,n){return r;function r(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),i}function i(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}let am={name:"labelStartImage",resolveAll:ai.resolveAll,tokenize:ah};function ah(e,t,n){let r=this;return i;function i(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o}function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}function ag(e){return null===e||iG(e)||iX(e)?1:iK(e)?2:void 0}let ay={name:"attention",resolveAll:av,tokenize:ab};function av(e,t){let n,r,i,o,a,l,s,u,c=-1;for(;++c<e.length;)if("enter"===e[c][0]&&"attentionSequence"===e[c][1].type&&e[c][1]._close){for(n=c;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[c][1]).charCodeAt(0)){if((e[n][1]._close||e[c][1]._open)&&(e[c][1].end.offset-e[c][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[c][1].end.offset-e[c][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[c][1].end.offset-e[c][1].start.offset>1?2:1;let d={...e[n][1].end},f={...e[c][1].start};a_(d,-l),a_(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[c][1].start},end:f},i={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[c][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[c][1].start={...a.end},s=[],e[n][1].end.offset-e[n][1].start.offset&&(s=iT(s,[["enter",e[n][1],t],["exit",e[n][1],t]])),s=iT(s,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),s=iT(s,ar(t.parser.constructs.insideSpan.null,e.slice(n+1,c),t)),s=iT(s,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[c][1].end.offset-e[c][1].start.offset?(u=2,s=iT(s,[["enter",e[c][1],t],["exit",e[c][1],t]])):u=0,iP(e,n-1,c-n+3,s),c=n+s.length-u-2;break}}for(c=-1;++c<e.length;)"attentionSequence"===e[c][1].type&&(e[c][1].type="data");return e}function ab(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ag(i);return a;function a(t){return n=t,e.enter("attentionSequence"),l(t)}function l(a){if(a===n)return e.consume(a),l;let s=e.exit("attentionSequence"),u=ag(a),c=!u||2===u&&o||r.includes(a),d=!o||2===o&&u||r.includes(i);return s._open=!!(42===n?c:c&&(o||!d)),s._close=!!(42===n?d:d&&(u||!c)),t(a)}}function a_(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let aw={name:"autolink",tokenize:ax};function ax(e,t,n){let r=0;return i;function i(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(t){return iB(t)?(e.consume(t),a):64===t?n(t):u(t)}function a(e){return 43===e||45===e||46===e||iH(e)?(r=1,l(e)):u(e)}function l(t){return 58===t?(e.consume(t),r=0,s):(43===t||45===t||46===t||iH(t))&&r++<32?(e.consume(t),l):(r=0,u(t))}function s(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||iU(r)?n(r):(e.consume(r),s)}function u(t){return 64===t?(e.consume(t),c):iz(t)?(e.consume(t),u):n(t)}function c(e){return iH(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):f(n)}function f(t){if((45===t||iH(t))&&r++<63){let n=45===t?f:d;return e.consume(t),n}return n(t)}}let aE={name:"htmlText",tokenize:ak};function ak(e,t,n){let r,i,o,a=this;return l;function l(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s}function s(t){return 33===t?(e.consume(t),u):47===t?(e.consume(t),w):63===t?(e.consume(t),b):iB(t)?(e.consume(t),k):n(t)}function u(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,m):iB(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),f):iZ(t)?(o=d,V(t)):(e.consume(t),d)}function f(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?T(e):45===e?f(e):d(e)}function m(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?h:m):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),g):iZ(t)?(o=h,V(t)):(e.consume(t),h)}function g(t){return 93===t?(e.consume(t),y):h(t)}function y(t){return 62===t?T(t):93===t?(e.consume(t),y):h(t)}function v(t){return null===t||62===t?T(t):iZ(t)?(o=v,V(t)):(e.consume(t),v)}function b(t){return null===t?n(t):63===t?(e.consume(t),_):iZ(t)?(o=b,V(t)):(e.consume(t),b)}function _(e){return 62===e?T(e):b(e)}function w(t){return iB(t)?(e.consume(t),x):n(t)}function x(t){return 45===t||iH(t)?(e.consume(t),x):E(t)}function E(t){return iZ(t)?(o=E,V(t)):iQ(t)?(e.consume(t),E):T(t)}function k(t){return 45===t||iH(t)?(e.consume(t),k):47===t||62===t||iG(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),T):58===t||95===t||iB(t)?(e.consume(t),O):iZ(t)?(o=S,V(t)):iQ(t)?(e.consume(t),S):T(t)}function O(t){return 45===t||46===t||58===t||95===t||iH(t)?(e.consume(t),O):D(t)}function D(t){return 61===t?(e.consume(t),C):iZ(t)?(o=D,V(t)):iQ(t)?(e.consume(t),D):S(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,F):iZ(t)?(o=C,V(t)):iQ(t)?(e.consume(t),C):(e.consume(t),A)}function F(t){return t===r?(e.consume(t),r=void 0,P):null===t?n(t):iZ(t)?(o=F,V(t)):(e.consume(t),F)}function A(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||iG(t)?S(t):(e.consume(t),A)}function P(e){return 47===e||62===e||iG(e)?S(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function V(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return iQ(t)?i1(e,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):j(t)}function j(t){return e.enter("htmlTextData"),o(t)}}let aS={name:"labelStartLink",resolveAll:ai.resolveAll,tokenize:aO};function aO(e,t,n){let r=this;return i;function i(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}let aD={42:oh,43:oh,45:oh,48:oh,49:oh,50:oh,51:oh,52:oh,53:oh,54:oh,55:oh,56:oh,57:oh,62:oE},aC={91:oT},aF={[-2]:oI,[-1]:oI,32:oI},aA={35:oR,42:op,45:[oH,op],60:oJ,61:oH,95:op,96:o2,126:o2},aP={38:o9,92:o8},aT={[-5]:at,[-4]:at,[-3]:at,33:am,38:o9,42:ay,60:[aw,aE],91:aS,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return r;function r(t){return e.enter("hardBreakEscape"),e.consume(t),i}function i(r){return iZ(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},o8],93:ai,95:ay,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return a;function a(t){return e.enter("codeText"),e.enter("codeTextSequence"),l(t)}function l(t){return 96===t?(e.consume(t),o++,l):(e.exit("codeTextSequence"),s(t))}function s(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),s):96===t?(i=e.enter("codeTextSequence"),r=0,c(t)):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):(e.enter("codeTextData"),u(t))}function u(t){return null===t||32===t||96===t||iZ(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),u)}function c(n){return 96===n?(e.consume(n),r++,c):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(i.type="codeTextData",u(n))}}}},aV={null:[ay,ol]},aM={null:[42,95]},aj={null:[]};function aI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],a=[],l=[],s={attempt:E(w),check:E(x),consume:v,enter:b,exit:_,interrupt:E(x,{interrupt:!0})},u={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},c=t.tokenize.call(u,s);return t.resolveAll&&o.push(t),u;function d(e){return(a=iT(a,e),g(),null!==a[a.length-1])?[]:(k(t,0),u.events=ar(o,u.events,u),u.events)}function f(e,t){return aL(p(e),t)}function p(e){return aN(a,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function h(e){i[e.line]=e.column,O()}function g(){let e;for(;r._index<a.length;){let t=a[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)y(t.charCodeAt(r._bufferIndex));else y(t)}}function y(e){c=c(e)}function v(e){iZ(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,O()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e}function b(e,t){let n=t||{};return n.type=e,n.start=m(),u.events.push(["enter",n,u]),l.push(n),n}function _(e){let t=l.pop();return t.end=m(),u.events.push(["exit",t,u]),t}function w(e,t){k(e,t.from)}function x(e,t){t.restore()}function E(e,t){return n;function n(n,r,i){let o,a,l,c;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):d(n);function d(e){return t;function t(t){let n=null!==t&&e[t],r=null!==t&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return(o=e,a=0,0===e.length)?i:p(e[a])}function p(e){return n;function n(n){return(c=S(),l=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name))?h(n):e.tokenize.call(t?Object.assign(Object.create(u),t):u,s,m,h)(n)}}function m(t){return e(l,c),r}function h(e){return(c.restore(),++a<o.length)?p(o[a]):i}}}function k(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&iP(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function S(){let e=m(),t=u.previous,n=u.currentConstruct,i=u.events.length,o=Array.from(l);return{from:i,restore:a};function a(){r=e,u.previous=t,u.currentConstruct=n,u.events.length=i,l=o,O()}}function O(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aN(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,a=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,a)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}function aL(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,i.push(o)}return i.join("")}function aq(e){let t={constructs:iq([o,...(e||{}).extensions||[]]),content:n(i2),defined:[],document:n(i5),flow:n(oo),lazy:{},string:n(os),text:n(ou)};return t;function n(e){return n;function n(n){return aI(t,e,n)}}}let aR=/[\0\t\n\r]/g;function a$(){let e,t=1,n="",r=!0;return i;function i(i,o,a){let l,s,u,c,d,f=[];for(i=n+("string"==typeof i?i.toString():new TextDecoder(o||void 0).decode(i)),u=0,n="",r&&(65279===i.charCodeAt(0)&&u++,r=void 0);u<i.length;){if(aR.lastIndex=u,c=(l=aR.exec(i))&&void 0!==l.index?l.index:i.length,d=i.charCodeAt(c),!l){n=i.slice(u);break}if(10===d&&u===c&&e)f.push(-3),e=void 0;else switch(e&&(f.push(-5),e=void 0),u<c&&(f.push(i.slice(u,c)),t+=c-u),d){case 0:f.push(65533),t++;break;case 9:for(s=4*Math.ceil(t/4),f.push(-2);t++<s;)f.push(-1);break;case 10:f.push(-4),t=1;break;default:e=!0,t=1}u=c+1}return a&&(e&&f.push(-5),n&&f.push(n),f.push(null)),f}}function aB(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let aH=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function az(e){return e.replace(aH,aU)}function aU(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return aB(n.slice(t?2:1),t?16:10)}return o6(n)||e}let aW={}.hasOwnProperty;function aY(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),aJ(n)(iN(aq(n).document().write(a$()(e,t,!0))))}function aJ(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(et),autolinkProtocol:S,autolinkEmail:S,atxHeading:o(Q),blockQuote:o(W),characterEscape:S,characterReference:S,codeFenced:o(Y),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Y,a),codeText:o(J,a),codeTextData:S,data:S,codeFlowValue:S,definition:o(Z),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(G),hardBreakEscape:o(K),hardBreakTrailing:o(K),htmlFlow:o(X,a),htmlFlowData:S,htmlText:o(X,a),htmlTextData:S,image:o(ee),label:a,link:o(et),listItem:o(er),listItemValue:f,listOrdered:o(en,d),listUnordered:o(en),paragraph:o(ei),reference:q,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Q),strong:o(eo),thematicBreak:o(el)},exit:{atxHeading:s(),atxHeadingSequence:w,autolink:s(),autolinkEmail:U,autolinkProtocol:z,blockQuote:s(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:$,characterReferenceMarkerNumeric:$,characterReferenceValue:B,characterReference:H,codeFenced:s(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:O,codeIndented:s(y),codeText:s(P),codeTextData:O,data:O,definition:s(),definitionDestinationString:_,definitionLabelString:v,definitionTitleString:b,emphasis:s(),hardBreakEscape:s(C),hardBreakTrailing:s(C),htmlFlow:s(F),htmlFlowData:O,htmlText:s(A),htmlTextData:O,image:s(V),label:j,labelText:M,lineEnding:D,link:s(T),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:R,resourceDestinationString:I,resourceTitleString:N,resource:L,setextHeading:s(k),setextHeadingLineSequence:E,setextHeadingText:x,strong:s(),thematicBreak:s()}};aG(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:c,data:n},s=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?s.push(d):d=i(e,s.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];aW.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},o),e[d][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||aK).call(o,void 0,e[0])}for(r.position={start:aZ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:aZ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r,i,o,a,l=t-1,s=-1,u=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?s++:s--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||s||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!s&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===s&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=l;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",u=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(l,0,["enter",i,t[2]]),l++,n++,o=void 0,a=!0}}}return e[t][1]._spread=u,n}function o(e,t){return n;function n(n){l.call(this,e(n),n),t&&t.call(this,n)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:aZ(t.start),end:void 0}}function s(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||aK).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+rQ({start:e.start,end:e.end})+"): it’s not open");n.position.end=aZ(e.end)}function c(){return iD(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)}function p(){let e=this.resume();this.stack[this.stack.length-1].lang=e}function m(){let e=this.resume();this.stack[this.stack.length-1].meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oP(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume();this.stack[this.stack.length-1].title=e}function _(){let e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)}function x(){this.data.setextHeadingSlurpLineEnding=!0}function E(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function S(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n=ea()).position={start:aZ(e.start),end:void 0},t.push(n)),this.stack.push(n)}function O(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=aZ(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=aZ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(S.call(this,e),O.call(this,e))}function C(){this.data.atHardBreak=!0}function F(){let e=this.resume();this.stack[this.stack.length-1].value=e}function A(){let e=this.resume();this.stack[this.stack.length-1].value=e}function P(){let e=this.resume();this.stack[this.stack.length-1].value=e}function T(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function V(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=az(t),n.identifier=oP(t).toLowerCase()}function j(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t}function I(){let e=this.resume();this.stack[this.stack.length-1].url=e}function N(){let e=this.resume();this.stack[this.stack.length-1].title=e}function L(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function R(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function $(e){this.data.characterReferenceType=e.type}function B(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=aB(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=o6(n);let i=this.stack[this.stack.length-1];i.value+=t}function H(e){this.stack.pop().position.end=aZ(e.end)}function z(e){O.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function U(e){O.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function W(){return{type:"blockquote",children:[]}}function Y(){return{type:"code",lang:null,meta:null,value:""}}function J(){return{type:"inlineCode",value:""}}function Z(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function G(){return{type:"emphasis",children:[]}}function Q(){return{type:"heading",depth:0,children:[]}}function K(){return{type:"break"}}function X(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function en(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function er(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function ei(){return{type:"paragraph",children:[]}}function eo(){return{type:"strong",children:[]}}function ea(){return{type:"text",value:""}}function el(){return{type:"thematicBreak"}}}function aZ(e){return{line:e.line,column:e.column,offset:e.offset}}function aG(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?aG(e,r):aQ(e,r)}}function aQ(e,t){let n;for(n in t)if(aW.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}function aK(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+rQ({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rQ({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+rQ({start:t.start,end:t.end})+") is still open")}function aX(e){let t=this;function n(n){return aY(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}t.parser=n}let a0="object"==typeof self?self:globalThis,a1=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[o,a]=t[i];switch(o){case 0:case -1:return n(a,i);case 1:{let e=n([],i);for(let t of a)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),i);case 4:{let{source:e,flags:t}=a;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of a)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of a)e.add(r(t));return e}case 7:{let{name:e,message:t}=a;return n(new a0[e](t),i)}case 8:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i)}return n(new a0[o](a),i)};return r},a2=e=>a1(new Map,e)(0),a4="",{toString:a5}={},{keys:a3}=Object,a6=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=a5.call(e).slice(8,-1);switch(n){case"Array":return[1,a4];case"Object":return[2,a4];case"Date":return[3,a4];case"RegExp":return[4,a4];case"Map":return[5,a4];case"Set":return[6,a4]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},a9=([e,t])=>0===e&&("function"===t||"symbol"===t),a7=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},o=r=>{if(n.has(r))return n.get(r);let[a,l]=a6(r);switch(a){case 0:{let t=r;switch(l){case"bigint":a=8,t=r.toString();break;case"function":case"symbol":if(e)throw TypeError("unable to serialize "+l);t=null;break;case"undefined":return i([-1],r)}return i([a,t],r)}case 1:{if(l)return i([l,[...r]],r);let e=[],t=i([a,e],r);for(let t of r)e.push(o(t));return t}case 2:{if(l)switch(l){case"BigInt":return i([l,r.toString()],r);case"Boolean":case"Number":case"String":return i([l,r.valueOf()],r)}if(t&&"toJSON"in r)return o(r.toJSON());let n=[],s=i([a,n],r);for(let t of a3(r))(e||!a9(a6(r[t])))&&n.push([o(t),o(r[t])]);return s}case 3:return i([a,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([a,{source:e,flags:t}],r)}case 5:{let t=[],n=i([a,t],r);for(let[n,i]of r)(e||!(a9(a6(n))||a9(a6(i))))&&t.push([o(n),o(i)]);return n}case 6:{let t=[],n=i([a,t],r);for(let n of r)(e||!a9(a6(n)))&&t.push(o(n));return n}}let{message:s}=r;return i([a,{name:l,message:s}],r)};return o},a8=(e,{json:t,lossy:n}={})=>{let r=[];return a7(!(t||n),!!t,new Map,r)(e),r},le="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?a2(a8(e,t)):structuredClone(e):(e,t)=>a2(a8(e,t));function lt(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&iH(e.charCodeAt(n+1))&&iH(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ln(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function lr(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function li(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ln,r=e.options.footnoteBackLabel||lr,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],s=-1;for(;++s<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[s]);if(!i)continue;let o=e.all(i),a=String(i.identifier).toUpperCase(),u=lt(a.toLowerCase()),c=0,d=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++c<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(s,c);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+u+(c>1?"-"+c:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(s,c),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+u},children:e.wrap(o,!0)};e.patch(i,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...le(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}let lo=function(e){if(null==e)return lc;if("function"==typeof e)return lu(e);if("object"==typeof e)return Array.isArray(e)?la(e):ll(e);if("string"==typeof e)return ls(e);throw Error("Expected function, string, or object as test")};function la(e){let t=[],n=-1;for(;++n<e.length;)t[n]=lo(e[n]);return lu(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ll(e){let t=e;return lu(n);function n(n){let r,i=n;for(r in e)if(i[r]!==t[r])return!1;return!0}}function ls(e){return lu(t);function t(t){return t&&t.type===e}}function lu(e){return t;function t(t,n,r){return!!(ld(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function lc(){return!0}function ld(e){return null!==e&&"object"==typeof e&&"type"in e}function lf(e){return e}let lp=[],lm=!0,lh=!1,lg="skip";function ly(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let o=lo(i),a=r?-1:1;function l(e,i,s){let u=e&&"object"==typeof e?e:{};if("string"==typeof u.type){let t="string"==typeof u.tagName?u.tagName:"string"==typeof u.name?u.name:void 0;Object.defineProperty(c,"name",{value:"node ("+lf(e.type+(t?"<"+t+">":""))+")"})}return c;function c(){let u,c,d,f=lp;if((!t||o(e,i,s[s.length-1]||void 0))&&(f=lv(n(e,s)))[0]===lh)return f;if("children"in e&&e.children){let t=e;if(t.children&&f[0]!==lg)for(c=(r?t.children.length:-1)+a,d=s.concat(t);c>-1&&c<t.children.length;){if((u=l(t.children[c],c,d)())[0]===lh)return u;c="number"==typeof u[1]?u[1]:c+a}}return f}}l(e,void 0,[])()}function lv(e){return Array.isArray(e)?e:"number"==typeof e?[lm,e]:null==e?lp:[e]}function lb(e,t,n,r){let i,o,a;function l(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return a(e,r,n)}"function"==typeof t&&"function"!=typeof n?(o=void 0,a=t,i=n):(o=t,a=n,i=r),ly(e,o,l,i)}function l_(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function lw(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=lx(n[r])}return t}function lx(e){let t=e.spread;return null==t?e.children.length>1:t}let lE=9,lk=32;function lS(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(lO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(lO(t.slice(i),i>0,!1)),o.join("")}function lO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===lE||t===lk;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===lE||t===lk;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let lD={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=lt(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),l=e.footnoteCounts.get(i);void 0===l?(l=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(i,l);let s={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let u={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,u),e.applyData(t,u)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return l_(e,t);let i={src:lt(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:lt(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return l_(e,t);let i={href:lt(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:lt(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?lw(n):lx(t),o={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(i||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let s=r[r.length-1];s&&(i||"element"!==s.type||"p"!==s.tagName)&&a.push({type:"text",value:"\n"});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=rJ(t.children[1]),a=rY(t.children[t.children.length-1]);o&&a&&(r.position={start:o,end:a}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length,l=-1,s=[];for(;++l<a;){let n=t.children[l],r={},a=o?o[l]:void 0;a&&(r.align=a);let u={type:"element",tagName:i,properties:r,children:[]};n&&(u.children=e.all(n),e.patch(n,u),u=e.applyData(n,u)),s.push(u)}let u={type:"element",tagName:"tr",properties:{},children:e.wrap(s,!0)};return e.patch(t,u),e.applyData(t,u)},text:function(e,t){let n={type:"text",value:lS(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:lC,yaml:lC,definition:lC,footnoteDefinition:lC};function lC(){}let lF={}.hasOwnProperty,lA={};function lP(e,t){let n=t||lA,r=new Map,i=new Map,o={all:l,applyData:lV,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...lD,...n.handlers},one:a,options:n,patch:lT,wrap:lj};return lb(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o;function a(e,t){let n=e.type,r=o.handlers[n];if(lF.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=le(n);return r.children=o.all(e),r}return le(e)}return(o.options.unknownHandler||lM)(o,e,t)}function l(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=lI(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=lI(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function lT(e,t){e.position&&(t.position=rG(e))}function lV(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,le(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function lM(e,t){let n=t.data||{},r="value"in t&&!(lF.call(n,"hProperties")||lF.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function lj(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function lI(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function lN(e,t){let n=lP(e,t),r=n.one(e,void 0),i=li(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:"\n"},i),o}function lL(e,t){return e&&"run"in e?async function(n,r){let i=lN(n,{file:r,...t});await e.run(i,r)}:function(n,r){return lN(n,{file:r,...e||t})}}function lq(e){if(e)throw e}var lR=n(9710);function l$(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lB(){let e=[],t={run:n,use:r};return t;function n(...t){let r=-1,i=t.pop();if("function"!=typeof i)throw TypeError("Expected function as last argument, not "+i);function o(n,...a){let l=e[++r],s=-1;if(n)return void i(n);for(;++s<t.length;)(null===a[s]||void 0===a[s])&&(a[s]=t[s]);t=a,l?lH(l,o)(...a):i(null,...a)}o(null,...t)}function r(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function lH(e,t){let n;return r;function r(...t){let a,l=e.length>t.length;l&&t.push(i);try{a=e.apply(this,t)}catch(t){let e=t;if(l&&n)throw e;return i(e)}l||(a instanceof Promise?a.then(o,i):a instanceof Error?i(a):o(a))}function i(e,...r){n||(n=!0,t(e,...r))}function o(e){i(null,e)}}let lz=lZ,lU=lG,lW=lQ,lY=lK,lJ="/";function lZ(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');l1(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(i=o):(l=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)}function lG(e){let t;if(l1(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)}function lQ(e){let t;l1(e);let n=e.length,r=-1,i=0,o=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===l?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===i+1?"":e.slice(o,r)}function lK(...e){let t,n=-1;for(;++n<e.length;)l1(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":lX(t)}function lX(e){l1(e);let t=47===e.codePointAt(0),n=l0(e,!t);return 0!==n.length||t||(n="."),n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/"),t?"/"+n:n}function l0(e,t){let n,r,i="",o=0,a=-1,l=0,s=-1;for(;++s<=e.length;){if(s<e.length)n=e.codePointAt(s);else if(47===n)break;else n=47;if(47===n){if(a===s-1||1===l);else if(a!==s-1&&2===l){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=s,l=0;continue}}else if(i.length>0){i="",o=0,a=s,l=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(a+1,s):i=e.slice(a+1,s),o=s-a-1;a=s,l=0}else 46===n&&l>-1?l++:l=-1}return i}function l1(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}let l2=l4;function l4(){return"/"}function l5(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function l3(e){if("string"==typeof e)e=new URL(e);else if(!l5(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return l6(e)}function l6(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}let l9=["history","path","basename","stem","extname","dirname"];class l7{constructor(e){let t,n;t=e?l5(e)?{path:e}:"string"==typeof e||sn(e)?{value:e}:e:{},this.cwd="cwd"in t?"":l2(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<l9.length;){const e=l9[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)l9.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?lz(this.path):void 0}set basename(e){se(e,"basename"),l8(e,"basename"),this.path=lY(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?lU(this.path):void 0}set dirname(e){st(this.basename,"dirname"),this.path=lY(e||"",this.basename)}get extname(){return"string"==typeof this.path?lW(this.path):void 0}set extname(e){if(l8(e,"extname"),st(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=lY(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){l5(e)&&(e=l3(e)),se(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?lz(this.path,this.extname):void 0}set stem(e){se(e,"stem"),l8(e,"stem"),this.path=lY(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new r1(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function l8(e,t){if(e&&e.includes(lJ))throw Error("`"+t+"` cannot be a path: did not expect `"+lJ+"`")}function se(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function st(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function sn(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}let sr=function(e){let t=this,n=t.constructor.prototype,r=n[e],i=function(){return r.apply(i,arguments)};return Object.setPrototypeOf(i,n),i},si={}.hasOwnProperty;class so extends sr{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lB()}copy(){let e=new so,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data(lR(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(su("data",this.frozen),this.namespace[e]=t,this):si.call(this.namespace,e)&&this.namespace[e]||void 0:e?(su("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);let r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=sf(e),n=this.parser||this.Parser;return sl("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),sl("process",this.parser||this.Parser),ss("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=sf(e),a=n.parse(o);function l(e,n){e||!n?i(e):r?r(n):t(void 0,n)}n.run(a,o,function(e,t,r){if(e||!t||!r)return l(e);let i=t,o=n.stringify(i,r);sm(o)?r.value=o:r.result=o,l(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),sl("processSync",this.parser||this.Parser),ss("processSync",this.compiler||this.Compiler),this.process(e,r),sd("processSync","process",n),t;function r(e,r){n=!0,lq(e),t=r}}run(e,t,n){sc(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){let a=sf(t);function l(t,r,a){let l=r||e;t?o(t):i?i(l):n(void 0,l,a)}r.run(e,a,l)}}runSync(e,t){let n,r=!1;return this.run(e,t,i),sd("runSync","run",r),n;function i(e,t){lq(e),n=t,r=!0}}stringify(e,t){this.freeze();let n=sf(t),r=this.compiler||this.Compiler;return ss("stringify",r),sc(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(su("use",this.frozen),null==e);else if("function"==typeof e)l(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if("function"==typeof e)l(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;l(t,n)}else o(e);else throw TypeError("Expected usable value, not `"+e+"`")}function o(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(r.settings=lR(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)i(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function l(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,a=n[i][1];l$(a)&&l$(r)&&(r=lR(!0,a,r)),n[i]=[e,r,...o]}}}}let sa=new so().freeze();function sl(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function ss(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function su(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sc(e){if(!l$(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function sd(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function sf(e){return sp(e)?e:new l7(e)}function sp(e){return!!(e&&"object"==typeof e&&"message"in e&&"messages"in e)}function sm(e){return"string"==typeof e||sh(e)}function sh(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}let sg=[],sy={allowDangerousHtml:!0},sv=/^(https?|ircs?|mailto|xmpp)$/i,sb=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function s_(e){let t=e.allowedElements,n=e.allowElement,r=e.children||"",i=e.className,o=e.components,a=e.disallowedElements,l=e.rehypePlugins||sg,s=e.remarkPlugins||sg,u=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sy}:sy,c=e.skipHtml,d=e.unwrapDisallowed,f=e.urlTransform||sw,p=sa().use(aX).use(s).use(lL,u).use(l),m=new l7;for(let t of("string"==typeof r&&(m.value=r),sb))Object.hasOwn(e,t.from)&&(t.from,t.to&&t.to,t.id);let h=p.parse(m),g=p.runSync(h,m);return i&&(g={type:"element",tagName:"div",properties:{className:i},children:"root"===g.type?g.children:[g]}),lb(g,y),r8(g,{Fragment:iS.Fragment,components:o,ignoreInvalidStyle:!0,jsx:iS.jsx,jsxs:iS.jsxs,passKeys:!0,passNode:!0});function y(e,r,i){if("raw"===e.type&&i&&"number"==typeof r)return c?i.children.splice(r,1):i.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in ik)if(Object.hasOwn(ik,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=ik[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=f(String(n||""),t,e))}}if("element"===e.type){let o=t?!t.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&n&&"number"==typeof r&&(o=!n(e,r,i)),o&&i&&"number"==typeof r)return d&&e.children?i.children.splice(r,1,...e.children):i.children.splice(r,1),r}}}function sw(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t<0||i>-1&&t>i||n>-1&&t>n||r>-1&&t>r||sv.test(e.slice(0,t))?e:""}let sx="-esm-form-engine__markdown-wrapper__markdownWrapper___N6Orn",sE={a:({node:e,...t})=>f().createElement("a",{...t,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer"})},sk=({markdown:e})=>f().createElement("div",{className:sx},f().createElement(s_,{children:e,unwrapDisallowed:!0,allowedElements:["h1","h2","h3","h4","h5","h6","p","strong","em","code","pre","ul","ol","li","a","blockquote","hr","br"],components:sE})),sS=({field:e})=>{let{t}=(0,e9.useTranslation)(),n=e=>Array.isArray(e)?e.map(e=>t(e,{defaultValue:e,interpolation:{escapeValue:!1}})).join("\n\n"):"string"==typeof e?t(e,{defaultValue:e,interpolation:{escapeValue:!1}}):e;return!e.isHidden&&f().createElement(sk,{markdown:n(e.value)})},sO={boldedLabel:"-esm-form-engine__multi-select__boldedLabel___-TJAY",errorLabel:"-esm-form-engine__multi-select__errorLabel___Cx0K1",selectionDisplay:"-esm-form-engine__multi-select__selectionDisplay___KJIF4",tagContainer:"-esm-form-engine__multi-select__tagContainer___jtOs2",checkbox:"-esm-form-engine__multi-select__checkbox___m66zk"},sD=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),[c,p]=(0,d.useState)(0),[m,h]=(0,d.useState)([]),g=(0,d.useRef)(!0),v=e.questionOptions.answers.filter(e=>!e.isHidden).map((t,n)=>({id:`${e.id}-${t.concept}`,concept:t.concept,label:o(t.label),key:n,disabled:t.disable?.isDisabled,readonly:(0,np.H)(e.readonly)})),b=(0,d.useMemo)(()=>t?.length&&c<1?(p(c+1),v.filter(e=>t?.includes(e.concept))):[],[t]),_=({selectedItems:e})=>{i(e.map(e=>e.concept))},w=(0,d.useMemo)(()=>(0,np.H)(e.questionOptions.isCheckboxSearchable),[e.questionOptions.isCheckboxSearchable]);(0,d.useEffect)(()=>{g.current&&1===c&&(h(b.map(e=>e.concept)),g.current=!1)},[b,g]);let x=e=>{let t,n=e.concept;h(t=m.some(e=>e===n)?m.filter(e=>e!==n):m.some(e=>e===n)?m.filter(e=>e!==n):[...m,n]),i(t)},E=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement("div",{className:sO.formField},f().createElement(nU,{label:o(e.label),value:t?u[e.type]?.getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:E})):!e.isHidden&&f().createElement(f().Fragment,null,f().createElement("div",{className:sO.boldedLabel},f().createElement(y.Layer,null,w?f().createElement(y.FilterableMultiSelect,{disabled:e.isDisabled,id:e.id,initialSelectedItems:b,invalid:n.length>0,invalidText:n[0]?.message,items:v,itemToString:e=>e?o(e.label):" ",key:e.id,onChange:_,placeholder:o("search","Search")+"...",readOnly:(0,np.H)(e.readonly),titleText:f().createElement(n1,{field:e}),warn:r.length>0,warnText:r[0]?.message}):f().createElement(y.CheckboxGroup,{legendText:f().createElement(n1,{field:e}),readOnly:(0,np.H)(e.readonly)},v?.map((t,n)=>f().createElement(y.Checkbox,{className:sO.checkbox,checked:m.some(e=>e===t.concept),disabled:t.disabled,id:`${e.id}-${t.concept}`,key:`${e.id}-${t.concept}-${n}`,labelText:o(t.label),name:t.concept,onChange:()=>x(t),readOnly:(0,np.H)(e.readonly)}))))),w&&f().createElement("div",{className:sO.selectionDisplay},t?.length?f().createElement("div",{className:sO.tagContainer},u[e.type]?.getDisplayValue(e,t)?.map((e,t)=>f().createElement(y.Tag,{key:t,type:"cool-gray"},o(e)))):f().createElement(n_,null)))},sC={boldedLabel:"-esm-form-engine__number__boldedLabel___baNvc",errorLabel:"-esm-form-engine__number__errorLabel___vJnNs",controlWidthConstrained:"-esm-form-engine__number__controlWidthConstrained___wjS56"},sF=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=ng(),u=(0,d.useMemo)(()=>isNaN(t)?"":t??"",[t]),c=(0,d.useCallback)(e=>void 0===e||isNaN(Number(e))?void 0:Number(e),[]),p=(0,d.useCallback)((e,{value:t})=>{let n=c(t);i(isNaN(n)?void 0:n)},[i,c]),h=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]),g=c(e.questionOptions.max),v=c(e.questionOptions.min);return"view"==l||"embedded-view"==l?f().createElement("div",{className:sC.formField},f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:h})):!e.isHidden&&f().createElement(y.Layer,null,f().createElement(y.NumberInput,{id:e.id,invalid:n.length>0,invalidText:n[0]?.message,label:f().createElement(n1,{field:e}),max:g,min:v,name:e.id,value:u,onChange:p,allowEmpty:!0,size:"lg",hideSteppers:e.hideSteppers??!1,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),className:m()(sC.controlWidthConstrained,sC.boldedLabel),warn:r.length>0,warnText:r[0]?.message,step:e.questionOptions.step??.01}))},sA="-esm-form-engine__radio__boldedLegend___YisTw",sP="-esm-form-engine__radio__errorMessage___fmThI",sT=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),c=e=>{i(e)},p=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,np.H)(e.readonly)?f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&f().createElement(y.FormGroup,{legendText:f().createElement(n1,{field:e}),className:sA,disabled:e.isDisabled,invalid:n?.length>0},f().createElement(y.RadioButtonGroup,{name:e.id,valueSelected:t,onChange:c,readOnly:(0,np.H)(e.readonly),orientation:e.questionOptions?.orientation||"vertical"},e.questionOptions.answers.filter(e=>!e.isHidden).map((n,r)=>f().createElement(y.RadioButton,{id:`${e.id}-${n.label}`,labelText:o(n.label)??"",value:n.concept,key:r,onClick:e=>{t&&e.target.checked?(e.target.checked=!1,e.preventDefault(),c(null)):c(n.concept)}}))),(n?.length>0||r?.length>0)&&f().createElement("div",null,f().createElement("div",{className:sP},n.length>0?n[0].message:r.length>0?r[0].message:null)))},sV="-esm-form-engine__dropdown__boldedLabel___jRkpD",sM=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),p=(0,d.useCallback)(({selectedItem:e})=>{i(e===c.ZA?null:e)},[i]),m=(0,d.useCallback)(t=>{let n=e.questionOptions.answers.find(e=>e.value?e.value==t:e.concept==t);return n?o(n.label):""},[e.questionOptions.answers,o]),h=(0,d.useMemo)(()=>{let t=e.questionOptions.answers;return t.some(e=>e.value===c.ZA)||t.unshift({value:c.ZA,label:o("chooseAnOption","Choose an option")}),t.filter(e=>!e.isHidden).map(e=>e.value||e.concept)},[e.questionOptions.answers]),g=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:g}):!e.isHidden&&f().createElement("div",{className:sV},f().createElement(y.Layer,null,f().createElement(y.Dropdown,{"aria-label":o(e.label),disabled:e.isDisabled,id:e.id,invalid:n.length>0,invalidText:n[0]?.message,items:h,itemToString:m,label:"",onChange:p,readOnly:(0,np.H)(e.readonly),selectedItem:ts(t)?c.ZA:t,titleText:f().createElement(n1,{field:e}),warn:r.length>0,warnText:r[0]?.message})))},sj="-esm-form-engine__text-area__boldedLabel___VdRnE",sI=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),[a,l]=(0,d.useState)(t),{layoutType:s,sessionMode:u,workspaceLayout:c}=ng(),p=e=>{e.preventDefault(),a!==t&&l(t)},m=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(u)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,s,c,u),[u,e.readonly,e.inlineRendering,s,c]);return"view"==u||"embedded-view"==u?f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:m}):!e.isHidden&&f().createElement("div",{className:sj},f().createElement(y.Layer,null,f().createElement(y.TextArea,{id:e.id,labelText:f().createElement(n1,{field:e}),name:e.id,onChange:i,onBlur:p,value:t||"",rows:e.questionOptions.rows||4,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),invalid:n.length>0,invalidText:n[0]?.message,warn:r.length>0,warnText:r[0]?.message,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength)})))},sN="-esm-form-engine__text__boldedLabel___WRIlW",sL=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=ng(),[u,c]=(0,d.useState)(null),p=e=>{e.preventDefault(),u!==t&&c(t)},m=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:m}):!e.isHidden&&f().createElement("div",{className:sN},f().createElement(y.Layer,null,f().createElement(y.TextInput,{disabled:e.isDisabled,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),id:e.id,invalid:n.length>0,invalidText:n[0]?.message,labelText:f().createElement(n1,{field:e}),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength),name:e.id,onBlur:p,onChange:e=>{i(e.target.value)},readOnly:(0,np.H)(e.readonly),value:t??"",warn:r.length>0,warnText:r.length>0?r[0].message:void 0})))},sq="-esm-form-engine__toggle__boldedLabel___IF1zX",sR=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),a=ng(),l=e=>{i(e)};(0,d.useEffect)(()=>{e.meta?.initialValue?.omrsObject||"enter"!=a.sessionMode||a.formFieldAdapters[e.type].transformFieldValue(e,t??!1,a)},[]);let s=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(a.sessionMode)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a.layoutType,a.workspaceLayout,a.sessionMode),[a.sessionMode,e.readonly,e.inlineRendering,a.layoutType,a.workspaceLayout]);return"view"==a.sessionMode||"embedded-view"==a.sessionMode?f().createElement(nU,{label:o(e.label),value:ts(t)?t:a.formFieldAdapters[e.type].getDisplayValue(e,t),conceptName:e.meta?.concept?.display,isInline:s}):!e.isHidden&&f().createElement("div",{className:sq},f().createElement(y.Toggle,{labelText:o(e.label),className:sq,id:e.id,labelA:e.questionOptions.toggleOptions.labelFalse,labelB:e.questionOptions.toggleOptions.labelTrue,onToggle:l,toggled:!!t,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly)}))};var s$=n(7942),sB=n(9600);let sH=function(){return sB.A.Date.now()};var sz=/\s/;let sU=function(e){for(var t=e.length;t--&&sz.test(e.charAt(t)););return t};var sW=/^\s+/;let sY=function(e){return e?e.slice(0,sU(e)+1).replace(sW,""):e};var sJ=n(4089),sZ=0/0,sG=/^[-+]0x[0-9a-f]+$/i,sQ=/^0b[01]+$/i,sK=/^0o[0-7]+$/i,sX=parseInt;let s0=function(e){if("number"==typeof e)return e;if((0,sJ.A)(e))return sZ;if((0,s$.A)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,s$.A)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=sY(e);var n=sQ.test(e);return n||sK.test(e)?sX(e.slice(2),n?2:8):sG.test(e)?sZ:+e};var s1="Expected a function",s2=Math.max,s4=Math.min;let s5=function(e,t,n){var r,i,o,a,l,s,u=0,c=!1,d=!1,f=!0;if("function"!=typeof e)throw TypeError(s1);function p(t){var n=r,o=i;return r=i=void 0,u=t,a=e.apply(o,n)}function m(e){return u=e,l=setTimeout(y,t),c?p(e):a}function h(e){var n=e-s,r=e-u,i=t-n;return d?s4(i,o-r):i}function g(e){var n=e-s,r=e-u;return void 0===s||n>=t||n<0||d&&r>=o}function y(){var e=sH();if(g(e))return v(e);l=setTimeout(y,h(e))}function v(e){return(l=void 0,f&&r)?p(e):(r=i=void 0,a)}function b(){return void 0===l?a:v(sH())}function _(){var e=sH(),n=g(e);if(r=arguments,i=this,s=e,n){if(void 0===l)return m(s);if(d)return clearTimeout(l),l=setTimeout(y,t),p(s)}return void 0===l&&(l=setTimeout(y,t)),a}return t=s0(t)||0,(0,s$.A)(n)&&(c=!!n.leading,o=(d="maxWait"in n)?s2(s0(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),_.cancel=function(){void 0!==l&&clearTimeout(l),u=0,r=s=i=l=void 0},_.flush=b,_},s3=[{name:"drug",datasource:{name:"drug_datasource",config:{class:"8d490dfc-c2cc-11de-8d13-0010c6dffd0f"}}},{name:"select-concept-answers",datasource:{name:"select_concept_answers_datasource",config:{concept:""}}},{name:"encounter-provider",datasource:{name:"provider_datasource"}},{name:"encounter-role",datasource:{name:"encounter_role_datasource"}},{name:"encounter-location",datasource:{name:"location_datasource"}},{name:"problem",datasource:{name:"problem_datasource",config:{class:["8d4918b0-c2cc-11de-8d13-0010c6dffd0f","8d492954-c2cc-11de-8d13-0010c6dffd0f","8d492b2a-c2cc-11de-8d13-0010c6dffd0f"]}}}],s6=e=>s3.find(t=>t.name===e),s9=e=>{let t=e.questionOptions.config?.referencedField,{methods:{control:n}}=ng();return ef({control:n,name:t,exact:!0,disabled:!t})},s7="-esm-form-engine__ui-select-extended__boldedLabel___MlmB3",s8="-esm-form-engine__ui-select-extended__loader___-txFf",ue="-esm-form-engine__ui-select-extended__item___+jYTi",ut="-esm-form-engine__ui-select-extended__code___Sg-vJ",un="-esm-form-engine__ui-select-extended__label___tsm2B",ur=({field:e,errors:t,warnings:n,setFieldValue:r})=>{let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)([]),[l,s]=(0,d.useState)(!1),[u,c]=(0,d.useState)(!1),[p,m]=(0,d.useState)(""),h=(0,d.useRef)(!1),[g,v]=(0,d.useState)(null),[b,_]=(0,d.useState)({}),w=s9(e),x=(0,np.H)(e.questionOptions.isSearchable),{layoutType:E,sessionMode:k,workspaceLayout:S,methods:{control:O,getFieldState:D,getValues:C}}=ng(),F=ef({control:O,name:e.id,exact:!0}),{isDirty:A}=D(e.id),P=(0,d.useMemo)(()=>!!(tg(k)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,E,S,k),[k,e.readonly,e.inlineRendering,E,S]),T=(0,d.useMemo)(()=>o.find(e=>e.uuid==F)||null,[o,F]),V=(0,d.useRef)(0),M=(0,d.useMemo)(()=>s5((t,n)=>{let r=V.current;c(!0),n.fetchData(t,b).then(t=>{r===V.current&&(t.length&&a(r=>{let i=C(e.id),o=r.find(e=>e.uuid==i),a=t.map(e=>n.toUuidAndDisplay(e,b));return o&&!a.some(e=>e.uuid==o.uuid)&&a.unshift(o),a}),c(!1))}).catch(e=>{r===V.current&&(console.error(e),c(!1))})},300),[b,e.id,C]),j=(0,d.useCallback)(e=>o.some(t=>t.display?.toLowerCase().includes(e.toLowerCase())),[o]);return((0,d.useEffect)(()=>{let t=e.questionOptions?.datasource?.name;_(t?e.questionOptions.datasource?.config:s6(e.questionOptions.rendering)?.datasource?.config),dA(t||e.questionOptions.rendering).then(e=>v(e))},[e.questionOptions?.datasource]),(0,d.useEffect)(()=>{let t=!1;return g&&!(0,np.H)(e.questionOptions.isSearchable)&&(a([]),s(!0),g.fetchData(null,{...b,referencedValue:w}).then(e=>{t||(a(e.map(e=>g.toUuidAndDisplay(e,b))),s(!1))}).catch(e=>{t||(console.error(e),s(!1),a([]))})),()=>{t=!0}},[g,b,w]),(0,d.useEffect)(()=>(g&&x&&!ts(p)&&!j(p)?M(p,g):c(!1),()=>{M.cancel(),V.current++}),[g,p,x,M]),(0,d.useEffect)(()=>{let e=!1;return F&&!A&&g&&x&&!o.length&&(s(!0),g.fetchSingleItem(F,b).then(t=>{e||(a([g.toUuidAndDisplay(t,b)]),s(!1))}).catch(t=>{e||(console.error(t),s(!1))})),()=>{e=!0}},[F,A,g,x,o,b]),l)?f().createElement(y.DropdownSkeleton,null):tg(k)||(0,np.H)(e.readonly)?f().createElement(nU,{label:i(e.label),value:F?ui(o.find(e=>e.uuid==F)):F,conceptName:e.meta?.concept?.display,isInline:P}):!e.isHidden&&f().createElement("div",{className:s7},f().createElement(y.Layer,null,f().createElement(y.ComboBox,{id:e.id,titleText:f().createElement(n1,{field:e}),items:o,itemToElement:e=>f().createElement("span",{className:ue},e?.code&&f().createElement("span",{className:ut},e.code),f().createElement("span",{className:un},e?.display)),itemToString:ui,selectedItem:T,placeholder:x?i("search","Search")+"...":null,onChange:({selectedItem:e})=>{M.cancel(),V.current++,c(!1),h.current=!0,r(e?.uuid)},disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),invalid:t.length>0,invalidText:t.length&&t[0].message,onInputChange:t=>{if(h.current){h.current=!1;return}e.questionOptions.isSearchable&&m(t)},onBlur:e=>{e.target.value||r(null)}}),u&&f().createElement(y.InlineLoading,{className:s8,description:i("searching","Searching")+"..."})))};function ui(e){return e?.code?`${e.code} ${e.display}`:e?.display??""}let uo="-esm-form-engine__workspace-launcher__label___vIWfO",ua="-esm-form-engine__workspace-launcher__workspaceButton___cmGUN",ul="-esm-form-engine__workspace-launcher__noPatientNotification___hhJs2",us=({field:e})=>{let{t}=(0,e9.useTranslation)(),{sessionMode:n,patient:r,visit:i}=ng(),o=async()=>{let n=e.questionOptions?.workspaceName;if(!n)return void(0,u.showSnackbar)({title:t("invalidWorkspaceName","Invalid workspace name."),subtitle:t("invalidWorkspaceNameSubtitle","Please provide a valid workspace name."),kind:"error",isLowContrast:!0});let o=e.questionOptions?.workspaceProps??{},a={patient:r,patientUuid:r?.id,visitContext:i};try{await (0,u.launchWorkspace2)(n,o,a)}catch(e){(0,u.showSnackbar)({title:t("errorLaunchingWorkspace","Error launching workspace"),subtitle:e?.message??t("errorLaunchingWorkspaceSubtitle","An unexpected error occurred while launching the workspace."),kind:"error",isLowContrast:!0})}};return e.isHidden||tg(n)?null:f().createElement("div",null,f().createElement("div",{className:uo},f().createElement(n1,{field:e})),f().createElement("div",{className:ua},f().createElement(y.Button,{disabled:(0,np.H)(e.readonly??!1)||!r,onClick:o},e.questionOptions.buttonLabel?t(e.questionOptions.buttonLabel):t("launchWorkspace","Launch Workspace")),!r&&f().createElement(y.InlineNotification,{className:ul,kind:"info",lowContrast:!0,hideCloseButton:!0,title:t("noPatientContext","No patient selected"),subtitle:t("noPatientContextSubtitle","This button is only active when a patient chart is open.")})))};var uu=n(3322);function uc(e,t,n){let r=[],i=(0,uu.A)(e);return i.questionOptions.repeatOptions={...i.questionOptions.repeatOptions??{}},i.meta={repeat:{...i.meta??{},isClone:!0},initialValue:{omrsObject:t}},i.id=`${i.id}_${n}`,i.questions?.forEach(e=>{r.push(e.id),e.id=`${e.id}_${n}`,e.meta.groupId=i.id,e.meta.initialValue={omrsObject:null,refinedValue:null},e.fieldDependents=new Set,tp(e),e.hide&&e.hide.hideWhenExpression&&(e.hide.hideWhenExpression=ud(e.hide.hideWhenExpression,n,r)),e.validators?.length&&e.validators.forEach(e=>{"js_expression"===e.type&&(e.failsWhenExpression=ud(e.failsWhenExpression,n,r))}),e.questionOptions.calculate?.calculateExpression&&(e.questionOptions.calculate.calculateExpression=ud(e.questionOptions.calculate?.calculateExpression,n,r))}),i}function ud(e,t,n){let r=[...new Set(n)];if(!r.length)return e;let i=r.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return e.replace(RegExp(`\\b(?:${i})\\b`,"g"),e=>`${e}_${t}`)}function uf(e,t){let n=Number(e);return!(ts(e)||isNaN(n))&&t>=n}let up=[],um={async getInitialValue(e,t,n){let r=uE(td((t??n.domainObjectValue).obs),up,e);return tf(e,"file")&&r?.length?uk(e,r):uh(e,r,!0)},async getPreviousValue(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let t=uh(e,uE(td(r.obs),up,e),!0);if(!ts(t))return{value:t,display:this.getDisplayValue(e,t)}}return null},getDisplayValue:(e,t)=>{let n=e.questionOptions.rendering;return ts(t)?t:t instanceof Date?tb(e,t):"checkbox"===n?t.map(t=>e.questionOptions.answers?.find(e=>e.concept==t)?.label):"toggle"===n?t?e.questionOptions.toggleOptions.labelTrue:e.questionOptions.toggleOptions.labelFalse:c.FU.includes(n)?e.questionOptions.answers?.find(e=>e.concept==t)?.label:t},transformFieldValue:(e,t,n)=>(tp(e),!e.meta.initialValue?.omrsObject&&ts(t))?null:tf(e,"checkbox")?uw(e,Array.isArray(t)?t:[t]):tf(e,"file")?ux(e,t):!ts(t)&&u_(e,t)?tm(e,uv(e,t),void 0):e.meta.initialValue?.omrsObject&&ts(t)?tm(e,void 0,uy(e.meta.initialValue.omrsObject)):ts(t)?null:tm(e,ug(e,t),void 0),tearDown:function(){up=[]}};function uh(e,t=[],n=!1){let r=e.questionOptions.rendering;if(e.meta||(e.meta={initialValue:{omrsObject:null,refinedValue:null}}),t.length){if("checkbox"==r)return up.push(...t.map(e=>e.uuid)),e.meta.initialValue.omrsObject=n?t:null,t.map(e=>e.value.uuid);let i=t[0];if(n&&(e.meta.initialValue.omrsObject={...i}),up.push(i.uuid),"string"==typeof i.value||"number"==typeof i.value){if(r.startsWith("date")){let t=ty(i.value);return n&&(e.meta.initialValue.omrsObject.value=tr()(t).format("YYYY-MM-DD HH:mm")),t}return i.value}return"toggle"==r?i.value.uuid===c.t$:"fixed-value"==r?e.fixedValue:i.value?.uuid}return""}function ug(e,t){return ts(t)&&"obsGroup"!==e.type?null:{..."obsGroup"===e.type?{groupMembers:[]}:{value:e.questionOptions.rendering.startsWith("date")?ub(e,t):t},concept:e.questionOptions.concept,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function uy(e){return{uuid:e.uuid,voided:!0}}function uv(e,t){let n=e.meta.initialValue?.omrsObject,r=e.questionOptions.rendering.startsWith("date")?ub(e,t):t;return{uuid:n.uuid,value:r,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function ub(e,t){if(e.datePickerFormat)switch(e.datePickerFormat){case"calendar":default:return tr()(t).format("YYYY-MM-DD");case"timer":return tr()(t).format("HH:mm");case"both":return tr()(t).format("YYYY-MM-DD HH:mm")}return t}function u_(e,t){let n=e.meta.initialValue?.omrsObject;return!ts(n)&&(c.FU.includes(e.questionOptions.rendering)?n.value.uuid!==t:tf(e,"date")?0!==tr()(t).diff(tr()(n.value),"D"):tf(e,"datetime")||"both"===e.datePickerFormat?0!==tr()(t).diff(tr()(n.value),"minute"):tf(e,"toggle")?n.value.uuid===c.t$!==t:n.value!==t)}function uw(e,t=[]){let n=e.meta.initialValue?.omrsObject;if(n?.length&&ts(t))return tm(e,null,n.map(e=>uy(e)));if(n?.length&&!ts(t)){let r=n.filter(e=>!t.includes(e.value.uuid));return tm(e,t.filter(e=>!n.some(t=>t.value.uuid===e)).map(t=>ug(e,t)),r.map(e=>uy(e)))}return tm(e,t.map(t=>ug(e,t)),void 0)}function ux(e,t=[]){let n=t.filter(e=>e.uuid&&e.voided).map(e=>({uuid:e.uuid,voided:!0})),r=e.meta.submission.newValue=t.filter(e=>!e.uuid).map(t=>({formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`,...t}));return tm(e,r,n)}function uE(e,t,n){let r=e.filter(e=>!!tf(n,"file")&&e.formFieldPath==`rfe-forms-${n.id}`||e.formFieldPath==`rfe-forms-${n.id}`&&e.concept.uuid==n.questionOptions.concept);if(!r?.length){let r=e.filter(e=>e.concept.uuid==n.questionOptions.concept);return t?.length?r.filter(e=>!t.includes(e.uuid)):r}return r}async function uk(e,t){let n=new AbortController,r=await Promise.all(t.map(e=>(0,u.getAttachmentByUuid)(e.uuid,n).then(e=>e.data).catch(t=>(console.error(`Failed to fetch attachment ${e.uuid}:`,t),null))));return e.meta.initialValue={omrsObject:t},r.filter(Boolean).map(e=>({uuid:e.uuid,base64Content:`${window.openmrsBase}${u.attachmentUrl}/${e.uuid}/bytes`,fileName:e.filename,fileDescription:e.comment,fileType:e.bytesContentFamily?.toLowerCase()}))}let uS={validate:(e,t)=>!ts(t)&&c.FU.includes(e.questionOptions.rendering)&&!(Array.isArray(t)?t:[t]).every(t=>e.questionOptions.answers?.find(e=>e.concept===t||e.value===t))?[{resultType:"error",errCode:"invalid.defaultValue",message:"Value not found in coded answers list"}]:ts(t)||"date"!=e.questionOptions.rendering||tr()(t).isValid()?!ts(t)&&"number"==e.questionOptions.rendering&&isNaN(t)?[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid numerical value: '${t}'`}]:[]:[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid date value: '${t}'`}]},uO=[],uD="testorder",uC="6f0c9a92-6f24-11e3-af88-005056821db0",uF={transformFieldValue:function(e,t,n){if(tp(e),"edit"===n.sessionMode&&e.meta.initialValue?.omrsObject)return uP(t,e,n.currentProvider.uuid);let r=uA(t,e,n.currentProvider.uuid);return tm(e,r,null),r},getInitialValue:function(e,t,n){let r=e.questionOptions.answers?.map(e=>e.concept)||[],i=t?.orders.filter(e=>!uO.includes(e.uuid)&&!e.voided).find(e=>r.includes(e.concept.uuid));return i?(e.meta={...e.meta||{},initialValue:{omrsObject:i,refinedValue:i.concept.uuid}},uO.push(i.uuid),i.concept.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){uO=[]}};function uA(e,t,n){return e?{action:"NEW",concept:e,type:t?.questionOptions?.orderType||uD,careSetting:t?.questionOptions?.orderSettingUuid||uC,orderer:n}:null}function uP(e,t,n){let r=t.meta.initialValue?.omrsObject;if(e===r?.concept?.uuid)return null;let i={uuid:r?.uuid,voided:!0};return tm(t,uA(e,t,n),i),t.meta.submission.newValue||null}let uT=[],uV={transformFieldValue:function(e,t,n){if(tp(e),e.meta.initialValue?.omrsObject&&ts(t))return tm(e,void 0,uN(e.meta.initialValue.omrsObject));if(!ts(t)){let r=e.meta.initialValue?.omrsObject;if(uI(r,t))return tm(e,uj(t,e,r,n.patient.id),void 0)}let r=uM(t,e,n.patient.id);return tm(e,r,null),r},getInitialValue:function(e,t,n){let r=(t??n.domainObjectValue).diagnoses.find(t=>t.formFieldPath===`rfe-forms-${e.id}`);return r?(e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r.diagnosis?.coded.uuid}},uT.includes(r.diagnosis?.coded?.uuid)||uT.push(r.diagnosis?.coded?.uuid),r.diagnosis?.coded.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){uT=[]}},uM=(e,t,n)=>e?{patient:n,condition:null,diagnosis:{coded:e},certainty:(0,np.H)(t.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:t.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${t.id}`,formFieldNamespace:"rfe-forms"}:null;function uj(e,t,n,r){return{patient:r,condition:null,diagnosis:{coded:e},certainty:(0,np.H)(t.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:t.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${t.id}`,formFieldNamespace:"rfe-forms",uuid:n.uuid}}function uI(e,t){return!ts(e)&&e.value!==t}function uN(e){return{uuid:e.uuid,voided:!0}}function uL(e,t,n,r,i){let{patient:o,formJson:a,domainObjectValue:l,formFields:s,visit:u,deletedFields:c}=e,d=[...s,...c],f=[];uY(f,d);let p=uQ(d),m=u4(d),h={};return l?(Object.assign(h,l),-1===h.encounterProviders.findIndex(e=>e.provider.uuid==r)&&(h.encounterProviders=[...h.encounterProviders,{provider:r,encounterRole:n}]),t&&(h.encounterDatetime=t),h.location=i,h.form={uuid:a.uuid},u&&(h.visit=u.uuid),h.obs=f,h.orders=p,h.diagnoses=m):(h={patient:o.id,location:i,encounterType:a.encounterType,encounterProviders:[{provider:r,encounterRole:n}],obs:f,form:{uuid:a.uuid},visit:u?.uuid,orders:p,diagnoses:m},t&&(h.encounterDatetime=t)),h}function uq(e,t){return e.filter(e=>"patientIdentifier"===e.type&&th(e)).map(e=>e.meta.submission.newValue)}function uR(e,t){return t.map(t=>(0,tj.savePatientIdentifier)(t,e.id))}function u$(e){return e.filter(e=>"personAttribute"===e.type&&th(e)).map(e=>e.meta.submission.newValue)}function uB(e,t){return t.map(t=>(0,tj.savePersonAttribute)(t,e.id))}function uH(e,t,n){let r=e.filter(e=>"programState"===e.type&&th(e)),i=new Map;return r.forEach(e=>{let r=e.questionOptions.programUuid,o=e.meta.submission.newValue,a=n.find(e=>e.program.uuid===r);a?i.has(r)?i.get(r).states.push(o):i.set(r,{uuid:a.uuid,states:[o]}):i.has(r)?i.get(r).states.push(o):i.set(r,{patient:t.id,program:r,states:[o],dateEnrolled:tr()().format()})}),Array.from(i.values())}function uz(e){let t=new AbortController;return Promise.all(e.map(e=>(0,tj.saveProgramEnrollment)(e,t)))}function uU(e,t,n){let r=e?.filter(e=>e?.questionOptions.rendering==="file"&&th(e));return r?.length?Promise.all(r.flatMap(e=>{let n="string"==typeof t?.patient?t?.patient:t?.patient?.uuid;return(e.meta.submission.newValue??[]).map(e=>(0,tj.createAttachment)(n,t.uuid,e))})):[]}function uW(e){let{formFields:t,location:n,currentProvider:r,customDependencies:i,sessionDate:o,domainObjectValue:a,visit:l}=e,{defaultEncounterRole:s}=i,u=t.find(e=>"encounterRole"===e.type)?.meta.submission?.newValue||s?.uuid,c=t.find(e=>"encounterProvider"===e.type)?.meta.submission?.newValue||r.uuid,d=t.find(e=>"encounterDatetime"===e.type)?.meta.submission?.newValue,f=l?.stopDatetime?o:void 0;return{encounterRole:u,encounterProvider:c,encounterDate:d??(a?.encounterDatetime?new Date(a.encounterDatetime):f),encounterLocation:t.find(e=>"encounterLocation"===e.type)?.meta.submission?.newValue||a?.location?.uuid||n.uuid}}function uY(e,t){t.filter(e=>u0(e)).forEach(n=>uJ(e,n,t))}function uJ(e,t,n){uX(t)&&t.meta.initialValue.omrsObject?uG(e,t):"obsGroup"===t.type?uZ(e,t,n):(tf(t,"file")||uK(e,t.meta.submission.newValue),uK(e,t.meta.submission.voidedValue))}function uZ(e,t,n){if(t.meta.submission?.voidedValue)return void uK(e,t.meta.submission.voidedValue);let r=ug(t,null);t.meta.initialValue?.omrsObject&&(r.uuid=t.meta.initialValue.omrsObject.uuid),t.questions.forEach(e=>{let t=n.find(t=>t.id===e.id)??e;if(uX(t))uG(r.groupMembers,t);else if("obsGroup"===t.type){let e=[];uZ(e,t,n),uK(r.groupMembers,e)}else th(t)&&(uK(r.groupMembers,t.meta.submission.newValue),uK(r.groupMembers,t.meta.submission.voidedValue))}),(r.groupMembers?.length||r.voided)&&uK(e,r)}function uG(e,t){let n=t.meta.initialValue?.omrsObject;n&&uK(e,(Array.isArray(n)?n:[n]).map(e=>uy(e)))}function uQ(e){return e.filter(e=>"testOrder"===e.type&&th(e)).flatMap(e=>uX(e)?[e.meta.submission.newValue?void 0:e.meta.submission.voidedValue]:[e.meta.submission.newValue,e.meta.submission.voidedValue]).filter(e=>e)}function uK(e,t){t&&(Array.isArray(t)?e.push(...t):e.push(t))}function uX(e){return!!(e.isHidden||e.isParentHidden)}function u0(e){let{questionOptions:{isTransient:t},type:n}=e;return!t&&!!["obs","obsGroup"].includes(n)&&!e.meta.groupId&&(!!(uX(e)&&e.meta.initialValue?.omrsObject)||!uX(e)&&("obsGroup"===n||th(e)))}function u1(e){if("toggle"==e.questionOptions.rendering&&"boolean"!=typeof e.questionOptions.defaultValue)return e.questionOptions.defaultValue==c.t$;let t=uS.validate(e,e.questionOptions.defaultValue);return t.length?(console.error(`Default value validation errors for field "${e.id}" with value "${e.questionOptions.defaultValue}":`,t),null):e.questionOptions.defaultValue}async function u2(e,t,n,r){let i=1,{formFieldAdapters:o}=r,a=t.obs.filter(t=>t.concept.uuid===e.questionOptions.concept&&t.uuid!=e.meta.initialValue?.omrsObject?.uuid&&!up.includes(t.uuid)),l=t.orders.filter(t=>(e.questionOptions.answers?.map(e=>e.concept)||[]).includes(t.concept?.uuid)&&!uO.includes(t.uuid));if("testOrder"===e.type)return Promise.all(l.filter(e=>!e.voided).map(async t=>{let a=uc(e,t,i++);return n[a.id]=await o[e.type].getInitialValue(a,{orders:[t]},r),a}));let s=t.diagnoses.filter(t=>!t.voided&&!uT.includes(t?.diagnosis?.coded.uuid)&&t.formFieldPath.startsWith(`rfe-forms-${e.id}_`));return"diagnosis"===e.type?Promise.all(s.map(async t=>{let i=parseInt(t.formFieldPath.split("_")[1]),a=uc(e,t,i);return n[a.id]=await o[e.type].getInitialValue(a,{diagnoses:[t]},r),uT.includes(t.diagnosis.coded.uuid)||uT.push(t.diagnosis.coded.uuid),a})):Promise.all(a.map(async t=>{let a=uc(e,t,i++);return await Promise.all(a.questions.map(async i=>{n[i.id]=await o[e.type].getInitialValue(i,{obs:[t]},r)})),up.push(t.uuid),[a,...a.questions]})).then(e=>e.flat())}function u4(e){return e.filter(e=>"diagnosis"===e.type&&th(e)).map(e=>uX(e)?e.meta.submission.newValue?void 0:e.meta.submission.voidedValue:e.meta.submission.newValue||e.meta.submission.voidedValue).filter(e=>e)}function u5(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u3{getDomainObject(){return this.domainObjectValue}async loadDependencies(e,t,n){return Promise.resolve({})}constructor(e){u5(this,"formJson",void 0),u5(this,"domainObjectValue",void 0),this.formJson=e}}var u6=n(1807),u9=n(7361),u7=n(6956),u8=n(7313),ce="[object String]";let ct=function(e){return"string"==typeof e||!(0,u7.A)(e)&&(0,u8.A)(e)&&(0,u9.A)(e)==ce};function cn(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!0),[o,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let t=new AbortController;return!ts(e.encounter)&&ct(e.encounter)?(0,u.openmrsFetch)(`${u.restBaseUrl}/encounter/${e.encounter}?v=${c.RZ}`,{signal:t.signal}).then(e=>{n(e.data),i(!1)}).catch(e=>{a(e)}):(ts(e.encounter)||n(e.encounter),i(!1)),()=>{t.abort()}},[e.encounter]),{encounter:t,error:o,isLoading:r}}var cr=n(3660),ci=n.n(cr);function co(){let{data:e,error:t,isLoading:n}=ci()(`${u.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,u.openmrsFetch),r=e?.data.results.find(e=>"Clinician"===e.name);return r?{encounterRole:r,error:t,isLoading:n}:{encounterRole:e?.data.results[0],error:t,isLoading:n}}var ca=n(1619),cl=n.n(ca);let cs=e=>{let t="custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(startDate,endDate,state:(uuid,name,retired,concept:(uuid),programWorkflow:(uuid)))",n=`${u.restBaseUrl}/programenrollment?patient=${e}&v=${t}`,{data:r,error:i,isLoading:o}=cl()(e?n:null,u.openmrsFetch),a=r?.data?.results.length>0?r?.data.results.sort((e,t)=>t.dateEnrolled>e.dateEnrolled?1:-1):null;return{activePrograms:a?.filter(e=>!e.dateCompleted),error:i,isLoading:o}},cu=(e,t)=>{let{activePrograms:n,error:r,isLoading:i}=cs(t.meta?.programs?.hasProgramFields?e:null);return{patientPrograms:n,errorFetchingPatientPrograms:r,isLoadingPatientPrograms:i}};function cc(e){let[t,n]=(0,d.useState)(!0),{encounter:r,isLoading:i}=cn(e.formJson),{encounterRole:o,isLoading:a}=co(),{isLoadingPatientPrograms:l,patientPrograms:s}=cu(e.patient?.id,e.formJson);return(0,d.useEffect)(()=>{n(l||i||a)},[l,i,a]),{data:{encounter:r,patientPrograms:s,encounterRole:o},isLoading:t,error:null,updateContext:(t,{setDomainObjectValue:n,setCustomDependencies:i})=>{e.processor.domainObjectValue=r,n(r),i(e=>({...e,patientPrograms:s,defaultEncounterRole:o}))}}}let cd={checkbox:[],toggle:!1,text:""},cf=["encounterProvider","encounterDatetime","encounterLocation","patientIdentifier","encounterRole","programState","personAttribute"];class cp extends u3{prepareFormSchema(e){let t=new Set;function n(e,r,i,o){e.id&&t.add(e.id),e.inlineRendering=e.inlineRendering??r.inlineRendering??i.inlineRendering??o.inlineRendering,e.readonly=e.readonly??r.readonly??i.readonly??o.readonly,e.questionOptions?.rendering!="fixed-value"||e.meta.fixedValue||(e.meta.fixedValue=e.value,delete e.value),(e.questionOptions?.rendering=="group"||"obsGroup"===e.type)&&e.questions?.forEach(t=>(t.readonly=t.readonly??e.readonly,n(t,r,i,o)))}return e.pages.forEach(t=>{t.sections.forEach(r=>{r.questions.forEach(i=>{n(i,r,t,e)})})}),ch(e,t),e}async processSubmission(e,t){let{encounterRole:n,encounterProvider:r,encounterDate:i,encounterLocation:o}=uW(e),a=(e,t,n)=>(0,u.translateFrom)(u6.L,e,t,n),l=uq(e.formFields,o),s=uL(e,i,n,r,o);try{await Promise.all(uR(e.patient,l)),l?.length&&(0,u.showSnackbar)({title:a("patientIdentifiersSaved","Patient identifier(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPatientIdentifiers","Error saving patient identifiers"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let t=u$(e.formFields);await Promise.all(uB(e.patient,t)),t?.length&&(0,u.showSnackbar)({title:a("personAttributesSaved","Person attribute(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPersonAttributes","Error saving person attributes"),description:e.join(", "),kind:"error",critical:!0})}try{let t=uH(e.formFields,e.patient,e.customDependencies.patientPrograms),n=await await uz(t);n?.length&&(0,u.showSnackbar)({title:a("patientProgramsSaved","Patient program(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPatientPrograms","Error saving patient program(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let{data:n}=await (0,tj.saveEncounter)(t,s,s.uuid),r=n.orders.map(e=>e.orderNumber),i=n.diagnoses.map(e=>e.display);r.length&&(0,u.showSnackbar)({title:a("ordersSaved","Order(s) saved successfully"),subtitle:r.join(", "),kind:"success",isLowContrast:!0}),i.length&&(0,u.showSnackbar)({title:a("diagnosisSaved","Diagnosis(es) saved successfully"),subtitle:i.join(", "),kind:"success",isLowContrast:!0});try{let r=await uU(e.formFields,n,t);r?.length&&(0,u.showSnackbar)({title:a("attachmentsSaved","Attachment(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){console.error("Error saving attachments",t);let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingAttachments","Error saving attachment(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}return n}catch(t){console.error("Error saving encounter",t);let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingEncounter","Error saving encounter"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}}getCustomHooks(){return{useCustomHooks:cc}}async getInitialValues(e){let{domainObjectValue:t,formFields:n,formFieldAdapters:r}=e,i={},o=[];if(t){await Promise.all(n.map(async n=>{let a=r[n.type];if(n.meta.initialValue?.omrsObject&&!ts(n.meta.initialValue.refinedValue)){i[n.id]=n.meta.initialValue.refinedValue;return}if(a){tf(n,"repeating")&&!n.meta?.repeat?.isClone&&o.push(n);let r=null;try{r=await a.getInitialValue(n,t,e),n.meta.initialValue.refinedValue=r}catch(e){console.error(e)}if("obsGroup"===n.type)return;if(ts(r)?ts(n.questionOptions.defaultValue)?i[n.id]=cd[n.questionOptions.rendering]??"":i[n.id]=u1(n):i[n.id]=r,n.questionOptions.calculate?.calculateExpression)try{await cm(n,i,e)}catch(e){console.error(e)}}else console.warn(`No adapter found for field type ${n.type}`)}));let a=await Promise.all(o.flatMap(n=>u2(n,t,i,e))).then(e=>e.flat());n.push(...a)}else{let t=n.filter(e=>"group"!==e.questionOptions.rendering&&"obsGroup"!==e.type),o=[];await Promise.all(t.map(async t=>{let n=r[t.type];if(i[t.id]=cd[t.questionOptions.rendering]??null,ts(i[t.id])&&cf.includes(t.type))try{i[t.id]=await n.getInitialValue(t,null,e)}catch(e){console.error(e)}t.questionOptions.defaultValue&&(i[t.id]=u1(t)),t.questionOptions.calculate?.calculateExpression&&o.push(t)})),await Promise.all(o.map(async t=>{try{await cm(t,i,e)}catch(e){console.error(e)}}))}return i}async loadDependencies(e,t,{setPreviousDomainObjectValue:n}){let{patient:r,formJson:i}=e;return n(await (0,tj.getPreviousEncounter)(r?.id,i.encounterType)),e}async getHistoricalValue(e,t){let{formFields:n,sessionMode:r,patient:i,methods:{getValues:o},formFieldAdapters:a,previousDomainObjectValue:l,visit:s}=t,u={value:e,type:"field"},c=a[e.type];if(e.historicalExpression){let t=await t1(e.historicalExpression,u,n,o(),{mode:r,patient:i,previousEncounter:l,visit:s});return t?nr(e,t):null}return l&&e.questionOptions.enablePreviousValue?await c.getPreviousValue(e,l,t):null}}async function cm(e,t,n){let{formFields:r,sessionMode:i,patient:o,visit:a}=n,l=e.questionOptions.calculate.calculateExpression,s={value:e,type:"field"},u={mode:i,patient:o,visit:a},c=await t1(l,s,r,t,u);ts(c)||(t[e.id]=c)}function ch(e,t){let n=/(['"])([a-zA-Z_][a-zA-Z0-9_]*)\1/g;function r(e,r){for(let i of e.matchAll(n)){let e=i[2];t.has(e)&&console.error(`The calculateExpression for the field '${r}' incorrectly quotes the field ID '${e}' as a string. Field IDs must be referenced as variables without quotes to access their values. Remove the quotes: use ${e} instead of '${e}'.`)}}function i(e){e.questionOptions?.calculate?.calculateExpression&&r(e.questionOptions.calculate.calculateExpression,e.id),e.questions&&e.questions.forEach(i)}e.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(i)})})}var cg=n(9804);function cy(e){let{formFields:t,formFieldValidators:n,patient:r,sessionMode:i,addInvalidField:o,updateFormField:a,methods:{getValues:l,trigger:s}}=e,u=l();return 0===t.filter(e=>!e.isHidden&&!e.isParentHidden&&!e.isDisabled&&!e.meta.submission?.unspecified).flatMap(e=>e.validators?.flatMap(l=>{let s=n[l.type];if(s){let n=s.validate(e,u[e.id],{formFields:t,values:u,expressionContext:{patient:r,mode:i},...l}).filter(e=>"error"===e.resultType);return n.length&&(e.meta.submission={...e.meta.submission,errors:n},a(e),o(e)),n}})).filter(e=>!!e).length}async function cv(e,t,n,r,i){return Promise.all(e.map(async({postAction:e,config:o,actionId:a,enabled:l})=>{try{let i=[];if(t)if(t.forEach(e=>{e?.data&&i.push(e.data),e?.uuid&&i.push(e)}),i.length)(!l||(0,cg.g)(l,i))&&await e.applyAction({patient:n,sessionMode:r,encounters:i},o);else throw Error("No encounter data to process post submission action");else throw Error("No handlers available to process post submission action")}catch(t){let e=(0,ns.j)(t);(0,u.showSnackbar)({title:String(i("errorDescriptionTitle",a?a.replace(/([a-z])([A-Z])/g,"$1 $2"):"Post Submission Error")),subtitle:String(i("errorDescription","{{errors}}",{errors:e.join(", ")})),kind:"error",isLowContrast:!1})}}))}function cb({patientUuid:e,formUuid:t,setIsSubmitting:n,setIsValidating:r}){let{t:i}=(0,e9.useTranslation)();(0,d.useEffect)(()=>{let o=o=>{let{formUuid:a,patientUuid:l,action:s}=o.detail;if(!s||!a||!l)return void(0,ns.N)(Error("The form action event is missing required details (formUuid, patientUuid, or action)."),i("formActionFailed","Form action failed"));if(a===t&&l===e)switch(s){case"onSubmit":n(!0);break;case"validateForm":r(!0);break;default:(0,ns.N)(Error(`Unsupported form action: "${s}"`),i("formActionFailed","Form action failed"))}};return window.addEventListener("ampath-form-action",o),()=>{window.removeEventListener("ampath-form-action",o)}},[n,r,t,e])}function c_(e){let[t,n]=(0,d.useState)([]);return(0,d.useEffect)(()=>{let t=[];e?.length&&e.map(e=>{let n="string"==typeof e?e:e.actionId;dC(n)?.then(r=>t.push({postAction:r,config:e.config,actionId:n,enabled:e.enabled}))}),n(t)},[e]),t}let cw=(0,d.createContext)(void 0),cx=({patient:e,patientUUID:t,sessionMode:n,sessionDate:r,formJson:i,workspaceLayout:o,location:a,provider:l,visit:s,isFormExpanded:c=!0,children:p,isLoadingDependencies:m=!1,formSubmissionProps:h,hideFormCollapseToggle:g,handleConfirmQuestionDeletion:y,setIsFormDirty:v})=>{let{t:b}=(0,e9.useTranslation)(),_=(0,d.useRef)(void 0),w=(0,d.useRef)({}),x=(0,u.useLayoutType)(),{isSubmitting:E,setIsSubmitting:k,onSubmit:S,onError:O,handleClose:D}=h,[C,F]=(0,d.useState)(!1),A=c_(i.postSubmissionActions),P=new AbortController,T=(0,d.useCallback)((e,t,n)=>{t?w.current[e]=n:_.current=n},[]),V=(0,d.useRef)({EncounterFormProcessor:cp}),M=(0,d.useCallback)(()=>{let e=[_.current,...Object.values(w.current)],t=e.every(e=>cy(e));return{forms:e,isValid:t}},[]);return cb({patientUuid:t,formUuid:i?.uuid,setIsSubmitting:k,setIsValidating:F}),(0,d.useEffect)(()=>{C&&(m||M(),F(!1))},[C,M,m]),(0,d.useEffect)(()=>{if(E){if(m)return void k(!1);let{forms:t,isValid:r}=M();r?Promise.all(t.map(e=>e.processor.processSubmission(e,P))).then(async t=>{h.setIsSubmitting(!1),"edit"===n?(0,u.showSnackbar)({title:b("updatedRecord","Record updated"),subtitle:b("updatedRecordDescription","The patient encounter was updated"),kind:"success",isLowContrast:!0}):(0,u.showSnackbar)({title:b("submittedForm","Form submitted"),subtitle:b("submittedFormDescription","Form submitted successfully"),kind:"success",isLowContrast:!0}),A&&await cv(A,t,e,n,b),g(),S?S(t):D()}).catch(e=>{k(!1),e instanceof Error?(0,u.showSnackbar)({title:b("errorProcessingFormSubmission","Error processing form submission"),kind:"error",subtitle:e.message,isLowContrast:!1}):(0,u.showSnackbar)(e)}):k(!1)}return()=>{P.abort()}},[E,M,m]),f().createElement(cw.Provider,{value:{patient:e,sessionMode:n,sessionDate:r,formJson:i,formProcessors:V.current,layoutType:x,workspaceLayout:o,visit:s,location:a,provider:l,isFormExpanded:c,registerForm:T,handleConfirmQuestionDeletion:y,setIsFormDirty:v}},V.current&&p)},cE=()=>{let e=(0,d.useContext)(cw);if(!e)throw Error("useFormFactoryContext must be used within a FormFactoryProvider");return e},ck={actionButtons:"-esm-form-engine__repeat-controls__actionButtons___RPDJa"},cS=function({question:e,rows:t,handleDelete:n,handleAdd:r,questionIndex:i}){let{t:o}=(0,e9.useTranslation)();return f().createElement("div",{className:ck.actionButtons},i>0&&f().createElement(y.Button,{className:ck.button,kind:"danger",onClick:n},f().createElement("span",null,o("remove","Remove"))),i===t.length-1&&f().createElement(y.Button,{className:ck.button,iconDescription:o("add","Add"),kind:"primary",disabled:uf(e.questionOptions.repeatOptions?.limit,t.length),onClick:r},f().createElement("span",null,e.questionOptions.repeatOptions?.addText||o("add","Add"))))},cO="-esm-form-engine__repeat__nodeContainer___WpV+2",cD="-esm-form-engine__repeat__divider___m-qDa",cC={obsGroup:"group",testOrder:"select",diagnosis:"ui-select-extended"};function cF(e){return e.questions?.length?e.questions?.some(e=>!e.isHidden):!e.isHidden}function cA(e){return{...e,questionOptions:{...e.questionOptions,rendering:cC[e.type]||null}}}let cP=({field:e})=>{let[t,n]=(0,d.useState)([]),r=ng(),{handleConfirmQuestionDeletion:i}=cE(),{patient:o,sessionMode:a,formFieldAdapters:l,formFields:s,methods:{getValues:c,setValue:p,unregister:m},addFormField:h,removeFormField:g,deletedFields:y,setDeletedFields:v,visit:b}=r;(0,d.useEffect)(()=>{n(s.filter(t=>t.questionOptions.concept===e.questionOptions.concept&&t.id.startsWith(e.id)&&!t.meta?.repeat?.wasDeleted))},[s,e]);let _=(0,d.useCallback)(i=>{let u=[];function d(e){e.hide?.hideWhenExpression&&(e.isHidden=t0(e.hide.hideWhenExpression,{value:e,type:"field"},[...s,...u],c(),{mode:a,patient:o,visit:b})),e.questionOptions.calculate?.calculateExpression&&t1(e.questionOptions.calculate?.calculateExpression,{value:e,type:"field"},[...s,...u],c(),{mode:a,patient:o,visit:b}).then(t=>{ts(t)||(p(e.id,t),l[e.type]?.transformFieldValue(e,t,r))})}let f=uc(e,null,i);u.push(f),"obsGroup"===f.type&&f.questions?.forEach(e=>{u.push(e)}),u.forEach(e=>{d(e),h(e)}),n([...t,f])},[s,e,t,r]),w=e=>{e.meta.initialValue?.omrsObject?(l[e.type]?.transformFieldValue(e,null,r),e.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},"obsGroup"===e.type&&e.questions.forEach(t=>{t.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},l[t.type]?.transformFieldValue(t,null,r)})):(tp(e),m(e.id),e.questions?.forEach(e=>m(e.id))),n(t.filter(t=>t.id!==e.id)),v([...y,e]),g(e.id)},x=e=>{if(i&&"function"==typeof i){let t=i(e);t&&"function"==typeof t.then&&"function"==typeof t.catch?t.then(()=>w(e)).catch(()=>(0,u.createErrorHandler)()):"boolean"==typeof t?t&&w(e):w(e)}else w(e)},E=(0,d.useMemo)(()=>t.map((n,r)=>{let i=f().createElement(nT,{fieldId:n.id,valueAdapter:l[n.type],repeatOptions:{targetRendering:cA(n).questionOptions.rendering}});return f().createElement("div",{key:n.id+"_wrapper"},0!==r&&f().createElement("div",null,f().createElement("hr",{className:cD})),f().createElement("div",{className:cO},i),!tg(a)&&f().createElement(cS,{question:n,rows:t,questionIndex:r,handleDelete:()=>{x(n)},handleAdd:()=>{_(t.reduce((t,n)=>{let r=Number(n.id.slice(e.id.length+1));return Number.isFinite(r)?Math.max(t,r):t},0)+1)}}))}),[t]);return!e.isHidden&&E&&cF(e)?f().createElement(f().Fragment,null,f().createElement("div",null,E)):null};var cT=n(5848);let cV={label:"-esm-form-engine__file__label___rUrrs",thumbnailGrid:"-esm-form-engine__file__thumbnailGrid___FRMXX",thumbnailContainer:"-esm-form-engine__file__thumbnailContainer___4S7Rq"},cM="-esm-form-engine__file-thumbnail__thumbnail___AGjAZ",cj="-esm-form-engine__file-thumbnail__imageThumbnail___nKfAe",cI="-esm-form-engine__file-thumbnail__pdfThumbnail___CfkjD",cN="-esm-form-engine__file-thumbnail__removeButton___DhEu3",cL="-esm-form-engine__file-thumbnail__closeIcon___zKRmf";var cq=n(529),cR=n(1899);function c$({bytesContentFamily:e,removeFileCb:t,...n}){let r=(0,d.useMemo)(()=>{switch(e){case"image":return cB;case"pdf":return cH;default:return cz}},[]);return f().createElement("div",{className:cM},f().createElement(r,n),f().createElement(y.Button,{kind:"ghost",className:cN,onClick:t},f().createElement(cq.bm,{size:16,className:cL})))}function cB(e){return f().createElement("img",{className:cj,src:e.src,alt:e.title})}function cH(e){return f().createElement("div",{className:cI,role:"button",tabIndex:0},f().createElement(cR.aD,{size:24}))}function cz(e){return f().createElement("div",{className:cI,role:"button",tabIndex:0},f().createElement(cR.WZ,{size:24}))}let cU=[{name:"drug",baseControlComponent:ur},{name:"problem",baseControlComponent:ur},{name:"encounter-provider",baseControlComponent:ur},{name:"encounter-location",baseControlComponent:ur},{name:"select-concept-answers",baseControlComponent:ur},{name:"encounter-role",baseControlComponent:ur}],cW=[{name:"text",component:sL},{name:"textarea",component:sI},{name:"select",component:sM},{name:"checkbox",component:sD},{name:"radio",component:sT},{name:"date",component:n8},{name:"datetime",component:n8},{name:"number",component:sF},{name:"content-switcher",component:n2},{name:"toggle",component:sR},{name:"workspace-launcher",component:us},{name:"group",component:nN},{name:"repeating",component:cP},{name:"markdown",component:sS},{name:"fixed-value",component:re},{name:"ui-select-extended",component:ur},{name:"file",component:({field:e,value:t,setFieldValue:n})=>{let{t:r}=(0,e9.useTranslation)(),{sessionMode:i}=ng(),o="tablet"===(0,u.useLayoutType)(),a=(0,d.useCallback)(()=>{let r=(0,u.showModal)("capture-photo-modal",{saveFile:e=>(e.capturedFromWebcam&&!e.fileName.includes(".")&&(e.fileName=`${e.fileName}.png`),n([...t||[],e]),r(),Promise.resolve()),closeModal:()=>{r()},allowedExtensions:e.questionOptions.allowedFileTypes,multipleFiles:e.questionOptions.allowMultiple,collectDescription:!0})},[t,e]),l=(0,d.useCallback)(e=>{let r=[...t],i=r[e];i.uuid?r[e]={...i,voided:!0}:r.splice(e,1),n(r)},[t]);return tg(i)&&!t?f().createElement(nU,{label:r(e.label),value:null,conceptName:e.meta.concept?.display,isInline:!1}):f().createElement("div",null,f().createElement("div",{className:m()(cV.label,"cds--label")},f().createElement(n1,{field:e})),!tg(i)&&f().createElement("div",null,f().createElement(y.Button,{className:cV.uploadButton,kind:o?"ghost":"tertiary",onClick:a,renderIcon:e=>f().createElement(cT.OM,{size:16,...e})},e.questionOptions.buttonLabel?r(e.questionOptions.buttonLabel):r("addFile","Add file"))),f().createElement("div",{className:cV.thumbnailGrid},t&&t.filter(e=>!e.voided).map((e,t)=>f().createElement("div",{className:cV.thumbnailContainer},f().createElement(c$,{title:e.fileName,src:e.base64Content,bytesContentFamily:e.fileType,removeFileCb:()=>l(t)})))))}},...s3.map(e=>({name:e.name,component:cU.find(t=>t.name===e.name).baseControlComponent}))],cY={validate:(e,t,n)=>{let r=new Date,i=t?[]:ta.validate(e,t);return i.length?i:t&&!(0,np.H)(n?.allowFutureDates)&&t.getTime&&t.getTime()>r.getTime()?[{resultType:"error",errCode:"value.invalid",message:"Future dates not allowed"}]:[]}},cJ=[{name:"default_value",component:uS},{name:"form_field",component:ta},{name:"date",component:cY},{name:"js_expression",component:{validate:function(e,t,n){let r="value.invalid",i="Invalid value",o="Field has warnings";return n.expressionContext.myValue=t,Object.keys(n).filter(e=>"failsWhenExpression"===e||"warnsWhenExpression"===e).flatMap(a=>{let l="failsWhenExpression"===a;return t0(n[a],{value:e,type:"field"},n.formFields,{...n.values,[e.id]:t},n.expressionContext)?[{resultType:l?"error":"warning",errCode:l?r:null,message:n.message?n.message:l?i:o}]:[]})}}},{name:"conditionalAnswered",component:{validate:function(e,t,n){let{referenceQuestionId:r,referenceQuestionAnswers:i,values:o,formFields:a,message:l}=n,s=o[a.find(e=>e.id===r).id];return ts(t)||i.includes(s)?[]:[{resultType:"error",errCode:"invalid.valueSelected",message:l}]}}}];function cZ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class cG{fetchData(e){return(0,u.openmrsFetch)(e?`${this.url}&q=${e}`:this.url).then(({data:e})=>e.results)}fetchSingleItem(e){let t=this.url;if(t.includes("?")){let n=t.split("?");t=`${n[0]}/${e}?${n[1]}`}else t=`${t}/${e}`;return(0,u.openmrsFetch)(t).then(({data:e})=>e)}toUuidAndDisplay(e){if(void 0===e.uuid||void 0===e.display)throw Error("'uuid' or 'display' not found in the OpenMRS object.");return e}constructor(e){cZ(this,"url",void 0),this.url=e}}let cQ="custom:(uuid,display,conceptClass:(uuid,display))",cK="custom:(uuid,display,conceptClass:(uuid,display),mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid))))",cX="35543629-7d8c-11e1-909d-c80aa9edcf4e";class c0 extends cG{fetchData(e,t){if(ts(t?.class)&&ts(t?.concept)&&!t?.useSetMembersByConcept&&ts(e))return Promise.resolve([]);let n=t?.conceptSourceUuid?cK:cQ,r=`${u.restBaseUrl}/concept?name=&searchType=fuzzy&v=${n}`;if(t?.class)if("string"!=typeof t.class)return(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results.filter(e=>e.conceptClass&&t.class.includes(e.conceptClass.uuid)));else{let e=r.split("searchType=fuzzy");r=`${e[0]}searchType=fuzzy&class=${t.class}&${e[1]}`}if(t?.concept&&t?.useSetMembersByConcept){let n=r.split("?name=&searchType=fuzzy&v="),i=t?.conceptSourceUuid?"custom:(uuid,setMembers:(uuid,display,mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid)))))":"custom:(uuid,setMembers:(uuid,display))";return r=`${n[0]}/${t.concept}?v=${i}`,(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.setMembers)}return(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results)}fetchSingleItem(e,t){let n=t?.conceptSourceUuid?cK:cQ;return(0,u.openmrsFetch)(`${u.restBaseUrl}/concept/${e}?v=${n}`).then(({data:e})=>e)}toUuidAndDisplay(e,t){let n=super.toUuidAndDisplay(e),r=this.getConceptSourceMapping(e,t?.conceptSourceUuid)?.conceptReferenceTerm?.code;return r?{...n,code:r}:n}getConceptSourceMapping(e,t){if(!t)return;let n=e.mappings?.filter(e=>e.conceptReferenceTerm?.conceptSource?.uuid===t)??[];return n.find(e=>e.conceptMapType?.uuid===cX||e.conceptMapType?.display?.toUpperCase()==="SAME-AS")??n[0]}constructor(){super(`${u.restBaseUrl}/concept?v=${cQ}`)}}class c1 extends cG{fetchData(e,t,n){let r=this.url,i=r.split("?");return t?.tag&&(r=`${i[0]}?tag=${t.tag}&${i[1]}`),n&&(r=`${i[0]}/${n}?${i[1]}`),(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results?e.results:e)}constructor(){super(`${u.restBaseUrl}/location?v=custom:(uuid,display)`)}}class c2 extends cG{async fetchData(e,t){let n="v=custom:(uuid,display)",r=`${u.restBaseUrl}/provider?${n}`,{data:i}=await (0,u.openmrsFetch)(e?`${r}&q=${e}`:r);return i?.results}async fetchSingleItem(e){let{data:t}=await (0,u.openmrsFetch)(`${u.restBaseUrl}/provider/${e}?v=custom:(uuid,display)`);return t}constructor(){super(null)}}class c4 extends cG{fetchSingleItem(e){return(0,u.openmrsFetch)(this.buildUrl(e)).then(({data:e})=>e)}fetchData(e,t){let n=this.buildUrl(t.referencedValue||t.concept);return(0,u.openmrsFetch)(n).then(({data:e})=>e.setMembers.length?e.setMembers:e.answers)}buildUrl(e){return this.url.replace(":conceptUuid",e)}constructor(){super(`${u.restBaseUrl}/concept/:conceptUuid?v=custom:(uuid,display,setMembers:(uuid,display),answers:(uuid,display))`)}}class c5 extends cG{async fetchData(e,t){let n="v=custom:(uuid,display,name)",r=`${u.restBaseUrl}/encounterrole?${n}`,{data:i}=await (0,u.openmrsFetch)(e?`${r}&q=${e}`:r);return i?.results}constructor(){super(null)}}let c3=[{name:"location_datasource",component:new c1},{name:"drug_datasource",component:new c0},{name:"problem_datasource",component:new c0},{name:"select_concept_answers_datasource",component:new c4},{name:"provider_datasource",component:new c2},{name:"encounter_role_datasource",component:new c5}],c6=[{name:"ProgramEnrollmentSubmissionAction",load:()=>n.e("8720").then(n.bind(n,3696))},{name:"MarkPatientAsDeceasedAction",load:()=>n.e("5897").then(n.bind(n,8128))}];function c9(e,t,n){if("programState"===e.type){let e=n.meta??{};e.programs=e.programs?{...e.programs,hasProgramFields:!0}:{hasProgramFields:!0},n.meta=e}try{c8(e),dt(e),dn(e),dr(e),e.questions?.length&&("obsGroup"===e.type&&e.questions.length?e.questions.forEach(e=>c9(e,t,n)):e.questions.forEach(e=>c9(e,t,n))),e.meta.pageId=t.id}catch(e){console.error(e)}}function c7(e){let t=[];return e?.forEach(e=>{if(t.push(e),"inlineDate"!==e.type&&(0,np.H)(e.questionOptions?.showDate)){let n={id:`${e.id}_inline_date`,label:`Date for ${e.label}`,type:"inlineDate",questionOptions:{rendering:"date",isTransient:!0},validators:e.questionOptions.shownDateOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownDateOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.obsDatetime}}};t.push(n)}}),t}function c8(e){de(e,"readonly"),de(e,"required"),de(e,"unspecified"),de(e.questionOptions,"disallowDecimals"),de(e.questionOptions,"isSearchable"),de(e.questionOptions,"isTransient"),de(e.questionOptions,"enablePreviousValue"),de(e.questionOptions,"allowMultiple"),e.meta||(e.meta={submission:null,initialValue:{omrsObject:null,refinedValue:null}})}function de(e,t){if(e&&"string"==typeof e[t]){let n=e[t].trim().toLowerCase();("true"===n||"false"===n)&&(e[t]="true"===n)}return e}function dt(e){!tf(e,"group")&&(e.validators=e.validators||[],0>e.validators.findIndex(e=>"form_field"===e.type)&&e.validators.push({type:"form_field"}),0>e.validators.findIndex(e=>"default_value"===e.type)&&e.validators.push({type:"default_value"}))}function dn(e){switch(e.type){case"encounterProvider":e.questionOptions.rendering="encounter-provider";break;case"encounterLocation":e.questionOptions.rendering="encounter-location";break;case"encounterRole":e.questionOptions.rendering="encounter-role";break;case"encounterDatetime":e.questionOptions.rendering=tf(e,"ui-select-extended")?"date":e.questionOptions.rendering;break;case"diagnosis":dc(e)}}function dr(e){switch(e.questionOptions.rendering){case"checkbox-searchable":case"multiCheckbox":di(e);break;case"numeric":e.questionOptions.rendering="number";break;case"select-concept-answers":dl(e);break;case"repeating":case"group":da(e);break;case"date":e.datePickerFormat=e.datePickerFormat??"calendar";break;case"datetime":e.datePickerFormat=e.datePickerFormat??"both";break;case"workspace-launcher":case"markdown":e.type="control";break;case"drug":case"problem":e.questionOptions.isSearchable=!0}return e}function di(e){"multiCheckbox"===e.questionOptions.rendering&&(e.questionOptions.rendering="checkbox-searchable",(0,np.H)(e.inlineMultiCheckbox)&&(e.questionOptions.rendering="checkbox")),tf(e,"checkbox-searchable")&&(e.questionOptions.rendering="checkbox",e.questionOptions.isCheckboxSearchable=!0)}function da(e){tf(e,"group")&&e.questions?.length&&e.questions.forEach(da),"testOrder"===e.type&&e.questionOptions.selectableOrders?.length&&(e.questionOptions.answers=e.questionOptions.selectableOrders||[],delete e.questionOptions.selectableOrders)}function dl(e){e.questionOptions.isSearchable=!0,e.questionOptions.datasource?.config||(e.questionOptions.datasource={name:"select_concept_answers_datasource",config:{concept:e.questionOptions.concept}})}function ds(e){if(e.meta.programs.isEnrollment||e.meta.programs.discontinuationDateQuestionId){let t={programUuid:e.meta.programs.uuid};e.meta.programs.isEnrollment?t.enrollmentDate="":t.completionDate=e.meta.programs.discontinuationDateQuestionId,e.postSubmissionActions=[{actionId:"ProgramEnrollmentSubmissionAction",enabled:"true",config:t}]}}function du(e){let t=[];return e?.forEach(e=>{if(t.push(e),"obsComment"!==e.type&&(0,np.H)(e.questionOptions?.showComment)){let n={id:`${e.id}_obs_comment`,label:`Comment for ${e.label}`,type:"obsComment",questionOptions:{rendering:"text",isTransient:!0},validators:e.questionOptions.shownCommentOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownCommentOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.comment}}};t.push(n)}}),t}function dc(e){if("dataSource"in e.questionOptions&&"diagnoses"===e.questionOptions.dataSource||"diagnosis"===e.type){let t=e.questionOptions.datasource?.config;e.questionOptions.datasource={name:"problem_datasource",config:{...t,class:e.questionOptions.diagnosis?.conceptClasses??t?.class}},e.questionOptions.diagnosis?.conceptSet&&(e.questionOptions={...e.questionOptions,concept:e.questionOptions.diagnosis?.conceptSet,datasource:{name:"problem_datasource",config:{...t,concept:e.questionOptions.diagnosis.conceptSet,useSetMembersByConcept:!0}}}),e.questionOptions.isSearchable=!0,delete e.questionOptions.dataSource}}function dd(e,t){Object.entries(t).forEach(([t,n])=>{e?.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(e=>{e.id===t?e.questionOptions.defaultValue=n:Array.isArray(e?.questions)&&e.questions.length>0&&e.questions.forEach(e=>{e.id===t&&(e.questionOptions.defaultValue=n)})})})})})}let df=[{name:"DefaultFormSchemaTransformer",component:{transform:(e,t)=>(de(e,"readonly"),e.pages.forEach((t,n)=>{let r=t.label??"";t.id=`page-${r.replace(/\s/g,"")}-${n}`,de(t,"readonly"),t.sections&&t.sections.forEach(n=>{n.questions=c7(n.questions),n.questions=du(n.questions),de(n,"readonly"),de(n,"isExpanded"),n?.questions?.forEach((n,r)=>c9(n,t,e))})}),t&&"object"==typeof t&&dd(e,t),e.meta?.programs&&ds(e),e)}}];function dp(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].provider}return null}function dm(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].encounterRole}return null}function dh(e,t){return u_(e,t)||!ts(e.meta.submission.newValue.obsDatetime)}let dg=[{type:"obs",component:um},{type:"control",component:{getDisplayValue:(e,t)=>t,transformFieldValue:function(e,t,n){return null},getInitialValue:function(e,t,n){return null},getPreviousValue:function(e,t,n){return null},tearDown:function(){}}},{type:"obsGroup",component:um},{type:"testOrder",component:uF},{type:"programState",component:{transformFieldValue:function(e,t,n){if(tp(e),e.meta?.initialValue?.omrsObject?.uuid===t||ts(t))return null;e.meta.submission.newValue={state:t,startDate:tr()().format()}},getInitialValue:function(e,t,n){let r=n.customDependencies.patientPrograms?.find(t=>t.program.uuid===e.questionOptions.programUuid);if(r?.states?.length>0){let t=r.states.filter(e=>!e.endDate).find(t=>t.state.programWorkflow?.uuid===e.questionOptions.workflowUuid)?.state;return e.meta={...e.meta||{},initialValue:{omrsObject:t}},t?.uuid}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterLocation",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){return t&&t.location?.uuid?t.location.uuid:n.location.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;return{value:r?.location?.uuid,display:r?.location?.name}},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterProvider",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){let r=dp(t);return r?.uuid?r.uuid:n.currentProvider?.uuid},getPreviousValue:function(e,t,n){let r=dp(t??n.previousDomainObjectValue);return{value:r?.uuid,display:r?.name}},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterRole",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){let r=t??n.domainObjectValue;return r?dm(r)?.uuid:n.customDependencies.defaultEncounterRole.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let e=dm(r);return{value:e?.uuid,display:e?.name}}return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"obsComment",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=r.meta.initialValue?.omrsObject;if(r.meta.submission?.newValue)ts(t)&&!dh(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.comment=t;else if(!th(r)&&o){if(ts(t)&&ts(o.comment))return null;let e=uv(r,i);r.meta.submission={newValue:{...e,comment:t}}}return null},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_obs_comment")[0],r=n.formFields.find(e=>e.id===t);return r?.meta.initialValue.omrsObject?.comment}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterDatetime",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){return t?.encounterDatetime?new Date(t.encounterDatetime):n.sessionDate},getPreviousValue:function(e,t,n){if(t?.encounterDatetime){let n=new Date(t.encounterDatetime);return{value:n,display:this.getDisplayValue(e,n)}}return null},getDisplayValue:function(e,t){return(0,u.formatDate)(t)},tearDown:function(){}}},{type:"inlineDate",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=t instanceof Date?(0,u.toOmrsIsoString)(t):t;if(r.meta.submission?.newValue)ts(o)&&!dh(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.obsDatetime=o;else if(!th(r)&&r.meta.initialValue?.omrsObject){if(ts(t)&&ts(r.meta.initialValue.omrsObject?.obsDatetime))return null;let e=uv(r,i);r.meta.submission={newValue:{...e,obsDatetime:o}}}},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_inline_date")[0],r=n.formFields.find(e=>e.id===t),i=r?.meta.initialValue?.omrsObject;if(i?.obsDatetime)return(0,u.parseDate)(i.obsDatetime)}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?(0,u.formatDate)(t):null},tearDown:function(){}}},{type:"patientIdentifier",component:{transformFieldValue:function(e,t,n){return(tp(e),e.meta.initialValue?.refinedValue===t||ts(t))?null:(e.meta.submission.newValue={identifier:t,identifierType:e.questionOptions.identifierType,uuid:e.meta.initialValue?.omrsObject?.id,location:n.location},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.identifier?.find(t=>t.type?.coding[0]?.code===e.questionOptions.identifierType);return e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r?.value}},r?.value},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"personAttribute",component:{transformFieldValue:function(e,t,n){return(tp(e),e.meta.initialValue?.refinedValue===t||ts(t))?null:(e.meta.submission.newValue={value:t,attributeType:e.questionOptions.attributeType,uuid:e.meta.initialValue?.omrsObject?.uuid},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.extension?.find(t=>t.url===`http://fhir.openmrs.org/ext/person-attribute/${e.questionOptions.attributeType}`);return e.meta={...e.meta,initialValue:{omrsObject:r,refinedValue:r?.valueString||r?.valueReference?.reference}},e.meta.initialValue.refinedValue},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"diagnosis",component:uV}],dy={},dv={},db={},d_={},dw={},dx={};function dE(e,t){dT().expressionHelpers[e]=t}async function dk(e){if(dv[e])return dv[e];let t=cW.find(t=>t.name===e||t?.alias===e)?.component;if(!t){let n=await dT().controls.find(t=>t.name===e||t?.alias===e)?.load?.();t=n?.default}return dv[e]=t,t}function dS(e){return dV(e)&&!tf(e,"file")?(e.disabled=!0,e.isDisabled=!0,dk("text")):dk(e.questionOptions.rendering)}async function dO(e){if(db[e])return db[e];let t=dg.find(t=>t.type===e)?.component;if(!t){let n=await dT().fieldValueAdapters.find(t=>t.type===e)?.load?.();t=n?.default}return db[e]=t,t}async function dD(){let e=[],t=dx;if(Object.keys(t).length)return Object.values(t);let n=dT().formSchemaTransformers||[];return e.push(...(await Promise.all(n.map(async e=>{let t=await e.load?.();return t?.default}))).filter(e=>void 0!==e)),e.push(...df.map(e=>e.component)),e.forEach(e=>{dx[df.find(t=>t.component===e).name]=e}),e}async function dC(e){let t=d_[e];if(t)return t;let n=c6.find(t=>t.name===e);if(n){let t=n.load,r=await t();return d_[e]=r.default,r.default}let r=dT().postSubmissionActions.find(t=>t.name===e);if(r){let t=r.load,n=await t();return d_[e]=n.default,n.default}return console.error(`No loader found for PostSubmissionAction registration of id: ${e}`),null}async function dF(e){if(dy[e])return dy[e];let t=cJ.find(t=>t.name===e)?.component;if(!t){let n=await dT().fieldValidators.find(t=>t.name===e)?.load?.();t=n?.default}return dy[e]=t,t}async function dA(e){if(dw[e])return dw[e];let t=c3.find(t=>t.name===e)?.component;if(!t){let n=s6(e);if(n)t=c3.find(e=>e.name===n.datasource.name)?.component;else{let n=await dT().dataSources.find(t=>t.name===e)?.load?.();if(!n)throw Error("Datasource not found");t=n.default}}return dw[e]=t,t}function dP(){return dT().expressionHelpers}function dT(){return(0,u.getGlobalStore)(c.RA,{controls:[],postSubmissionActions:[],expressionHelpers:{},fieldValidators:[],fieldValueAdapters:[],dataSources:[],formSchemaTransformers:[]}).getState()}function dV(e){return"obs"==e.type&&!e.questionOptions.concept&&"fixed-value"!==e.questionOptions.rendering}function dM(e,t,n,r,i){let[o,a]=(0,d.useState)(null),[l,s]=(0,d.useState)(dq(e,t));return(0,d.useEffect)(()=>{let o=new AbortController,l=e=>{if(e?.translations){let t=window.i18next.language;window.i18next.addResourceBundle(t,u6.L,e.translations,!0,!0)}a(e)};return dj(e,t,r,i).then(e=>{l({...e,encounter:n})}).catch(e=>{"AbortError"!==e.name&&(console.error(e),s(Error("Error loading form JSON: "+e.message)))}),()=>{o.abort()}},[r,e,t,n]),{formJson:o,isLoading:!o&&!l,formError:l}}async function dj(e,t,n,r){let i=await (0,tj.fetchOpenMRSForm)(e),o=await (0,tj.fetchClobData)(i),a=await dD(),l=o?{...o,uuid:i.uuid}:d$(t),s=dI(l);dL(l,await dN(s,n));let u=dz(l),c=await dU(u),d=u.reduce((e,t)=>(e[t.formName]=t.alias,e),{});return dY(l,dW(c),d),dR(l,a,n,r)}function dI(e){return e.pages.filter(e=>e.isSubform&&!e.subform.form&&e.subform?.name).map(e=>e.subform?.name)}async function dN(e,t){return Promise.all(e.map(e=>dj(e,null,t)))}function dL(e,t){t.forEach(t=>{let n=e.pages.find(e=>e.subform?.name===t.name);n&&(n.subform.form=t)})}function dq(e,t){return e||t?e&&t?Error("InvalidArgumentsErr: Both formUuid and formJson cannot be provided at the same time."):void 0:Error("InvalidArgumentsErr: Neither formUuid nor formJson was provided")}function dR(e,t=[],n,r){return dB(e,n),t.reduce((e,t)=>t.transform(e,r),e),dH(e),a(n,e)}function d$(e){return"string"==typeof e?JSON.parse(e):JSON.parse(JSON.stringify(e))}function dB(e,t){for(let n=e.pages.length-1;n>=0;n--){let r=e.pages[n];(0,np.H)(r.isSubform)&&!(0,np.H)(r.isHidden)&&r.subform?.form?.encounterType===e.encounterType&&(r.subform.form.pages.filter(e=>!(0,np.H)(e.isSubform)),e.pages.splice(n,1,...dR(r.subform.form,[],t).pages))}}function dH(e){e.encounter&&"string"==typeof e.encounter&&!e.encounterType&&(e.encounterType=e.encounter,delete e.encounter)}function dz(e){let t=e?.referencedForms;return t||[]}async function dU(e){return Promise.all(e.map(e=>dj(e.formName,null,null)))}function dW(e){let t=new Map;return e.forEach(e=>{t.set(e.name,e)}),t}function dY(e,t,n){t.forEach((t,r)=>{e.pages.forEach(e=>{e.sections&&e.sections.forEach(e=>{if(e.reference&&(e.reference.form===r||e.reference.form===n[r])){let n=dJ(e,t);Object.assign(e,n)}})})})}function dJ(e,t){let n,r=t.pages.filter(t=>t.label===e.reference.page);if(r.length>0){let t=r[0].sections.filter(t=>t.label===e.reference.section);t.length>0&&(n=t[0])}return dZ(n,e.reference)}function dZ(e,t){if(t?.excludeQuestions){let n=t.excludeQuestions;e.questions=e.questions.filter(e=>!n.includes(e.id))}return e}var dG=function(e,t){return(dG=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function dQ(e,t){function n(){this.constructor=e}dG(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function dK(e){return"function"==typeof e}var dX=!1,d0={Promise:void 0,set useDeprecatedSynchronousErrorHandling(value){value&&Error().stack,dX=value},get useDeprecatedSynchronousErrorHandling(){return dX}};function d1(e){setTimeout(function(){throw e},0)}var d2={closed:!0,next:function(e){},error:function(e){if(d0.useDeprecatedSynchronousErrorHandling)throw e;d1(e)},complete:function(){}},d4=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}();function d5(e){return null!==e&&"object"==typeof e}var d3=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),d6=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return e.prototype.unsubscribe=function(){if(!this.closed){var t,n=this,r=n._parentOrParents,i=n._ctorUnsubscribe,o=n._unsubscribe,a=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof e)r.remove(this);else if(null!==r)for(var l=0;l<r.length;++l)r[l].remove(this);if(dK(o)){i&&(this._unsubscribe=void 0);try{o.call(this)}catch(e){t=e instanceof d3?d9(e.errors):[e]}}if(d4(a))for(var l=-1,s=a.length;++l<s;){var u=a[l];if(d5(u))try{u.unsubscribe()}catch(e){t=t||[],e instanceof d3?t=t.concat(d9(e.errors)):t.push(e)}}if(t)throw new d3(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw Error("unrecognized teardown "+t+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof e){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function d9(e){return e.reduce(function(e,t){return e.concat(t instanceof d3?t.errors:t)},[])}var d7=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),d8=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=d2;break;case 1:if(!n){o.destination=d2;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new fe(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new fe(o,n,r,i)}return o}return dQ(t,e),t.prototype[d7]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(d6),fe=function(e){function t(t,n,r,i){var o,a=e.call(this)||this;a._parentSubscriber=t;var l=a;return dK(n)?o=n:n&&(o=n.next,r=n.error,i=n.complete,n!==d2&&(dK((l=Object.create(n)).unsubscribe)&&a.add(l.unsubscribe.bind(l)),l.unsubscribe=a.unsubscribe.bind(a))),a._context=l,a._next=o,a._error=r,a._complete=i,a}return dQ(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;d0.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=d0.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?this.__tryOrSetError(t,this._error,e):this.__tryOrUnsub(this._error,e),this.unsubscribe();else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):d1(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;d1(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};d0.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,n):this.__tryOrUnsub(n),this.unsubscribe()}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),d0.useDeprecatedSynchronousErrorHandling)throw e;d1(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!d0.useDeprecatedSynchronousErrorHandling)throw Error("bad call");try{t.call(this._context,n)}catch(t){if(d0.useDeprecatedSynchronousErrorHandling)return e.syncErrorValue=t,e.syncErrorThrown=!0,!0;return d1(t),!0}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(d8);function ft(e){for(;e;){var t=e,n=t.closed,r=t.destination,i=t.isStopped;if(n||i)return!1;e=r&&r instanceof d8?r:null}return!0}function fn(e,t,n){if(e){if(e instanceof d8)return e;if(e[d7])return e[d7]()}return e||t||n?new d8(e,t,n):new d8(d2)}var fr=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function fi(e){return e}function fo(e){return 0===e.length?fi:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var fa=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,i=fn(e,t,n);if(r?i.add(r.call(i,this.source)):i.add(this.source||d0.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),d0.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){d0.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),ft(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=fl(t))(function(t,r){var i;i=n.subscribe(function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}},r,t)})},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[fr]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:fo(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=fl(e))(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function fl(e){if(e||(e=d0.Promise||Promise),!e)throw Error("no Promise impl found");return e}var fs=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),fu=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return dQ(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(d6),fc=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return dQ(t,e),t}(d8),fd=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return dQ(t,e),t.prototype[d7]=function(){return new fc(this)},t.prototype.lift=function(e){var t=new ff(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new fs;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new fs;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new fs;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new fs},t.prototype._subscribe=function(e){if(this.closed)throw new fs;return this.hasError?(e.error(this.thrownError),d6.EMPTY):this.isStopped?(e.complete(),d6.EMPTY):(this.observers.push(e),new fu(this,e))},t.prototype.asObservable=function(){var e=new fa;return e.source=this,e},t.create=function(e,t){return new ff(e,t)},t}(fa),ff=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return dQ(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):d6.EMPTY},t}(fd),fp=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return dQ(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new fs},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(fd);function fm(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class fh{setEvaluatedPagesVisibility(e){this.evaluatedPagesVisibilitySubject.next(e)}updateScrollablePages(e){this.scrollablePagesSubject.next(e)}updatePagesWithErrors(e){this.pagesWithErrorsSubject.next(new Set(e))}addActivePage(e){let t=this.activePagesSubject.value;t.add(e),this.activePagesSubject.next(t)}removeInactivePage(e){let t=this.activePagesSubject.value;t.delete(e),this.activePagesSubject.next(t)}getActivePagesObservable(){return this.activePagesSubject.asObservable()}getScrollablePagesObservable(){return this.scrollablePagesSubject.asObservable()}getPagesWithErrorsObservable(){return this.pagesWithErrorsSubject.asObservable()}getEvaluatedPagesVisibilityObservable(){return this.evaluatedPagesVisibilitySubject.asObservable()}clear(){this.scrollablePagesSubject.next([]),this.pagesWithErrorsSubject.next(new Set),this.activePagesSubject.next(new Set),this.evaluatedPagesVisibilitySubject.next(!1)}constructor(){fm(this,"scrollablePagesSubject",new fp([])),fm(this,"pagesWithErrorsSubject",new fp(new Set)),fm(this,"activePagesSubject",new fp(new Set)),fm(this,"evaluatedPagesVisibilitySubject",new fp(null))}}let fg=new fh,fy=new Set;function fv(e){e&&Object.values(e).forEach(e=>{fy.add(e)})}function fb(){fy.forEach(e=>{try{e.tearDown()}catch(e){}}),fy.clear(),fg.clear()}function f_(e){let[t,n]=(0,d.useState)(void 0),r=(0,d.useCallback)(()=>{let e=new CustomEvent("openmrs:form-view-embedded",{detail:{value:!1}});window.dispatchEvent(e)},[]),i=(0,d.useCallback)(e=>{n(e.detail.value)},[]);return(0,d.useEffect)(()=>{let t=new CustomEvent("openmrs:form-view-embedded",{detail:{value:"embedded-view"!=e}});window.dispatchEvent(t)},[e]),(0,d.useEffect)(()=>(window.addEventListener("openmrs:form-collapse-toggle",i),()=>{window.removeEventListener("openmrs:form-collapse-toggle",i)}),[]),{isFormExpanded:t,hideFormCollapseToggle:r}}let fw=26.25,fx=32.25,fE=48.25;function fk(e){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>t<=fw?"narrow":t<=fx?"wider":t<=fE?"extra-wide":"ultra-wide",[t]);return(0,d.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.parentElement?.offsetWidth,r=parseInt(getComputedStyle(document.documentElement).fontSize);t&&n(tw(t,r))};t();let r=new ResizeObserver(e=>{t()});return e.current?.parentElement&&r.observe(e.current?.parentElement),()=>{r.disconnect()}},[e]),r}let fS=()=>{let[e,t]=(0,d.useState)({pages:[],pagesWithErrors:[],activePages:[],evaluatedPagesVisibility:!1,hasMultiplePages:null});return(0,d.useEffect)(()=>{let e=[fg.getScrollablePagesObservable().subscribe(e=>{t(t=>({...t,pages:e,hasMultiplePages:e.length>1}))}),fg.getPagesWithErrorsObservable().subscribe(e=>{t(t=>({...t,pagesWithErrors:Array.from(e)}))}),fg.getActivePagesObservable().subscribe(e=>{t(t=>({...t,activePages:Array.from(e)}))}),fg.getEvaluatedPagesVisibilityObservable().subscribe(e=>{t(t=>({...t,evaluatedPagesVisibility:e}))})];return()=>e.forEach(e=>e.unsubscribe())},[]),e};function fO(e){let t=new Date,n=t.getFullYear()-e.getFullYear();return t.getMonth()<e.getMonth()||t.getMonth()===e.getMonth()&&t.getDate()<e.getDate()?n-1:n}let fD={female:"F",male:"M",other:"O",unknown:"U"},fC=e=>{let{patient:t,isLoading:n,error:r}=(0,u.usePatient)(e);return t&&!n&&(t.age=fO(new Date(t?.birthDate)),t.sex=fD[t.gender]??"U"),{patient:t,isLoadingPatient:n,patientError:r}},fF=(e,t,n,r)=>{let{loadDependencies:i}=e,{formJson:o}=t,[a,l]=(0,d.useState)(0),[s,u]=(0,d.useState)(null),c=(0,d.useCallback)(()=>l(e=>e+1),[]),f=s?.loadDependencies===i&&s?.attempt===a?s:null;return(0,d.useEffect)(()=>{let e=!1;return async function(){let l=await Promise.allSettled([Promise.resolve().then(()=>i?.(t,n,r)),tq(o)]);if(!e){let e=l.find(e=>"rejected"===e.status);u({loadDependencies:i,attempt:a,error:e?Error(e.reason?.message??String(e.reason)):null})}}(),()=>{e=!0}},[i,a]),{isLoading:!f||!!f.error,error:f?.error,retry:c}},fA=(e,t,n)=>{let[r,i]=(0,d.useState)(!0),[o,a]=(0,d.useState)({}),[l,s]=(0,d.useState)(null),u=(0,d.useRef)(n);u.current=n;let c=(0,d.useRef)(!1),f=n.formFields?.length>0,p=Object.keys(n.formFieldAdapters??{}).length>0;return(0,d.useEffect)(()=>{if(e&&!t&&f&&p&&!c.current){c.current=!0;let t=u.current;e.getInitialValues(t).then(e=>{a(e),i(!1)}).catch(e=>{console.error(e),s(e),i(!1)})}},[e,t,f,p]),{isLoadingInitialValues:r,initialValues:o,error:l}},fP="-esm-form-engine__section-renderer__section___OpnOG",fT="-esm-form-engine__section-renderer__sectionBody___lI63X",fV=({section:e})=>{let{formFieldAdapters:t}=ng(),n=(0,d.useMemo)(()=>e.label.replace(/\s/g,""),[e.label]);return f().createElement("div",{className:fP},e.questions.map(e=>t[e.type]?f().createElement("div",{key:`${n}-${e.id}`,className:fT},f().createElement(nT,{key:e.id,fieldId:e.id,valueAdapter:t[e.type]})):null))};var fM=n(9086),fj=!!("u">typeof window&&window.document&&window.document.createElement);function fI(){if(!fj||!window.addEventListener||!window.removeEventListener||!Object.defineProperty)return!1;var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return function(){e=!0}}()}),n=function(){};window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t)}catch(e){}return e}var fN=void 0;function fL(){return void 0===fN&&(fN=fI()),fN}function fq(e){if(e)return fL()?e:!!e.capture}function fR(e){return e?!0===e?100:(0|e.capture)+(e.passive<<1)+(e.once<<2):0}function f$(e){e.handlers===e.nextHandlers&&(e.nextHandlers=e.handlers.slice())}function fB(e){this.target=e,this.events={}}fB.prototype.getEventHandlers=function(){return function(e,t){var n=String(e)+" "+String(fR(t));return this.events[n]||(this.events[n]={handlers:[],handleEvent:void 0},this.events[n].nextHandlers=this.events[n].handlers),this.events[n]}}(),fB.prototype.handleEvent=function(){return function(e,t,n){var r=this.getEventHandlers(e,t);r.handlers=r.nextHandlers,r.handlers.forEach(function(e){e&&e(n)})}}(),fB.prototype.add=function(){return function(e,t,n){var r=this,i=this.getEventHandlers(e,n);f$(i),0===i.nextHandlers.length&&(i.handleEvent=this.handleEvent.bind(this,e,n),this.target.addEventListener(e,i.handleEvent,n)),i.nextHandlers.push(t);var o=!0;return function(){return function(){if(o){o=!1,f$(i);var a=i.nextHandlers.indexOf(t);i.nextHandlers.splice(a,1),0===i.nextHandlers.length&&(r.target&&r.target.removeEventListener(e,i.handleEvent,n),i.handleEvent=void 0)}}}()}}();var fH="__consolidated_events_handlers__";function fz(e,t,n,r){e[fH]||(e[fH]=new fB(e));var i=fq(r);return e[fH].add(t,n,i)}var fU=n(524);function fW(e){if("%"===e.slice(-1))return parseFloat(e.slice(0,-1))/100}function fY(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseFloat(e):"px"===e.slice(-2)?parseFloat(e.slice(0,-2)):void 0}function fJ(e,t){var n=fY(e);if("number"==typeof n)return n;var r=fW(e);if("number"==typeof r)return r*t}var fZ="above",fG="inside",fQ="below",fK="invisible";function fX(e){return"string"==typeof e.type}var f0="<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a DOM element (e.g. <div>) nor does it use the innerRef prop.\n\nSee https://goo.gl/LrBNgw for more info.";function f1(e,t){if(e&&!fX(e)&&!t)throw Error(f0)}function f2(e){return e.viewportBottom-e.viewportTop==0?fK:e.viewportTop<=e.waypointTop&&e.waypointTop<=e.viewportBottom||e.viewportTop<=e.waypointBottom&&e.waypointBottom<=e.viewportBottom||e.waypointTop<=e.viewportTop&&e.viewportBottom<=e.waypointBottom?fG:e.viewportBottom<e.waypointTop?fQ:e.waypointTop<e.viewportTop?fZ:fK}var f4=[];function f5(e){f4.push(e),r||(r=setTimeout(function(){var e;for(r=null;e=f4.shift();)e()},0));var t=!0;return function(){if(t){t=!1;var n=f4.indexOf(e);-1!==n&&(f4.splice(n,1),!f4.length&&r&&(clearTimeout(r),r=null))}}}function f3(e){return"window"===e?n.g.window:e}var f6="u">typeof window,f9={debug:!1,scrollableAncestor:void 0,children:void 0,topOffset:"0px",bottomOffset:"0px",horizontal:!1,onEnter:function(){},onLeave:function(){},onPositionChange:function(){},fireOnRapidScroll:!0},f7=function(e){function t(t){var n;return(n=e.call(this,t)||this).refElement=function(e){n._ref=e},n}(0,fM.A)(t,e);var n=t.prototype;return n.componentDidMount=function(){var e=this;f6&&(this.cancelOnNextTick=f5(function(){e.cancelOnNextTick=null;var t=e.props,n=t.children;t.debug,f1(n,e._ref),e._handleScroll=e._handleScroll.bind(e),e.scrollableAncestor=e._findScrollableAncestor(),e.scrollEventListenerUnsubscribe=fz(e.scrollableAncestor,"scroll",e._handleScroll,{passive:!0}),e.resizeEventListenerUnsubscribe=fz(window,"resize",e._handleScroll,{passive:!0}),e._handleScroll(null)}))},n.componentDidUpdate=function(){var e=this;f6&&this.scrollableAncestor&&(this.cancelOnNextTick||(this.cancelOnNextTick=f5(function(){e.cancelOnNextTick=null,e._handleScroll(null)})))},n.componentWillUnmount=function(){f6&&(this.scrollEventListenerUnsubscribe&&this.scrollEventListenerUnsubscribe(),this.resizeEventListenerUnsubscribe&&this.resizeEventListenerUnsubscribe(),this.cancelOnNextTick&&this.cancelOnNextTick())},n._findScrollableAncestor=function(){var e=this.props,t=e.horizontal,n=e.scrollableAncestor;if(n)return f3(n);for(var r=this._ref;r.parentNode&&(r=r.parentNode)!==document.body;){var i=window.getComputedStyle(r),o=(t?i.getPropertyValue("overflow-x"):i.getPropertyValue("overflow-y"))||i.getPropertyValue("overflow");if("auto"===o||"scroll"===o||"overlay"===o)return r}return window},n._handleScroll=function(e){if(this._ref){var t=this._getBounds(),n=f2(t),r=this._previousPosition,i=this.props,o=(i.debug,i.onPositionChange),a=i.onEnter,l=i.onLeave,s=i.fireOnRapidScroll;if(this._previousPosition=n,r!==n){var u={currentPosition:n,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom};o.call(this,u),n===fG?a.call(this,u):r===fG&&l.call(this,u);var c=r===fQ&&n===fZ,d=r===fZ&&n===fQ;s&&(c||d)&&(a.call(this,{currentPosition:fG,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}),l.call(this,{currentPosition:n,previousPosition:fG,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}))}}},n._getBounds=function(){var e,t,n=this.props,r=n.horizontal;n.debug;var i=this._ref.getBoundingClientRect(),o=i.left,a=i.top,l=i.right,s=i.bottom,u=r?o:a,c=r?l:s;this.scrollableAncestor===window?(e=r?window.innerWidth:window.innerHeight,t=0):(e=r?this.scrollableAncestor.offsetWidth:this.scrollableAncestor.offsetHeight,t=r?this.scrollableAncestor.getBoundingClientRect().left:this.scrollableAncestor.getBoundingClientRect().top);var d=this.props,f=d.bottomOffset,p=fJ(d.topOffset,e),m=fJ(f,e),h=t+e;return{waypointTop:u,waypointBottom:c,viewportTop:t+p,viewportBottom:h-m}},n.render=function(){var e=this,t=this.props.children;if(!t)return f().createElement("span",{ref:this.refElement,style:{fontSize:0}});if(fX(t)||(0,fU.isForwardRef)(t)){var n=function(n){e.refElement(n),t.ref&&("function"==typeof t.ref?t.ref(n):t.ref.current=n)};return f().cloneElement(t,{ref:n})}return f().cloneElement(t,{innerRef:this.refElement})},t}(f().PureComponent);f7.above=fZ,f7.below=fQ,f7.inside=fG,f7.invisible=fK,f7.defaultProps=f9,f7.displayName="Waypoint";let f8={pageContent:"-esm-form-engine__page-renderer__pageContent___ZYB9J",pageHeader:"-esm-form-engine__page-renderer__pageHeader___XuC5+",pageTitle:"-esm-form-engine__page-renderer__pageTitle___AbChc",collapseIcon:"-esm-form-engine__page-renderer__collapseIcon___eEY4D",sectionContainer:"-esm-form-engine__page-renderer__sectionContainer___nfi1A",accordionContainer:"-esm-form-engine__page-renderer__accordionContainer___M2pxs",firstSection:"-esm-form-engine__page-renderer__firstSection___IQTsd",lastSection:"-esm-form-engine__page-renderer__lastSection___sooKZ",formSection:"-esm-form-engine__page-renderer__formSection___PGg8p",hiddenAccordion:"-esm-form-engine__page-renderer__hiddenAccordion___-29II"};function pe({section:e,sectionIndex:t,visibleSections:n,isFormExpanded:r}){let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)(r);return(0,d.useEffect)(()=>{a(r)},[r]),f().createElement(y.AccordionItem,{title:i(e.label),open:o,className:m()(f8.sectionContainer,{[f8.firstSection]:0===t,[f8.lastSection]:t===n.length-1})},f().createElement("div",{className:f8.formSection},f().createElement(fV,{section:e})))}let pt=function({page:e,isFormExpanded:t}){let{t:n}=(0,e9.useTranslation)(),[r,i]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>e.sections.filter(e=>{let t=e.questions.some(e=>!(0,np.H)(e.isHidden));return!(0,np.H)(e.isHidden)&&t}),[e.sections]),a=()=>i(!r);return(0,d.useEffect)(()=>(i(!t),()=>{fg.removeInactivePage(e.id)}),[t]),f().createElement("div",null,f().createElement(f7,{key:e.id,onEnter:()=>fg.addActivePage(e.id),onLeave:()=>fg.removeInactivePage(e.id),topOffset:"40%",bottomOffset:"40%"},f().createElement("div",{id:e.id,className:f8.pageContent},f().createElement("div",{className:f8.pageHeader,onClick:a},f().createElement("p",{className:f8.pageTitle},n(e.label),f().createElement("span",{className:f8.collapseIconWrapper},r?f().createElement(u.ChevronDownIcon,{className:f8.collapseIcon,"aria-label":"Expand"}):f().createElement(u.ChevronUpIcon,{className:f8.collapseIcon,"aria-label":"Collapse"})))),f().createElement("div",{className:m()({[f8.hiddenAccordion]:r,[f8.accordionContainer]:!r})},f().createElement(y.Accordion,null,o.map((e,n)=>f().createElement(pe,{key:`section-${e.label}`,section:e,sectionIndex:n,visibleSections:o,isFormExpanded:t})))))))},pn={formFields:[],invalidFields:[],formJson:null,deletedFields:[]},pr=(e,t)=>{switch(t.type){case"SET_FORM_FIELDS":return{...e,formFields:t.value};case"ADD_FORM_FIELD":return{...e,formFields:[...e.formFields,t.value]};case"UPDATE_FORM_FIELD":return{...e,formFields:e.formFields.map(e=>e.id===t.value.id?t.value:e)};case"REMOVE_FORM_FIELD":return{...e,formFields:e.formFields.filter(e=>e.id!==t.value)};case"SET_INVALID_FIELDS":return{...e,invalidFields:t.value};case"ADD_INVALID_FIELD":return{...e,invalidFields:[...e.invalidFields,t.value]};case"REMOVE_INVALID_FIELD":return{...e,invalidFields:e.invalidFields.filter(e=>e.id!==t.value)};case"CLEAR_INVALID_FIELDS":return{...e,invalidFields:[]};case"SET_FORM_JSON":return{...e,formJson:t.value};case"SET_DELETED_FIELDS":return{...e,deletedFields:t.value};default:return e}},pi=(e,t)=>{let{formFields:n,patient:r,sessionMode:i,visit:o}=t,[a,l]=(0,d.useState)(t.formJson),[s,u]=(0,d.useState)(!1),c=(0,d.useMemo)(()=>n?.map(t=>{let a={value:t,type:"field"},l={patient:r,mode:i,visit:o};if(t.hide?.hideWhenExpression){let r=t0(t.hide.hideWhenExpression,a,n,e,l);t.isHidden=r,Array.isArray(t.questions)&&t.questions.forEach(e=>{e.isHidden=r})}else t.isHidden=!1;"object"==typeof t.required&&"conditionalRequired"===t.required.type?t.isRequired=t9(t,n,e):t.isRequired=(0,np.H)(t.required),"object"==typeof t.disabled&&t.disabled.disableWhenExpression?t.isDisabled=t0(t.disabled.disableWhenExpression,a,n,e,l):t.isDisabled=(0,np.H)(t.disabled),t.validators?.some(e=>"conditionalAnswered"===e.type)&&t6(t,n),t.questionOptions.answers?.filter(e=>!ts(e.hide?.hideWhenExpression)).forEach(t=>{t.isHidden=t0(t.hide.hideWhenExpression,a,n,e,l)}),t.questionOptions.answers?.filter(e=>!ts(e.disable?.disableWhenExpression)).forEach(t=>{t.disable.isDisabled=t0(t.disable?.disableWhenExpression,a,n,e,l)}),"string"==typeof t.readonly&&po(t.readonly)&&(t.meta.readonlyExpression=t.readonly,t.readonly=t0(t.readonly,a,n,e,l));let s=t.questionOptions.repeatOptions?.limitExpression;return"repeating"!==t.questionOptions.rendering||ts(s)||(t.questionOptions.repeatOptions.limit=t0(s,a,n,e,l)),t}),[e,n,r,i]);return(0,d.useEffect)(()=>{t.formJson?.pages?.forEach(t=>{t.hide?t8({value:t,type:"page"},n,e,i,r,t0,null):t.isHidden=!1,t?.sections?.forEach(t=>{t.hide?t8({value:t,type:"section"},n,e,i,r,t0,null):t.isHidden=!1})}),l(t_(t.formJson)),u(!0)},[t.formJson,n]),{evaluatedFormJson:a,evaluatedFields:c,evaluatedPagesVisibility:s}};function po(e){return"true"!==e&&"false"!==e}function pa(e,t){let n=(0,d.useCallback)(t=>{e({type:"ADD_FORM_FIELD",value:t})},[]),r=(0,d.useCallback)(n=>{if(n.meta.groupId){let e=t.find(e=>e.id===n.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===n.id?n:e),r(e))}e({type:"UPDATE_FORM_FIELD",value:(0,uu.A)(n)})},[t]),i=(0,d.useCallback)(e=>t.find(t=>t.id===e),[t]),o=(0,d.useCallback)(t=>{e({type:"REMOVE_FORM_FIELD",value:t})},[]),a=(0,d.useCallback)(t=>{e({type:"SET_INVALID_FIELDS",value:t})},[]),l=(0,d.useCallback)(t=>{e({type:"ADD_INVALID_FIELD",value:t})},[]),s=(0,d.useCallback)(t=>{e({type:"REMOVE_INVALID_FIELD",value:t})},[]);return{addFormField:n,updateFormField:r,getFormField:i,removeFormField:o,setInvalidFields:a,addInvalidField:l,removeInvalidField:s,setForm:(0,d.useCallback)(t=>{e({type:"SET_FORM_JSON",value:t_(t)})},[]),setDeletedFields:(0,d.useCallback)(t=>{e({type:"SET_DELETED_FIELDS",value:t})},[])}}let pl=({processorContext:e,initialValues:t,isSubForm:n,setIsLoadingFormDependencies:r})=>{let{evaluatedFields:i,evaluatedFormJson:o,evaluatedPagesVisibility:a}=pi(t,e),{registerForm:l,setIsFormDirty:s,workspaceLayout:u,isFormExpanded:c}=cE(),p=e6({defaultValues:t,mode:"onChange",reValidateMode:"onChange",criteriaMode:"all"}),{formState:{isDirty:m}}=p,[{formFields:h,invalidFields:g,formJson:y,deletedFields:v},b]=(0,d.useReducer)(pr,{...pn,formFields:i,formJson:o}),{addFormField:_,updateFormField:w,getFormField:x,removeFormField:E,setInvalidFields:k,addInvalidField:S,removeInvalidField:O,setForm:D,setDeletedFields:C}=pa(b,h);(0,d.useEffect)(()=>{let e=y.pages.filter(e=>!e.isSubform).map(e=>e);fg.updateScrollablePages(e)},[y.pages]),(0,d.useEffect)(()=>{fg.setEvaluatedPagesVisibility(a)},[a]),(0,d.useEffect)(()=>{fg.updatePagesWithErrors(g.map(e=>e.meta.pageId))},[g]);let F=(0,d.useMemo)(()=>({...e,workspaceLayout:u,methods:p,formFields:h,formJson:y,invalidFields:g,deletedFields:v,addFormField:_,updateFormField:w,getFormField:x,removeFormField:E,setInvalidFields:k,addInvalidField:S,removeInvalidField:O,setForm:D,setDeletedFields:C}),[e,u,p,h,y,g,v]);return(0,d.useEffect)(()=>{l(y.name,n,F)},[y.name,n,F]),(0,d.useEffect)(()=>{s(m)},[m]),f().createElement(nh,F,y.pages.map(e=>e.isSubform||ni(e)?e.isSubform&&e.subform?.form?f().createElement(px,{key:e.subform.form.uuid,formJson:e.subform.form,isSubForm:!0,setIsLoadingFormDependencies:r}):f().createElement(pt,{key:e.label,page:e,isFormExpanded:c}):null))},ps=({context:e,setContext:t,setters:n,useCustomHooks:r,setIsLoadingCustomHooks:i})=>{let{isLoading:o=!1,error:a=null,data:l,updateContext:s}=r(e);return(0,d.useEffect)(()=>{!o&&s&&(s(t,n),i(!1))},[o]),null};function pu(e){let[t,n]=(0,d.useMemo)(()=>{let t=[],n=new Set,r=(e,i)=>{let o=i?{...e,meta:{...e.meta,groupId:i}}:e;t.push(o),o.questionOptions?.concept&&n.add(o.questionOptions.concept),o.questionOptions?.answers?.forEach(e=>{e.concept&&n.add(e.concept)}),"obsGroup"===o.type&&o.questions&&o.questions.forEach(e=>{r(e,o.id)})};return e.pages?.forEach(e=>e.sections?.forEach(e=>{e.questions?.forEach(e=>r(e))})),[t,JSON.stringify(Array.from(n).sort())]},[e]);return{formFields:t,conceptReferences:(0,d.useMemo)(()=>new Set(JSON.parse(n)),[n])}}let pc="custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))";function pd(e){let{data:t,error:n,isLoading:r}=cl()([`${u.restBaseUrl}/conceptreferences?v=${pc}`,e],([e,t])=>(0,u.openmrsFetch)(e,{headers:{"Content-Type":"application/json"},body:{references:t},method:"POST"}),{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1,shouldRetryOnError:!1});return{concepts:(0,d.useMemo)(()=>t?.data?Object.values(t.data):void 0,[t]),isLoading:r,error:n}}let pf={};function pp(e){let t=(0,d.useMemo)(()=>{let t=new Set;return e.forEach(e=>{e.validators?.forEach(e=>t.add(e.type))}),Array.from(t).sort().join(",")},[e]),{data:n}=ci()(t?["formFieldValidators",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>dF(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??pf}function pm(e,t){return(0,d.useMemo)(()=>e.length&&t?.length?e.map(e=>{let n=nt(e.questionOptions.concept,t);return e.questionOptions.concept=n?n.uuid:e.questionOptions.concept,e.label=e.label?e.label:n?.display,c.FU.includes(e.questionOptions.rendering)&&!e.questionOptions.answers?.length&&n?.conceptClass?.display==="Question"&&n?.answers?.length&&(e.questionOptions.answers=n.answers.map(e=>({concept:e?.uuid,label:e?.display}))),e.meta={...e.meta||{},concept:n},e.questionOptions.answers&&(e.questionOptions.answers=e.questionOptions.answers.map(e=>{let n=nt(e.concept,t);return{...e,concept:n?n.uuid:e.concept,label:e.label?e.label:n?.display}})),e}):e??[],[t,e])}let ph={},pg=e=>{let t=(0,d.useMemo)(()=>{let t=new Set;return e.forEach(e=>t.add(e.type)),Array.from(t).sort().join(",")},[e]),{data:n}=ci()(t?["formFieldValueAdapters",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>dO(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??ph},py="-esm-form-engine__loader__loaderContainer___78hu3",pv="-esm-form-engine__loader__loader___dnvKS",pb=()=>{let{t:e}=(0,e9.useTranslation)();return f().createElement("div",{className:py},f().createElement(y.InlineLoading,{className:pv,description:`${e("loading","Loading")} ...`}))},p_=["patient","formJson","visit","sessionMode","sessionDate","location","currentProvider","layoutType","processor","formFields","formFieldAdapters","formFieldValidators"];function pw(e,t){let n=p_.filter(n=>n in t&&t[n]!==e[n]);n.length&&console.warn(`A form processor tried to set the context propert${1===n.length?"y":"ies"} ${n.join(", ")}, which the form engine derives itself. ${1===n.length?"It was":"They were"} ignored. Use the setters passed alongside setContext to update the domain object or custom dependencies.`)}let px=({formJson:e,isSubForm:t=!1,setIsLoadingFormDependencies:n})=>{let{patient:r,sessionMode:i,formProcessors:o,layoutType:a,location:l,provider:s,sessionDate:u,visit:c}=cE(),{t:p}=(0,e9.useTranslation)(),m=(0,d.useId)(),h=(0,d.useMemo)(()=>{let t,n=o[e.processor];return n?t=new n(e):(console.error(`Form processor ${e.processor} not found, defaulting to EncounterFormProcessor`),t=new cp(e)),t.prepareFormSchema(e),t},[o,e.processor]),{formFields:g,conceptReferences:v}=pu(e),{concepts:b,isLoading:_}=pd(Array.from(v)),w=pm(g,b),x=pg(g),E=pp(g),k=(0,d.useMemo)(()=>w?.length?w:g??[],[w,g]),[S,O]=(0,d.useState)({}),D=(0,d.useMemo)(()=>({patient:r,formJson:e,sessionMode:i,layoutType:a,location:l,currentProvider:s,processor:h,sessionDate:u,visit:c,formFields:k,formFieldAdapters:x??{},formFieldValidators:E??{}}),[r,e,i,a,l,s,h,u,c,k,x,E]),C=(0,d.useMemo)(()=>({...D,...S}),[D,S]),F=(0,d.useCallback)(e=>{O(t=>{let n={...D,...t},r="function"==typeof e?e(n):e;return"function"==typeof e&&pw(n,r),{domainObjectValue:r.domainObjectValue,previousDomainObjectValue:r.previousDomainObjectValue,customDependencies:r.customDependencies}})},[D]),A=(0,d.useMemo)(()=>({setDomainObjectValue:e=>O(t=>({...t,domainObjectValue:e})),setPreviousDomainObjectValue:e=>O(t=>({...t,previousDomainObjectValue:e})),setCustomDependencies:e=>O(t=>({...t,customDependencies:"function"==typeof e?e(t.customDependencies??{}):e}))}),[]),{isLoading:P,error:T,retry:V}=fF(h,C,F,A),M=h.getCustomHooks().useCustomHooks,[j,I]=(0,d.useState)(!!M),{isLoadingInitialValues:N,initialValues:L,error:q}=fA(h,P||j||_,C),R=(0,d.useMemo)(()=>P||j||_||N,[P,j,_,N]);return(0,d.useEffect)(()=>{n(m,R)},[m,R,n]),(0,d.useEffect)(()=>()=>n(m,!1),[m,n]),(0,d.useEffect)(()=>{(0,ns.N)(q,p("errorLoadingInitialValues","Error loading initial values"))},[q,p]),(0,d.useEffect)(()=>{x&&fv(x)},[x]),f().createElement(f().Fragment,null,M&&f().createElement(ps,{context:C,setContext:F,setters:A,useCustomHooks:M,setIsLoadingCustomHooks:I}),T?f().createElement("div",null,f().createElement(y.InlineNotification,{kind:"error",hideCloseButton:!0,title:p("errorLoadingFormDependencies","Unable to load form data"),subtitle:p("retryLoadingFormDependencies","Required form data could not be loaded. Retry to complete and save this form.")}),f().createElement(y.Button,{kind:"tertiary",onClick:V},p("retry","Retry"))):R?f().createElement(pb,null):f().createElement(pl,{processorContext:C,initialValues:L,isSubForm:t,setIsLoadingFormDependencies:n}))},pE="-esm-form-engine__patient-banner__patientBannerContainer___w28t3",pk=({patient:e,hideActionsOverflow:t})=>f().createElement("div",{className:pE},f().createElement(u.ExtensionSlot,{name:"patient-header-slot",state:{patient:e,patientUuid:e.id,hideActionsOverflow:t}})),pS=({pages:e,defaultPage:t,activePages:n,evaluatedPagesVisibility:r})=>{let[i,o]=(0,d.useState)(null),[a,l]=(0,d.useState)(!1),[s,u]=(0,d.useState)(null),c=(0,d.useRef)(!0);return(0,d.useEffect)(()=>{a||!r||((()=>{let n=e.find(({label:e})=>e===t);if(n&&!n.isHidden)o(n.id),nn(n.id);else{let t=e.find(e=>!e.isHidden);t&&o(t.id)}})(),l(!0))},[e,t,r,a]),(0,d.useEffect)(()=>{let e=null;return a&&(e=setTimeout(()=>{c.current=!1},200)),()=>{e&&clearTimeout(e)}},[a]),(0,d.useEffect)(()=>{if(c.current)return;let t=null;if(s&&n.includes(s)){o(s),t=setTimeout(()=>{u(null)},100);return}return!s&&n.length>0&&o(n.reduce((t,n)=>e.findIndex(e=>e.id===t)<e.findIndex(e=>e.id===n)?t:n)),()=>{t&&clearTimeout(t)}},[n,s,e]),{currentActivePage:i,requestPage:(0,d.useCallback)(e=>{c.current=!1,u(e),o(e),nn(e)},[])}},pO="-esm-form-engine__sidebar__pageLink___ivjRs",pD="-esm-form-engine__sidebar__pageLinkTablet___DzG-5",pC="-esm-form-engine__sidebar__activePage___PtOKZ",pF="-esm-form-engine__sidebar__errorPage___56UzK",pA="-esm-form-engine__sidebar__activeErrorPage___FRrGU",pP="-esm-form-engine__sidebar__sidebar___oko66",pT="-esm-form-engine__sidebar__sideNavActions___hQ7Cj",pV="-esm-form-engine__sidebar__divider___qNrzq",pM="-esm-form-engine__sidebar__closeButton___X671g",pj="-esm-form-engine__sidebar__saveButton___1qxAl",pI="-esm-form-engine__sidebar__topMargin___XINCj";function pN({page:e,currentActivePage:t,pagesWithErrors:n,requestPage:r}){let{t:i}=(0,e9.useTranslation)(),o=e.id===t,a=n.includes(e.id),l="tablet"===(0,u.useLayoutType)();return f().createElement("div",{className:m()(pO,{[pC]:o&&!a,[pF]:a&&!o,[pA]:a&&o,[pD]:l})},f().createElement("button",{onClick:t=>{t.preventDefault(),r(e.id)}},f().createElement("span",null,i(e.label))))}let pL=({defaultPage:e,isFormSubmitting:t,sessionMode:n,onCancel:r,handleClose:i,hideFormCollapseToggle:o,hideControls:a})=>{let{t:l}=(0,e9.useTranslation)(),{pages:s,pagesWithErrors:c,activePages:p,evaluatedPagesVisibility:h}=fS(),{currentActivePage:g,requestPage:v}=pS({pages:s,defaultPage:e,activePages:p,evaluatedPagesVisibility:h}),b=(0,u.useLayoutType)(),_=(0,d.useMemo)(()=>"tablet"===b?"lg":"sm",[b]);return f().createElement("div",{className:pP},s.filter(e=>ni(e)).map(e=>f().createElement(pN,{key:e.id,page:e,currentActivePage:g,pagesWithErrors:c,requestPage:v})),"view"!==n&&!a&&f().createElement("hr",{className:pV}),!a&&f().createElement("div",{className:pT},"view"!==n&&f().createElement(y.Button,{className:pj,disabled:t,type:"submit",size:_},t?f().createElement(y.InlineLoading,{description:l("submitting","Submitting")+"..."}):f().createElement("span",null,`${l("save","Save")}`)),f().createElement(y.Button,{className:m()(pM,{[pI]:"view"===n}),kind:"tertiary",onClick:()=>{r?.(),i?.(),o()},size:_},"view"===n?l("close","Close"):l("cancel","Cancel"))))},pq="-esm-form-engine__form-engine__form___G3zJ0",pR="-esm-form-engine__form-engine__formContainer___SqLcw",p$="-esm-form-engine__form-engine__formContent___wWrk8",pB="-esm-form-engine__form-engine__formContentInner___z1h1C",pH="-esm-form-engine__form-engine__formBody___Fb2k2",pz="-esm-form-engine__form-engine__minifiedButtons___SnmW7",pU="-esm-form-engine__form-engine__markdownContainer___A3eX9",pW="-esm-form-engine__form-engine__linearActivity___boIRq",pY="-esm-form-engine__form-engine__indeterminate___nUedJ",pJ="-esm-form-engine__form-engine__saveButton___T0Txa",pZ=({formJson:e,patientUUID:t,formUUID:n,encounterUUID:r,visit:i,formSessionIntent:o,mode:a,onSubmit:l,onCancel:s,handleClose:c,handleConfirmQuestionDeletion:p,markFormAsDirty:h,hideControls:g=!1,hidePatientBanner:v=!1,preFilledQuestions:b})=>{let{t:_}=(0,e9.useTranslation)(),w=(0,u.useSession)(),x=(0,d.useRef)(null),E=(0,d.useRef)(new Date),k=(0,d.useMemo)(()=>tv(E.current,i),[i?.startDatetime,i?.stopDatetime]),S=fk(x),{patient:O,isLoadingPatient:D}=fC(t),[C,F]=(0,d.useState)(!0),A=(0,d.useRef)(new Set),P=(0,d.useCallback)((e,t)=>{t?A.current.add(e):A.current.delete(e),F(A.current.size>0)},[]),[T,V]=(0,d.useState)(!1),[M,j]=(0,d.useState)(!1),I=ts(a)?ts(r)?"enter":"edit":a,{isFormExpanded:N,hideFormCollapseToggle:L}=f_(I),{hasMultiplePages:q}=fS(),{formJson:R,isLoading:$,formError:B}=dM(n,e,r,o,b),H=(0,d.useMemo)(()=>!v&&O&&"ultra-wide"===S&&"embedded-view"!==a,[O,a,S,v]),z=(0,d.useMemo)(()=>["narrow"].includes(S),[S]),U=(0,d.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&(z||!q),[a,z,C,q]),W=(0,d.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&!z&&q,[z,C,q]);(0,d.useEffect)(()=>{(0,ns.N)(B,_("errorLoadingFormSchema","Error loading form schema"))},[B]),(0,d.useEffect)(()=>()=>{fb()},[]),(0,d.useEffect)(()=>{h?.(M)},[M]);let Y=(0,d.useCallback)(e=>{e.preventDefault(),V(!0)},[]);return f().createElement("form",{ref:x,noValidate:!0,className:m()("cds--form",pq),onSubmit:Y},D||$?f().createElement(pb,null):f().createElement(cx,{patient:O,isLoadingDependencies:C,patientUUID:t,sessionMode:I,sessionDate:k,formJson:R,workspaceLayout:"ultra-wide"===S?"maximized":"minimized",location:w?.sessionLocation,provider:w?.currentProvider,visit:i,handleConfirmQuestionDeletion:p,isFormExpanded:N,formSubmissionProps:{isSubmitting:T,setIsSubmitting:V,onSubmit:l,onError:()=>{},handleClose:()=>{}},hideFormCollapseToggle:L,setIsFormDirty:j},f().createElement("div",{className:pR},C&&f().createElement("div",{className:pW},f().createElement("div",{className:pY})),f().createElement("div",{className:p$},W&&f().createElement(pL,{isFormSubmitting:T,sessionMode:a,defaultPage:R.defaultPage,onCancel:s,handleClose:c,hideFormCollapseToggle:L,hideControls:g}),f().createElement("div",{className:pB},H&&f().createElement(pk,{patient:O,hideActionsOverflow:!0}),R.markdown&&f().createElement("div",{className:pU},f().createElement(sk,{markdown:R.markdown})),f().createElement("div",{className:pH},f().createElement(px,{formJson:R,setIsLoadingFormDependencies:P})),U&&!g&&f().createElement(y.ButtonSet,{className:pz},f().createElement(y.Button,{kind:"secondary",onClick:()=>{s&&s(),c&&c(),L()}},"view"===a?_("close","Close"):_("cancel","Cancel")),f().createElement(y.Button,{className:pJ,disabled:C||T||"view"===a,kind:"primary",type:"submit"},T?f().createElement(y.InlineLoading,{description:_("submitting","Submitting")+"..."}):f().createElement("span",null,`${_("save","Save")}`))))))))},pG=function(e){return f().createElement(d.Suspense,{fallback:f().createElement(pb,null)},f().createElement(e9.I18nextProvider,{i18n:window.i18next,defaultNS:u6.L},f().createElement(pZ,e)))}},1809(e,t,n){"use strict";function r(e){return"boolean"==typeof e?e:"string"==typeof e?"true"==e:!!e}function i(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}n.d(t,{H:()=>r,O:()=>i})},8059(e,t,n){"use strict";n.d(t,{N:()=>i,j:()=>o});var r=n(2293);function i(e,t){if(e){let n=o(e).join(", ");console.error(e),(0,r.showSnackbar)({subtitle:n,title:t,kind:"error",isLowContrast:!1})}}function o(e){let t=e?.responseBody?.error?.fieldErrors,n=e?.responseBody?.error?.globalErrors;return t&&0!==Object.keys(t).length||n?n?.length?n.flatMap(e=>e.message):Object.values(t).flatMap(e=>e.map(e=>e.message)):[e?.responseBody?.error?.message??e?.message]}},9804(__unused_rspack_module,__webpack_exports__,__webpack_require__){"use strict";function evaluatePostSubmissionExpression(expression,encounters){let match,encounter=encounters[0],regx=/(?:\w+|'(?:\\'|[^'\n])*')/g,fieldIds=new Set;try{let replacedExpression;for(;match=regx.exec(expression);){let value=match[0].replace(/\\'/g,"'"),isBoolean=/^(true|false)$/i.test(value),isNumber=/^-?\d+$/.test(value),isFloat=/^-?\d+\.\d+$/.test(value);value.startsWith("'")&&value.endsWith("'")||"string"!=typeof value||isBoolean||isNumber||isFloat||fieldIds.add(value)}let fieldToValueMap={};return fieldIds.size&&(fieldToValueMap=getFieldValues(fieldIds,encounter)),replacedExpression=Object.keys(fieldToValueMap).length?expression.replace(/(\w+)/g,e=>Object.prototype.hasOwnProperty.call(fieldToValueMap,e)?fieldToValueMap[e]:e):expression,eval(replacedExpression)}catch(error){throw Error("Error evaluating expression")}}function getFieldValues(e,t){let n={};return e.forEach(e=>{let r=t.obs?.find(t=>t.formFieldPath.includes(e))?.value;"object"==typeof r&&(r=r.uuid),r&&(r=formatValue(r)),n[e]=r}),n}function formatValue(e){if("string"==typeof e&&(!(e.length>=2)||"'"!==e[0]||"'"!==e[e.length-1]))return`'${e}'`;return e}__webpack_require__.d(__webpack_exports__,{g:()=>evaluatePostSubmissionExpression})},1630(e){!function(t){e.exports=t()}(function(){"use strict";var e={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"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,a={},l=function(e){return(e*=1)+(e>68?1900:2e3)},s=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e||"Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],c=function(e){var t=a[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=a.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[o,function(e){this.afternoon=d(e,!1)}],a:[o,function(e){this.afternoon=d(e,!0)}],Q:[n,function(e){this.month=3*(e-1)+1}],S:[n,function(e){this.milliseconds=100*e}],SS:[r,function(e){this.milliseconds=10*e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[i,s("seconds")],ss:[i,s("seconds")],m:[i,s("minutes")],mm:[i,s("minutes")],H:[i,s("hours")],h:[i,s("hours")],HH:[i,s("hours")],hh:[i,s("hours")],D:[i,s("day")],DD:[r,s("day")],Do:[o,function(e){var t=a.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],w:[i,s("week")],ww:[r,s("week")],M:[i,s("month")],MM:[r,s("month")],MMM:[o,function(e){var t=c("months"),n=(c("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw Error();this.month=n%12||n}],MMMM:[o,function(e){var t=c("months").indexOf(e)+1;if(t<1)throw Error();this.month=t%12||t}],Y:[/[+-]?\d+/,s("year")],YY:[r,function(e){this.year=l(e)}],YYYY:[/\d{4}/,s("year")],Z:u,ZZ:u};function p(n){var r,i;r=n,i=a&&a.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(t),l=o.length,s=0;s<l;s+=1){var u=o[s],c=f[u],d=c&&c[0],p=c&&c[1];o[s]=p?{regex:d,parser:p}:u.replace(/^\[|\]$/g,"")}return function(e){for(var t={},n=0,r=0;n<l;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else{var a=i.regex,s=i.parser,u=e.slice(r),c=a.exec(u)[0];s.call(t,c),e=e.replace(c,"")}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(l=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,o=e.args;this.$u=r;var l=o[1];if("string"==typeof l){var s=!0===o[2],u=!0===o[3],c=s||u,d=o[2];u&&(d=o[2]),a=this.$locale(),!s&&d&&(a=n.Ls[d]),this.$d=function(e,t,n,r){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var i=p(t)(e),o=i.year,a=i.month,l=i.day,s=i.hours,u=i.minutes,c=i.seconds,d=i.milliseconds,f=i.zone,m=i.week,h=new Date,g=l||(o||a?1:h.getDate()),y=o||h.getFullYear(),v=0;o&&!a||(v=a>0?a-1:h.getMonth());var b,_=s||0,w=u||0,x=c||0,E=d||0;return f?new Date(Date.UTC(y,v,g,_,w,x,E+60*f.offset*1e3)):n?new Date(Date.UTC(y,v,g,_,w,x,E)):(b=new Date(y,v,g,_,w,x,E),m&&(b=r(b).week(m).toDate()),b)}catch(e){return new Date("")}}(t,l,r,n),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),c&&t!=this.format(l)&&(this.$d=new Date("")),a={}}else if(l instanceof Array)for(var f=l.length,m=1;m<=f;m+=1){o[1]=l[m-1];var h=n.apply(this,o);if(h.isValid()){this.$d=h.$d,this.$L=h.$L,this.init();break}m===f&&(this.$d=new Date(""))}else i.call(this,e)}}})},9710(e){"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,i=t.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!i&&!o)return!1;for(r in e);return void 0===r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;else if(i)return i(e,n).value}return e[n]};e.exports=function e(){var t,n,r,i,u,c,d=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<p;++f)if(t=arguments[f],null!=t)for(n in t)r=s(d,n),d!==(i=s(t,n))&&(m&&i&&(a(i)||(u=o(i)))?(u?(u=!1,c=r&&o(r)?r:[]):c=r&&a(r)?r:{},l(d,{name:n,newValue:e(m,c,i)})):void 0!==i&&l(d,{name:n,newValue:i}));return d}},5937(e){var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,s=/^\s+|\s+$/g,u="\n",c="/",d="*",f="",p="comment",m="declaration";function h(e){return e?e.replace(s,f):f}e.exports=function(e,s){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];s=s||{};var g=1,y=1;function v(e){var t=e.match(n);t&&(g+=t.length);var r=e.lastIndexOf(u);y=~r?e.length-r:y+e.length}function b(){var e={line:g,column:y};return function(t){return t.position=new _(e),k(),t}}function _(e){this.start=e,this.end={line:g,column:y},this.source=s.source}_.prototype.content=e;var w=[];function x(t){var n=Error(s.source+":"+g+":"+y+": "+t);if(n.reason=t,n.filename=s.source,n.line=g,n.column=y,n.source=e,s.silent)w.push(n);else throw n}function E(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function k(){E(r)}function S(e){var t;for(e=e||[];t=O();)!1!==t&&e.push(t);return e}function O(){var t=b();if(c==e.charAt(0)&&d==e.charAt(1)){for(var n=2;f!=e.charAt(n)&&(d!=e.charAt(n)||c!=e.charAt(n+1));)++n;if(n+=2,f===e.charAt(n-1))return x("End of comment missing");var r=e.slice(2,n-2);return y+=2,v(r),e=e.slice(n),y+=2,t({type:p,comment:r})}}function D(){var e=b(),n=E(i);if(n){if(O(),!E(o))return x("property missing ':'");var r=E(a),s=e({type:m,property:h(n[0].replace(t,f)),value:r?h(r[0].replace(t,f)):f});return E(l),s}}function C(){var e,t=[];for(S(t);e=D();)!1!==e&&(t.push(e),S(t));return t}return k(),C()}},3103(e,t,n){e.exports=n(4715)(n(8942),"DataView")},5098(e,t,n){var r=n(3305),i=n(9361),o=n(1112),a=n(5276),l=n(5071);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},1386(e,t,n){var r=n(2393),i=n(2049),o=n(7144),a=n(7452),l=n(3964);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9770(e,t,n){e.exports=n(4715)(n(8942),"Map")},8250(e,t,n){var r=n(9753),i=n(5681),o=n(88),a=n(4732),l=n(9068);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9413(e,t,n){e.exports=n(4715)(n(8942),"Promise")},4512(e,t,n){e.exports=n(4715)(n(8942),"Set")},3212(e,t,n){var r=n(8250),i=n(1877),o=n(8006);function a(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}a.prototype.add=a.prototype.push=i,a.prototype.has=o,e.exports=a},1340(e,t,n){var r=n(1386),i=n(4103),o=n(1779),a=n(4162),l=n(7462),s=n(6638);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=i,u.prototype.delete=o,u.prototype.get=a,u.prototype.has=l,u.prototype.set=s,e.exports=u},5650(e,t,n){e.exports=n(8942).Symbol},1623(e,t,n){e.exports=n(8942).Uint8Array},9270(e,t,n){e.exports=n(4715)(n(8942),"WeakMap")},9968(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},9847(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}},358(e,t,n){var r=n(6137),i=n(3283),o=n(3142),a=n(5853),l=n(9632),s=n(8666),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=o(e),c=!n&&i(e),d=!n&&!c&&a(e),f=!n&&!c&&!d&&s(e),p=n||c||d||f,m=p?r(e.length,String):[],h=m.length;for(var g in e)(t||u.call(e,g))&&!(p&&("length"==g||d&&("offset"==g||"parent"==g)||f&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||l(g,h)))&&m.push(g);return m}},5111(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}},1129(e){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},6465(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},7034(e,t,n){var r=n(6285);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return -1}},4570(e,t,n){var r=n(7170);e.exports=n(5770)(r)},4661(e,t,n){var r=n(4570);e.exports=function(e,t){var n=[];return r(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}},7250(e){e.exports=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return -1}},5636(e,t,n){e.exports=n(6596)()},7170(e,t,n){var r=n(5636),i=n(1211);e.exports=function(e,t){return e&&r(e,t,i)}},7923(e,t,n){var r=n(3526),i=n(6040);e.exports=function(e,t){t=r(t,e);for(var n=0,o=t.length;null!=e&&n<o;)e=e[i(t[n++])];return n&&n==o?e:void 0}},8244(e,t,n){var r=n(1129),i=n(3142);e.exports=function(e,t,n){var o=t(e);return i(e)?o:r(o,n(e))}},7379(e,t,n){var r=n(5650),i=n(8870),o=n(9005),a="[object Null]",l="[object Undefined]",s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?l:a:s&&s in Object(e)?i(e):o(e)}},3636(e){e.exports=function(e,t){return null!=e&&t in Object(e)}},6027(e,t,n){var r=n(7379),i=n(547),o="[object Arguments]";e.exports=function(e){return i(e)&&r(e)==o}},4687(e,t,n){var r=n(353),i=n(547);function o(e,t,n,a,l){return e===t||(null!=e&&null!=t&&(i(e)||i(t))?r(e,t,n,a,o,l):e!=e&&t!=t)}e.exports=o},353(e,t,n){var r=n(1340),i=n(3934),o=n(8861),a=n(1182),l=n(8486),s=n(3142),u=n(5853),c=n(8666),d=1,f="[object Arguments]",p="[object Array]",m="[object Object]",h=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,g,y,v){var b=s(e),_=s(t),w=b?p:l(e),x=_?p:l(t);w=w==f?m:w,x=x==f?m:x;var E=w==m,k=x==m,S=w==x;if(S&&u(e)){if(!u(t))return!1;b=!0,E=!1}if(S&&!E)return v||(v=new r),b||c(e)?i(e,t,n,g,y,v):o(e,t,w,n,g,y,v);if(!(n&d)){var O=E&&h.call(e,"__wrapped__"),D=k&&h.call(t,"__wrapped__");if(O||D){var C=O?e.value():e,F=D?t.value():t;return v||(v=new r),y(C,F,n,g,v)}}return!!S&&(v||(v=new r),a(e,t,n,g,y,v))}},8330(e,t,n){var r=n(1340),i=n(4687),o=1,a=2;e.exports=function(e,t,n,l){var s=n.length,u=s,c=!l;if(null==e)return!u;for(e=Object(e);s--;){var d=n[s];if(c&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++s<u;){var f=(d=n[s])[0],p=e[f],m=d[1];if(c&&d[2]){if(void 0===p&&!(f in e))return!1}else{var h=new r;if(l)var g=l(p,m,f,e,t,h);if(!(void 0===g?i(m,p,o|a,l,h):g))return!1}}return!0}},9624(e,t,n){var r=n(3655),i=n(4759),o=n(1580),a=n(4066),l=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,u=Object.prototype,c=Function.prototype.toString,d=u.hasOwnProperty,f=RegExp("^"+c.call(d).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?f:s).test(a(e))}},674(e,t,n){var r=n(7379),i=n(5387),o=n(547),a="[object Arguments]",l="[object Array]",s="[object Boolean]",u="[object Date]",c="[object Error]",d="[object Function]",f="[object Map]",p="[object Number]",m="[object Object]",h="[object RegExp]",g="[object Set]",y="[object String]",v="[object WeakMap]",b="[object ArrayBuffer]",_="[object DataView]",w="[object Float64Array]",x="[object Int8Array]",E="[object Int16Array]",k="[object Int32Array]",S="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",C="[object Uint32Array]",F={};F["[object Float32Array]"]=F[w]=F[x]=F[E]=F[k]=F[S]=F[O]=F[D]=F[C]=!0,F[a]=F[l]=F[b]=F[s]=F[_]=F[u]=F[c]=F[d]=F[f]=F[p]=F[m]=F[h]=F[g]=F[y]=F[v]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!F[r(e)]}},3334(e,t,n){var r=n(6526),i=n(2343),o=n(2053),a=n(3142),l=n(3282);e.exports=function(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?a(e)?i(e[0],e[1]):r(e):l(e)}},195(e,t,n){var r=n(4882),i=n(8121),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},6526(e,t,n){var r=n(8330),i=n(4367),o=n(3904);e.exports=function(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},2343(e,t,n){var r=n(4687),i=n(6123),o=n(7276),a=n(5187),l=n(7267),s=n(3904),u=n(6040),c=1,d=2;e.exports=function(e,t){return a(e)&&l(t)?s(u(e),t):function(n){var a=i(n,e);return void 0===a&&a===t?o(n,e):r(t,a,c|d)}}},2762(e){e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},8880(e,t,n){var r=n(7923);e.exports=function(e){return function(t){return r(t,e)}}},6137(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},2291(e,t,n){var r=n(5650),i=n(5111),o=n(3142),a=n(1187),l=1/0,s=r?r.prototype:void 0,u=s?s.toString:void 0;function c(e){if("string"==typeof e)return e;if(o(e))return i(e,c)+"";if(a(e))return u?u.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}e.exports=c},6403(e,t,n){var r=n(2945),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},9460(e){e.exports=function(e){return function(t){return e(t)}}},5568(e){e.exports=function(e,t){return e.has(t)}},3997(e,t,n){var r=n(2053);e.exports=function(e){return"function"==typeof e?e:r}},3526(e,t,n){var r=n(3142),i=n(5187),o=n(6493),a=n(5243);e.exports=function(e,t){return r(e)?e:i(e,t)?[e]:o(a(e))}},1950(e,t,n){e.exports=n(8942)["__core-js_shared__"]},5770(e,t,n){var r=n(6529);e.exports=function(e,t){return function(n,i){if(null==n)return n;if(!r(n))return e(n,i);for(var o=n.length,a=t?o:-1,l=Object(n);(t?a--:++a<o)&&!1!==i(l[a],a,l););return n}}},6596(e){e.exports=function(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),l=a.length;l--;){var s=a[e?l:++i];if(!1===n(o[s],s,o))break}return t}}},3934(e,t,n){var r=n(3212),i=n(6465),o=n(5568),a=1,l=2;e.exports=function(e,t,n,s,u,c){var d=n&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=-1,y=!0,v=n&l?new r:void 0;for(c.set(e,t),c.set(t,e);++g<f;){var b=e[g],_=t[g];if(s)var w=d?s(_,b,g,t,e,c):s(b,_,g,e,t,c);if(void 0!==w){if(w)continue;y=!1;break}if(v){if(!i(t,function(e,t){if(!o(v,t)&&(b===e||u(b,e,n,s,c)))return v.push(t)})){y=!1;break}}else if(!(b===_||u(b,_,n,s,c))){y=!1;break}}return c.delete(e),c.delete(t),y}},8861(e,t,n){var r=n(5650),i=n(1623),o=n(6285),a=n(3934),l=n(5894),s=n(9828),u=1,c=2,d="[object Boolean]",f="[object Date]",p="[object Error]",m="[object Map]",h="[object Number]",g="[object RegExp]",y="[object Set]",v="[object String]",b="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",x=r?r.prototype:void 0,E=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,k,S){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case _:if(e.byteLength!=t.byteLength||!k(new i(e),new i(t)))break;return!0;case d:case f:case h:return o(+e,+t);case p:return e.name==t.name&&e.message==t.message;case g:case v:return e==t+"";case m:var O=l;case y:var D=r&u;if(O||(O=s),e.size!=t.size&&!D)break;var C=S.get(e);if(C)return C==t;r|=c,S.set(e,t);var F=a(O(e),O(t),r,x,k,S);return S.delete(e),F;case b:if(E)return E.call(e)==E.call(t)}return!1}},1182(e,t,n){var r=n(393),i=1,o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,a,l,s){var u=n&i,c=r(e),d=c.length;if(d!=r(t).length&&!u)return!1;for(var f=d;f--;){var p=c[f];if(!(u?p in t:o.call(t,p)))return!1}var m=s.get(e),h=s.get(t);if(m&&h)return m==t&&h==e;var g=!0;s.set(e,t),s.set(t,e);for(var y=u;++f<d;){var v=e[p=c[f]],b=t[p];if(a)var _=u?a(b,v,p,t,e,s):a(v,b,p,e,t,s);if(!(void 0===_?v===b||l(v,b,n,a,s):_)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var w=e.constructor,x=t.constructor;w!=x&&"constructor"in e&&"constructor"in t&&!("function"==typeof w&&w instanceof w&&"function"==typeof x&&x instanceof x)&&(g=!1)}return s.delete(e),s.delete(t),g}},4967(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},393(e,t,n){var r=n(8244),i=n(7979),o=n(1211);e.exports=function(e){return r(e,o,i)}},4700(e,t,n){var r=n(9067);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},4367(e,t,n){var r=n(7267),i=n(1211);e.exports=function(e){for(var t=i(e),n=t.length;n--;){var o=t[n],a=e[o];t[n]=[o,a,r(a)]}return t}},4715(e,t,n){var r=n(9624),i=n(155);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},8870(e,t,n){var r=n(5650),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,l=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,l),n=e[l];try{e[l]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[l]=n:delete e[l]),i}},7979(e,t,n){var r=n(9847),i=n(9306),o=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;e.exports=a?function(e){return null==e?[]:r(a(e=Object(e)),function(t){return o.call(e,t)})}:i},8486(e,t,n){var r=n(3103),i=n(9770),o=n(9413),a=n(4512),l=n(9270),s=n(7379),u=n(4066),c="[object Map]",d="[object Object]",f="[object Promise]",p="[object Set]",m="[object WeakMap]",h="[object DataView]",g=u(r),y=u(i),v=u(o),b=u(a),_=u(l),w=s;(r&&w(new r(new ArrayBuffer(1)))!=h||i&&w(new i)!=c||o&&w(o.resolve())!=f||a&&w(new a)!=p||l&&w(new l)!=m)&&(w=function(e){var t=s(e),n=t==d?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case g:return h;case y:return c;case v:return f;case b:return p;case _:return m}return t}),e.exports=w},155(e){e.exports=function(e,t){return null==e?void 0:e[t]}},5899(e,t,n){var r=n(3526),i=n(3283),o=n(3142),a=n(9632),l=n(5387),s=n(6040);e.exports=function(e,t,n){t=r(t,e);for(var u=-1,c=t.length,d=!1;++u<c;){var f=s(t[u]);if(!(d=null!=e&&n(e,f)))break;e=e[f]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&l(c)&&a(f,c)&&(o(e)||i(e))}},3305(e,t,n){var r=n(4497);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},9361(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t}},1112(e,t,n){var r=n(4497),i="__lodash_hash_undefined__",o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===i?void 0:n}return o.call(t,e)?t[e]:void 0}},5276(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:i.call(t,e)}},5071(e,t,n){var r=n(4497),i="__lodash_hash_undefined__";e.exports=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=r&&void 0===t?i:t,this}},9632(e){var t=0x1fffffffffffff,n=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var i=typeof e;return!!(r=null==r?t:r)&&("number"==i||"symbol"!=i&&n.test(e))&&e>-1&&e%1==0&&e<r}},5187(e,t,n){var r=n(3142),i=n(1187),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||i(e))||a.test(e)||!o.test(e)||null!=t&&e in Object(t)}},9067(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4759(e,t,n){var r=n(1950),i=function(){var e=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();e.exports=function(e){return!!i&&i in e}},4882(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},7267(e,t,n){var r=n(1580);e.exports=function(e){return e==e&&!r(e)}},2393(e){e.exports=function(){this.__data__=[],this.size=0}},2049(e,t,n){var r=n(7034),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0)&&(n==t.length-1?t.pop():i.call(t,n,1),--this.size,!0)}},7144(e,t,n){var r=n(7034);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},7452(e,t,n){var r=n(7034);e.exports=function(e){return r(this.__data__,e)>-1}},3964(e,t,n){var r=n(7034);e.exports=function(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},9753(e,t,n){var r=n(5098),i=n(1386),o=n(9770);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(o||i),string:new r}}},5681(e,t,n){var r=n(4700);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=!!t,t}},88(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).get(e)}},4732(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).has(e)}},9068(e,t,n){var r=n(4700);e.exports=function(e,t){var n=r(this,e),i=n.size;return n.set(e,t),this.size+=+(n.size!=i),this}},5894(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},3904(e){e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},6853(e,t,n){var r=n(9011),i=500;e.exports=function(e){var t=r(e,function(e){return n.size===i&&n.clear(),e}),n=t.cache;return t}},4497(e,t,n){e.exports=n(4715)(Object,"create")},8121(e,t,n){e.exports=n(3766)(Object.keys,Object)},2306(e,t,n){e=n.nmd(e);var r=n(4967),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i&&r.process,l=function(){try{var e=o&&o.require&&o.require("util").types;if(e)return e;return a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=l},9005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},3766(e){e.exports=function(e,t){return function(n){return e(t(n))}}},8942(e,t,n){var r=n(4967),i="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||i||Function("return this")()},1877(e){var t="__lodash_hash_undefined__";e.exports=function(e){return this.__data__.set(e,t),this}},8006(e){e.exports=function(e){return this.__data__.has(e)}},9828(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4103(e,t,n){var r=n(1386);e.exports=function(){this.__data__=new r,this.size=0}},1779(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4162(e){e.exports=function(e){return this.__data__.get(e)}},7462(e){e.exports=function(e){return this.__data__.has(e)}},6638(e,t,n){var r=n(1386),i=n(9770),o=n(8250),a=200;e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var l=n.__data__;if(!i||l.length<a-1)return l.push([e,t]),this.size=++n.size,this;n=this.__data__=new o(l)}return n.set(e,t),this.size=n.size,this}},6493(e,t,n){var r=n(6853),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g;e.exports=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(i,function(e,n,r,i){t.push(r?i.replace(o,"$1"):n||e)}),t})},6040(e,t,n){var r=n(1187),i=1/0;e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},4066(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},2945(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},6285(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},7581(e,t,n){var r=n(9847),i=n(4661),o=n(3334),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t,3))}},2154(e,t,n){var r=n(7250),i=n(3334),o=n(7642),a=Math.max;e.exports=function(e,t,n){var l=null==e?0:e.length;if(!l)return -1;var s=null==n?0:o(n);return s<0&&(s=a(l+s,0)),r(e,i(t,3),s)}},7289(e,t,n){e.exports=n(3981)},3657(e,t,n){var r=n(9968),i=n(4570),o=n(3997),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t))}},6123(e,t,n){var r=n(7923);e.exports=function(e,t,n){var i=null==e?void 0:r(e,t);return void 0===i?n:i}},7276(e,t,n){var r=n(3636),i=n(5899);e.exports=function(e,t){return null!=e&&i(e,t,r)}},3981(e){e.exports=function(e){return e&&e.length?e[0]:void 0}},2053(e){e.exports=function(e){return e}},3283(e,t,n){var r=n(6027),i=n(547),o=Object.prototype,a=o.hasOwnProperty,l=o.propertyIsEnumerable;e.exports=r(function(){return arguments}())?r:function(e){return i(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},3142(e){e.exports=Array.isArray},6529(e,t,n){var r=n(3655),i=n(5387);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},5853(e,t,n){e=n.nmd(e);var r=n(8942),i=n(4772),o=t&&!t.nodeType&&t,a=o&&e&&!e.nodeType&&e,l=a&&a.exports===o?r.Buffer:void 0,s=(l?l.isBuffer:void 0)||i;e.exports=s},3655(e,t,n){var r=n(7379),i=n(1580),o="[object AsyncFunction]",a="[object Function]",l="[object GeneratorFunction]",s="[object Proxy]";e.exports=function(e){if(!i(e))return!1;var t=r(e);return t==a||t==l||t==o||t==s}},5387(e){var t=0x1fffffffffffff;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=t}},1580(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},1187(e,t,n){var r=n(7379),i=n(547),o="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||i(e)&&r(e)==o}},8666(e,t,n){var r=n(674),i=n(9460),o=n(2306),a=o&&o.isTypedArray;e.exports=a?i(a):r},1211(e,t,n){var r=n(358),i=n(195),o=n(6529);e.exports=function(e){return o(e)?r(e):i(e)}},8087(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},9011(e,t,n){var r=n(8250),i="Expected a function";function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError(i);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},3282(e,t,n){var r=n(2762),i=n(8880),o=n(5187),a=n(6040);e.exports=function(e){return o(e)?r(a(e)):i(e)}},9306(e){e.exports=function(){return[]}},4772(e){e.exports=function(){return!1}},3301(e,t,n){var r=n(6131),i=1/0,o=17976931348623157e292;e.exports=function(e){return e?(e=r(e))===i||e===-i?(e<0?-1:1)*o:e==e?e:0:0===e?e:0}},7642(e,t,n){var r=n(3301);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},6131(e,t,n){var r=n(6403),i=n(1580),o=n(1187),a=0/0,l=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return a;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=s.test(e);return n||u.test(e)?c(e.slice(2),n?2:8):l.test(e)?a:+e}},5243(e,t,n){var r=n(2291);e.exports=function(e){return null==e?"":r(e)}},2281(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},6783(e,t,n){"use strict";let r=n(4517),i=n(3955),{safeRe:o,t:a}=n(2841);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){let r,i=t.includePrerelease?o[a.COERCERTLFULL]:o[a.COERCERTL];for(;(r=i.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&r.index+r[0].length===n.index+n[0].length||(n=r),i.lastIndex=r.index+r[1].length+r[2].length;i.lastIndex=-1}else n=e.match(t.includePrerelease?o[a.COERCEFULL]:o[a.COERCE]);if(null===n)return null;let l=n[2],s=n[3]||"0",u=n[4]||"0",c=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${l}.${s}.${u}${c}${d}`,t)}},6106(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n)=>{let i=new r(e,n),o=new r(t,n);return i.compare(o)||i.compareBuild(o)}},2132(e,t,n){"use strict";let r=n(7851);e.exports=(e,t)=>r(e,t,!0)},3269(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,null,!0),i=r(t,null,!0),o=n.compare(i);if(0===o)return null;let a=o>0,l=a?n:i,s=a?i:n,u=!!l.prerelease.length;if(s.prerelease.length&&!u){if(!s.patch&&!s.minor)return"major";if(0===s.compareMain(l))return s.minor&&!s.patch?"minor":"patch"}let c=u?"pre":"";return n.major!==i.major?c+"major":n.minor!==i.minor?c+"minor":n.patch!==i.patch?c+"patch":"prerelease"}},8868(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,o).version}catch(e){return null}}},6381(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).major},1353(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).minor},3955(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},6082(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).patch},9428(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},7555(e,t,n){"use strict";let r=n(7851);e.exports=(e,t,n)=>r(t,e,n)},3810(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(n,e,t))},4042(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(e,n,t))},8474(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n?n.version:null}},2722(e,t,n){"use strict";let r=n(2841),i=n(9543),o=n(4517),a=n(3806),l=n(3955),s=n(8474),u=n(2281),c=n(8868),d=n(3269),f=n(6381),p=n(1353),m=n(6082),h=n(9428),g=n(7851),y=n(7555),v=n(2132),b=n(6106),_=n(4042),w=n(3810),x=n(9761),E=n(1262),k=n(8848),S=n(8220),O=n(2386),D=n(9639),C=n(4004),F=n(6783),A=n(1565),P=n(7476),T=n(7229),V=n(6364),M=n(5039),j=n(5357),I=n(1280),N=n(7403),L=n(8854),q=n(7226),R=n(7183),$=n(8623);e.exports={parse:l,valid:s,clean:u,inc:c,diff:d,major:f,minor:p,patch:m,prerelease:h,compare:g,rcompare:y,compareLoose:v,compareBuild:b,sort:_,rsort:w,gt:x,lt:E,eq:k,neq:S,gte:O,lte:D,cmp:C,coerce:F,Comparator:A,Range:P,satisfies:T,toComparators:V,maxSatisfying:M,minSatisfying:j,minVersion:I,validRange:N,outside:L,gtr:q,ltr:R,intersects:$,simplifyRange:n(6486),subset:n(583),SemVer:o,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},7226(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,">",n)},8623(e,t,n){"use strict";let r=n(7476);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},7183(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,"<",n)},5039(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||-1===a.compare(e))&&(a=new r(o=e,n))}),o}},5357(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||1===a.compare(e))&&(a=new r(o=e,n))}),o}},1280(e,t,n){"use strict";let r=n(4517),i=n(7476),o=n(9761);e.exports=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)||(n=new r("0.0.0-0"),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],a=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":(!a||o(t,a))&&(a=t);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),a&&(!n||o(n,a))&&(n=a)}return n&&e.test(n)?n:null}},8854(e,t,n){"use strict";let r=n(4517),i=n(1565),{ANY:o}=i,a=n(7476),l=n(7229),s=n(9761),u=n(1262),c=n(9639),d=n(2386);e.exports=(e,t,n,f)=>{let p,m,h,g,y;switch(e=new r(e,f),t=new a(t,f),n){case">":p=s,m=c,h=u,g=">",y=">=";break;case"<":p=u,m=d,h=s,g="<",y="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(l(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let r=t.set[n],a=null,l=null;if(r.forEach(e=>{e.semver===o&&(e=new i(">=0.0.0")),a=a||e,l=l||e,p(e.semver,a.semver,f)?a=e:h(e.semver,l.semver,f)&&(l=e)}),a.operator===g||a.operator===y||(!l.operator||l.operator===g)&&m(e,l.semver)||l.operator===y&&h(e,l.semver))return!1}return!0}},6486(e,t,n){"use strict";let r=n(7229),i=n(7851);e.exports=(e,t,n)=>{let o=[],a=null,l=null,s=e.sort((e,t)=>i(e,t,n));for(let e of s)r(e,t,n)?(l=e,a||(a=e)):(l&&o.push([a,l]),l=null,a=null);a&&o.push([a,null]);let u=[];for(let[e,t]of o)e===t?u.push(e):t||e!==s[0]?t?e===s[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");let c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},583(e,t,n){"use strict";let r=n(7476),i=n(1565),{ANY:o}=i,a=n(7229),l=n(7851),s=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let i=!1;e:for(let r of e.set){for(let e of t.set){let t=d(r,e,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0},u=[new i(">=0.0.0-0")],c=[new i(">=0.0.0")],d=(e,t,n)=>{let r,i,s,d,m,h,g;if(e===t)return!0;if(1===e.length&&e[0].semver===o)if(1===t.length&&t[0].semver===o)return!0;else e=n.includePrerelease?u:c;if(1===t.length&&t[0].semver===o)if(n.includePrerelease)return!0;else t=c;let y=new Set;for(let t of e)">"===t.operator||">="===t.operator?r=f(r,t,n):"<"===t.operator||"<="===t.operator?i=p(i,t,n):y.add(t.semver);if(y.size>1)return null;if(r&&i&&((s=l(r.semver,i.semver,n))>0||0===s&&(">="!==r.operator||"<="!==i.operator)))return null;for(let e of y){if(r&&!a(e,String(r),n)||i&&!a(e,String(i),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let v=!!i&&!n.includePrerelease&&!!i.semver.prerelease.length&&i.semver,b=!!r&&!n.includePrerelease&&!!r.semver.prerelease.length&&r.semver;for(let e of(v&&1===v.prerelease.length&&"<"===i.operator&&0===v.prerelease[0]&&(v=!1),t)){if(g=g||">"===e.operator||">="===e.operator,h=h||"<"===e.operator||"<="===e.operator,r){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if((d=f(r,e,n))===e&&d!==r)return!1}else if(">="===r.operator&&!a(r.semver,String(e),n))return!1}if(i){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),"<"===e.operator||"<="===e.operator){if((m=p(i,e,n))===e&&m!==i)return!1}else if("<="===i.operator&&!a(i.semver,String(e),n))return!1}if(!e.operator&&(i||r)&&0!==s)return!1}return(!r||!h||!!i||0===s)&&(!i||!g||!!r||0===s)&&!b&&!v&&!0},f=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},p=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=s},6364(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "))},7403(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},8052(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var i=r(n(5937));function o(e,t){var n=null;if(!e||"string"!=typeof e)return n;var r=(0,i.default)(e),o="function"==typeof t;return r.forEach(function(e){if("declaration"===e.type){var r=e.property,i=e.value;o?t(r,i,e):i&&((n=n||{})[r]=i)}}),n}}}]);
|
|
5
|
+
failing expression: ${e}`)}return null}function t2(e,t,n,r){let{myValue:i,patient:o}=r,{sex:a,age:l}=o??{};"field"===e.type&&void 0===i&&e.value&&(i=n[e.value.id]);let s=new tQ;s.putObject("prevEnc",{value:r.previousEncounter||{obs:[]},getValue(e){return this.value.obs.find(t=>t.concept.uuid==e)}});let u=r?.visit??{},c=u?.visitType||{uuid:""},d=c.uuid??"",f={isEmpty:tx.A};return{...new tY(e,o,t,n),...dP(),...r,...n,patient:o,myValue:i,sex:a,age:l,HD:s,visit:u,visitType:c,visitTypeUuid:d,_:f}}function t4(e){let t=tJ(e);if(tK.has(t))return tK.get(t);let n=(0,u.compile)(e);return tK.set(t,n),n}function t5(e,t,n){for(let r of(0,u.extractVariableNames)(e)){let e=n.find(e=>e.id===r);e&&tZ(t,e)}}function t3(e,t,n,r){return"embedded-view"==r||("automatic"==e?"maximized"==n&&t.endsWith("desktop"):"single-line"==e)}function t6(e,t){let n=e.validators.find(e=>"conditionalAnswered"===e.type).referenceQuestionId,r=t.find(e=>e.id==n);r&&(r.fieldDependents||(r.fieldDependents=new Set)).add(e.id)}function t9(e,t,n){if("object"!=typeof e.required)return!1;let{referenceQuestionAnswers:r,referenceQuestionId:i}=e.required,o=t.find(e=>e.id==i);return!!o&&((o.fieldDependents||(o.fieldDependents=new Set)).add(e.id),r?.includes(n[i]))}function t7(e,t,n,r,i,o){let{value:a}=e;return o(a.disabled?.disableWhenExpression,e,t,n,{mode:r,patient:i})}function t8(e,t,n,r,i,o,a){let{value:l,type:s}=e,u=o(l.hide?.hideWhenExpression,e,t,n,{mode:r,patient:i});e.value.isHidden=u,"field"==s&&e.value?.questions?.length&&e.value?.questions.forEach(e=>{e.isParentHidden=u}),"page"==s&&l.sections.forEach(e=>{e.isParentHidden=u,ne(u,e,t,a)}),"section"==s&&ne(u,l,t,a)}function ne(e,t,n,r){let i=t.questions.map(e=>e.id);n.filter(e=>i.includes(e.id)).forEach(t=>{t.isParentHidden=e,"group"==t.questionOptions.rendering&&t.questions.forEach(t=>{t.isParentHidden=e}),r?.(t)})}function nt(e,t){if(!e?.includes(":"))return t?.find(t=>t.uuid===e);{let[n,r]=e.split(":");return t?.find(e=>e?.conceptMappings?.find(e=>e?.conceptReferenceTerm?.conceptSource?.name.toUpperCase()===n.toUpperCase()&&e?.conceptReferenceTerm?.code.toUpperCase()===r.toUpperCase()))}}function nn(e,t=!1){let n=document.getElementById(e);n?.scrollIntoView({behavior:"smooth",block:"start",inline:"center"}),t&&n?.focus()}let nr=(e,t)=>{let n=e.questionOptions.rendering;if("object"!=typeof t)return{value:t,display:t};let r="Observation"===t.resourceType?no(t,n):t;if(!r)return{value:null,display:null};if("string"==typeof r.value||"number"==typeof r.value){if("date"===n||"datetime"===n){let e=ty(`${r.value}`);return{value:e,display:tr()(e).format("YYYY-MM-DD HH:mm")}}return{value:r.value,display:r.value}}return["toggle","checkbox"].includes(n)?{value:r.value?.uuid,display:r.value?.name?.name}:{value:r.value?.uuid,display:e.questionOptions.answers?.find(e=>e.concept===r.value?.uuid)?.label}};function ni(e){return!e.isHidden&&(e.sections?.some(e=>!e.isHidden&&e.questions?.some(e=>!e.isHidden))??!1)}function no(e,t){try{return{obsDatetime:e.effectiveDateTime,uuid:e.id,concept:{uuid:e.code.coding[0]?.code,display:e.code.coding[0]?.display},value:na(e,t)}}catch(e){return console.error("Error converting FHIR Obs to OpenMRS modelling",e),null}}function na(e,t){switch(t){case"toggle":return e.valueBoolean?{uuid:c.t$}:{uuid:c.Mi};case"date":case"datetime":return e.valueDateTime;case"number":return e.valueQuantity?.value??null;case"radio":case"checkbox":case"select":case"content-switcher":return e.valueCodeableConcept?.coding[0]?{uuid:e.valueCodeableConcept?.coding[0].code,name:{name:e.valueCodeableConcept?.coding[0].display}}:null;default:return e.valueString}}function nl(e,t){let n=e.pages.find(e=>t.meta.pageId===e.id);return n?.sections.find(e=>e.questions.find(e=>e.id===t.id))}var ns=n(8059);function nu(e,t){let{methods:{getValues:n}}=t,r=n();c.FU.includes(e.questionOptions.rendering)&&nc(e,r,t),nd(e,r,t)}function nc(e,t,n){let{sessionMode:r,formFields:i,patient:o,visit:a}=n;e.questionOptions.answers.forEach(n=>{let l=n.disable?.disableWhenExpression;l&&l.includes("myValue")&&(n.disable.isDisabled=t0(n.disable?.disableWhenExpression,{value:e,type:"field"},i,t,{mode:r,patient:o,visit:a}))})}function nd(e,t,n){let{sessionMode:r,formFields:i,patient:o,formFieldValidators:a,formJson:l,methods:{setValue:s},updateFormField:u,setForm:c,visit:d}=n,f=!1;e.fieldDependents&&e.fieldDependents.forEach(e=>{let c=i.find(t=>t.id==e);if(c){if(c.questionOptions.calculate?.calculateExpression&&t1(c.questionOptions.calculate.calculateExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d}).then(e=>{s(c.id,e);let{errors:a,warnings:l}=nf(c,e,n.formFieldValidators,{formFields:i,values:t,expressionContext:{patient:o,mode:r}});c.meta.submission||(c.meta.submission={}),c.meta.submission.errors=a,c.meta.submission.warnings=l,a.length||n.formFieldAdapters[c.type].transformFieldValue(c,e,n),u(c)}).catch(e=>{(0,ns.N)(e,"Error evaluating calculate expression")}),c.hide){let e=nl(l,c),n=e?.questions.some(e=>!e.isHidden);if(t8({value:c,type:"field"},i,t,r,o,t0,u),e){e.questions=e?.questions.map(e=>e.id===c.id?c:e);let t=c.isHidden,r=[...e.questions,c].some(e=>!e.isHidden);n||t?n&&!r&&(e.isHidden=!0,f=!0):(e.isHidden=!1,f=!0)}}if("object"==typeof c.disabled&&c.disabled.disableWhenExpression&&(c.isDisabled=t7({value:c,type:"field"},i,t,r,o,t0)),"object"==typeof c.required&&c.required?.type==="conditionalRequired"&&(c.isRequired=t9(c,i,t)),c.validators?.some(e=>"conditionalAnswered"===e.type)){let e=c.validators?.find(e=>"conditionalAnswered"===e.type),n=a.conditionalAnswered.validate(c,c.meta.submission?.newValue,{...e,expressionContext:{patient:o,mode:r},values:t,formFields:i});c.meta.submission={...c.meta.submission,errors:n}}c?.questionOptions.answers?.filter(e=>!ts(e.hide?.hideWhenExpression)).forEach(e=>{e.isHidden=t0(e.hide?.hideWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),c?.questionOptions.answers?.filter(e=>!ts(e.disable?.isDisabled)).forEach(e=>{e.disable.isDisabled=t0(e.disable?.disableWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),!c.isHidden&&c.meta.readonlyExpression&&(c.readonly=t0(c.meta.readonlyExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),tf(c,"repeating")&&!ts(c.questionOptions.repeatOptions?.limitExpression)&&(c.questionOptions.repeatOptions.limit=t0(c.questionOptions.repeatOptions?.limitExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),u(c)}}),e.sectionDependents&&e.sectionDependents.forEach(e=>{for(let n=0;n<l.pages.length;n++){let a=l.pages[n].sections.find(t=>t.label==e);if(a){t8({value:a,type:"section"},i,t,r,o,t0,u),f=!0;break}}}),e.pageDependents&&e.pageDependents?.forEach(e=>{t8({value:l.pages.find(t=>t.label==e),type:"page"},i,t,r,o,t0,u),f=!0}),f&&c(l)}function nf(e,t,n,r){let i=[],o=[];if(e.meta.submission?.unspecified)return{errors:[],warnings:[]};try{e.validators.forEach(a=>{let l=n[a.type]?.validate?.(e,t,{...a,...r});l&&l.forEach(e=>{"error"===e.resultType?i.push(e):"warning"===e.resultType&&o.push(e)})})}catch(e){console.error(e)}return{errors:i,warnings:o}}var np=n(1809);let nm=f().createContext(void 0),nh=({methods:e,children:t,...n})=>f().createElement(nm.Provider,{value:{...n,methods:e}},t),ng=()=>{let e=f().useContext(nm);if(!e)throw Error("FormProviderContext must be used within a FormProviderContext");return e},ny="-esm-form-engine__value__value___ltyQT",nv="-esm-form-engine__value__item___2GHPw",nb="-esm-form-engine__value__empty___hEe5L",n_=()=>{let{t:e}=(0,e9.useTranslation)();return f().createElement("div",null,f().createElement("span",{className:nb},"(",e("blank","Blank"),")"))},nw=({value:e})=>Array.isArray(e)?f().createElement(nx,{valueArray:e}):f().createElement("div",{className:ny},e),nx=({valueArray:e})=>f().createElement("ul",null,e.map(e=>f().createElement("li",{className:nv},e))),nE="-esm-form-engine__previous-value-review__formField___usT6m",nk="-esm-form-engine__previous-value-review__row___uDsJL",nS="-esm-form-engine__previous-value-review__value___ySFyl",nO="-esm-form-engine__previous-value-review__reuseButton___n4XbJ",nD=({previousValue:e,displayText:t,field:n,hideHeader:r,onAfterChange:i})=>{let{t:o}=(0,e9.useTranslation)(),{methods:{setValue:a}}=ng(),l=t=>{t.preventDefault(),a(n.id,e),i(e)};return f().createElement("div",{className:nE},f().createElement("div",{className:nk},!r&&f().createElement("div",null,o("previousValue","Previous value:")),f().createElement("div",{className:nS},f().createElement(nw,{value:t}))),f().createElement("div",{className:nO,role:"button",tabIndex:0,onClick:l},o("reuseValue","Reuse value")))},nC="-esm-form-engine__unspecified__unspecified___kJgif",nF=({field:e,fieldValue:t,setFieldValue:n,onAfterChange:r})=>{let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)(!1),{sessionMode:l,updateFormField:s}=ng();(0,d.useEffect)(()=>{ts(t)&&"edit"===l&&(a(!0),e.meta.submission||(e.meta.submission={}),e.meta.submission.unspecified=!0)},[]),(0,d.useEffect)(()=>{e.meta.submission?.unspecified&&(e.meta.submission.newValue||!ts(t))&&(e.meta.submission.unspecified=!1,s(e)),a(!!e.meta.submission?.unspecified)},[e.meta?.submission,e.meta.submission?.unspecified,t]);let u=(0,d.useCallback)(t=>{let i=e.questionOptions.rendering;if(t.target.checked){a(!0);let t="checkbox"===i?[]:"";tp(e),e.meta.submission.unspecified=!0,e.meta.submission.errors=[],e.meta.submission.warnings=[],s(e),n(t),r(t)}else a(!1),e.meta.submission.unspecified=!1,s(e)},[e.questionOptions.rendering]);return!e.isHidden&&!(0,np.H)(e.readonly)&&!tg(l)&&f().createElement("div",{className:nC},f().createElement(y.Checkbox,{id:`${e.id}-unspecified`,labelText:i("unspecified","Unspecified"),value:i("unspecified","Unspecified"),onChange:u,checked:o,disabled:e.isDisabled}))};function nA(e,t,n,r){return!("embedded-view"===e&&n&&(t||r))}let nP="-esm-form-engine__form-field-renderer__unspecifiedContainer___MoH57",nT=({fieldId:e,valueAdapter:t,repeatOptions:n})=>{let[r,i]=(0,d.useState)(null),[o,a]=(0,d.useState)([]),[l,s]=(0,d.useState)([]),[c,p]=(0,d.useState)(null),m=ng(),h=!1;try{let e=(0,u.useConfig)({externalModuleName:"@openmrs/esm-form-engine-app"});h=e?.hideUnansweredQuestionsInReadonlyForms??!1}catch(e){console.warn("Failed to load @openmrs/esm-form engine-app config - using hideUnansweredQuestionsInReadonlyForms=false (empty fields will be visible in readonly mode): ",e)}let{methods:{control:y,getValues:v,getFieldState:b},patient:_,sessionMode:w,formFields:x,formFieldValidators:E,addInvalidField:k,removeInvalidField:S,updateFormField:O}=m,D=(0,d.useRef)(null),C=ef({control:y,name:e,exact:!0}),F=()=>{},A=(0,d.useMemo)(()=>x.find(t=>t.id===e),[e,x]);(0,d.useEffect)(()=>{if(tf(A,"repeating")&&n?.targetRendering?dk(n.targetRendering).then(e=>{e&&i({value:e})}):dS(A).then(e=>{e&&i({value:e})}),"enter"===w&&(A.historicalExpression||m.previousDomainObjectValue))try{m.processor.getHistoricalValue(A,m).then(e=>{p(e)})}catch(e){console.error(e)}},[]),(0,d.useEffect)(()=>{let{isDirty:e,isTouched:n}=b(A.id),{submission:r,unspecified:i}=A.meta,{calculate:o,defaultValue:a}=A.questionOptions;!ts(C)&&!r?.newValue&&!e&&!i&&(o?.calculateExpression||a)&&t.transformFieldValue(A,C,m);let l=D.current;D.current=null,(e||n)&&(!l||!(0,g.A)(l.value,C))&&P(C)},[C]),(0,d.useEffect)(()=>{A.meta.submission?.errors&&a(A.meta.submission.errors),A.meta.submission?.warnings&&s(A.meta.submission.warnings),A.meta.submission?.unspecified&&(a([]),S(A.id))},[A.meta.submission]);let P=e=>{A.meta.submission?.unspecified&&!ts(e)&&(A.meta.submission.unspecified=!1);let{errors:n,warnings:r}=nf(A,e,E,{formFields:x,values:v(),expressionContext:{patient:_,mode:w}});if(A.meta.submission&&(A.meta.submission.errors=void 0,A.meta.submission.warnings=void 0),o.length&&!n.length?(S(A.id),a([])):n.length&&(a(n),k(A)),n.length||t.transformFieldValue(A,e,m),s(r),nu(A,m),A.meta.groupId){let e=x.find(e=>e.id===A.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===A.id?A:e),O(e))}},T=e=>{D.current={value:e},P(e)};if(!r)return null;let V=r.value;return!n?.targetRendering&&nj(A.questionOptions.rendering)?f().createElement(V,{key:A.id,field:A,value:null,errors:o,warnings:l,setFieldValue:null}):nA(w,!!A.questionOptions.isTransient,ts(C),h)?f().createElement(te,{FallbackComponent:nV,onReset:F},f().createElement(em,{control:y,name:A.id,render:({field:{value:e,onChange:t,onBlur:n}})=>f().createElement("div",null,f().createElement(V,{key:`${A.id}-input-component`,field:A,value:e,errors:o,warnings:l,setFieldValue:e=>{t(e),T(e),n()}}),nM(A)&&f().createElement("div",{className:nP},A.unspecified&&f().createElement(nF,{key:`${A.id}-unspecified`,field:A,setFieldValue:t,onAfterChange:T,fieldValue:e})),c?.value&&f().createElement("div",null,f().createElement(nD,{key:`${A.id}-previous-value-review`,previousValue:c.value,displayText:c.display,onAfterChange:T,field:A})))})):null};function nV({error:e}){let{t}=(0,e9.useTranslation)();return f().createElement(y.ToastNotification,{"aria-label":t("closesNotification","Closes notification"),caption:"",hideCloseButton:!0,lowContrast:!0,onClose:function(){},onCloseButtonClick:function(){},statusIconDescription:t("notification","Notification"),subtitle:e.message,title:t("errorRenderingField","Error rendering field")})}function nM(e){let{rendering:t}=e.questionOptions;return(0,np.H)(e.unspecified)&&"toggle"!=t&&"group"!=t&&"repeating"!=t&&"markdown"!=t&&"extension-widget"!=t&&"workspace-launcher"!=t}function nj(e){return"group"===e||"repeating"===e}let nI=({field:e,...t})=>{let{t:n}=(0,e9.useTranslation)(),{formFieldAdapters:r,formFields:i}=ng(),o=(0,d.useMemo)(()=>e.questions.map(e=>i.find(t=>t.id===e.id)).filter(e=>!e.isHidden).map((n,i)=>{let o=`${n.id}_${i}`;return n.id===e.id?f().createElement(nV,{error:Error("ObsGroup child has same id as parent question")}):"obsGroup"===n.type&&nj(n.questionOptions.rendering)?f().createElement("div",{key:o,className:h.nestedGroupContainer},f().createElement(nI,{field:n,...t})):r[n.type]?f().createElement("div",{className:m()(h.flexColumn),key:o},f().createElement("div",{className:h.groupContainer},f().createElement(nT,{fieldId:n.id,valueAdapter:r[n.type]}))):void 0}),[e,i]);return f().createElement("div",{className:h.groupContainer},o.length>1?f().createElement(y.FormGroup,{legendText:n(e.label),className:h.boldLegend},o):o)},nN=nI,nL="-esm-form-engine__label__label___d9pB3",nq=({value:e,tooltipText:t})=>f().createElement("div",{className:nL},f().createElement(y.DefinitionTooltip,{autoAlign:!0,tabIndex:0,definition:t??""},f().createElement("span",{className:"cds--label"},`${e}:`))),nR="-esm-form-engine__field-value-view__formField___aiANn",n$="-esm-form-engine__field-value-view__readonly___4EhBN",nB="-esm-form-engine__field-value-view__value___cgPr1",nH="-esm-form-engine__field-value-view__inlineFlexRow___Rk2F-",nz="-esm-form-engine__field-value-view__inlineFlexColumn___Yd9Fp",nU=({label:e,conceptName:t,value:n,isInline:r})=>f().createElement(f().Fragment,null,r?f().createElement("div",{className:nH},f().createElement("div",{className:nz},f().createElement(nq,{value:e,tooltipText:t})),f().createElement("div",{className:nz},ts(n)?f().createElement(n_,null):f().createElement(nw,{value:n}))):f().createElement("div",{className:n$},f().createElement("div",{className:nR},f().createElement(nq,{value:e,tooltipText:t}),f().createElement("div",{className:nB},ts(n)?f().createElement(n_,null):f().createElement(nw,{value:n}))))),nW="-esm-form-engine__content-switcher__formField___vZnsA",nY="-esm-form-engine__content-switcher__errorLegend___JGh37",nJ="-esm-form-engine__content-switcher__boldedLegend___DEeyj",nZ="-esm-form-engine__content-switcher__selectedOption___KMGst";var nG=n(4807);let nQ="-esm-form-engine__field-label__required___QIc-5",nK="-esm-form-engine__field-label__questionLabel___mFOqM",nX="-esm-form-engine__field-label__tooltipIcon___vCSZl",n0=({field:e,children:t})=>{let{t:n}=(0,e9.useTranslation)();return e.questionInfo?f().createElement(y.Tooltip,{autoAlign:!0,label:n(e.questionInfo)},f().createElement("div",null,t)):f().createElement(f().Fragment,null,t)},n1=({field:e,customLabel:t})=>{let{t:n}=(0,e9.useTranslation)(),r=!!e.questionInfo,i=t||n(e.label);return f().createElement(n0,{field:e},f().createElement("div",{className:nK,"data-testid":`${e.id}-label`},f().createElement("span",null,i),e.isRequired&&f().createElement("span",{title:n("required","Required"),className:nQ},"*"),r&&f().createElement(nG.$$,{size:16,"aria-hidden":"true",className:nX,"data-testid":`${e.id}-information-icon`})))},n2=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),c=(0,d.useCallback)(e=>{i(e.name)},[i]),p=(0,d.useMemo)(()=>e.questionOptions.answers.filter(e=>!e.isHidden),[e.questionOptions.answers]),h=(0,d.useMemo)(()=>p.findIndex(e=>e.concept==t),[t,p]),g=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,np.H)(e.readonly)?f().createElement("div",{className:nW},f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:g})):!e.isHidden&&f().createElement(y.FormGroup,{legendText:f().createElement("div",{className:nJ},f().createElement(n1,{field:e})),className:m()({[nY]:n.length>0,[nJ]:0===n.length})},f().createElement(y.ContentSwitcher,{onChange:c,selectedIndex:h,className:nZ,size:"md"},p.map((t,n)=>f().createElement(y.Switch,{name:t.concept||t.value,text:o(t.label),key:n,disabled:e.isDisabled}))))},n4="-esm-form-engine__date__datePickerWarn___GDUCO",n5="-esm-form-engine__date__datePickerLabel___gCHIg",n3="-esm-form-engine__date__boldedLabel___cGCdn",n6="-esm-form-engine__date__datetime___z+i2e",n9="-esm-form-engine__date__datePickerSpacing___Lprw3",n7="-esm-form-engine__date__timeInput___E1vhw",n8=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),[a,l]=(0,d.useState)(""),{layoutType:s,sessionMode:c,workspaceLayout:p}=ng(),h=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(c)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,s,p,c),[c,e.readonly,e.inlineRendering,s,p]),g=(0,d.useCallback)(e=>{v(e,a),i(e)},[i,a]),v=(0,d.useCallback)((e,t)=>{if(!ts(t)){let[n,r]=t.split(":").map(Number);e.setHours(n??0,r??0)}},[]),b=(0,d.useCallback)(n=>{let r=n.target.value;l(r);let o="timer"===e.datePickerFormat?new Date:new Date(t);v(o,r),i(o)},[i,v,t]);(0,d.useEffect)(()=>{t&&t instanceof Date&&l([10>t.getHours()?`0${t.getHours()}`:`${t.getHours()}`,10>t.getMinutes()?`0${t.getMinutes()}`:`${t.getMinutes()}`].join(":"))},[t]);let _=(0,d.useMemo)(()=>"timer"===e.datePickerFormat?f().createElement(n1,{field:e}):f().createElement(n1,{field:e,customLabel:o("time","Time")}),[e.datePickerFormat,e.label,o]);return"view"==c||"embedded-view"==c||(0,np.H)(e.readonly)?f().createElement(nU,{label:o(e.label),value:t instanceof Date?tb(e,t):t,conceptName:e.meta?.concept?.display,isInline:h}):!e.isHidden&&f().createElement("div",{className:n6},("calendar"===e.datePickerFormat||"both"===e.datePickerFormat)&&f().createElement("div",{className:n9},f().createElement(y.Layer,null,f().createElement(u.OpenmrsDatePicker,{id:e.id,onChange:g,labelText:f().createElement("span",{className:n5},f().createElement(n1,{field:e})),isDisabled:e.isDisabled,isReadOnly:(0,np.H)(e.readonly),isRequired:e.isRequired??!1,isInvalid:n.length>0,invalidText:n[0]?.message,value:t})),r.length>0?f().createElement("div",{className:n4},r[0]?.message):null),"both"===e.datePickerFormat||"timer"===e.datePickerFormat?f().createElement("div",null,f().createElement(y.Layer,null,f().createElement(y.TimePicker,{className:m()(n3,n7),id:e.id,labelText:_,placeholder:"HH:MM",pattern:"(1[012]|[1-9]):[0-5][0-9]$",type:"time",disabled:"timer"===e.datePickerFormat?e.isDisabled:!t,invalid:n.length>0,invalidText:n[0]?.message,readOnly:(0,np.H)(e.readonly),warning:r.length>0,warningText:r[0]?.message,value:a||(t instanceof Date?t.toLocaleDateString(window.navigator.language):t),onChange:b}))):null)},re=({field:e,setFieldValue:t})=>{let n=ng();return(0,d.useEffect)(()=>{e.meta?.initialValue?.omrsObject||ts(e.meta.fixedValue)||(t(e.meta.fixedValue),n.formFieldAdapters[e.type].transformFieldValue(e,e.meta.fixedValue,n))},[]),f().createElement(f().Fragment,null)};function rt(e,t){let n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}let rn=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rr=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ri={};function ro(e,t){return((t||ri).jsx?rr:rn).test(e)}let ra=/[ \t\n\f\r]/g;function rl(e){return"object"==typeof e?"text"===e.type&&rs(e.value):rs(e)}function rs(e){return""===e.replace(ra,"")}class ru{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function rc(e,t){let n={},r={},i=-1;for(;++i<e.length;)Object.assign(n,e[i].property),Object.assign(r,e[i].normal);return new ru(n,r,t)}function rd(e){return e.toLowerCase()}ru.prototype.property={},ru.prototype.normal={},ru.prototype.space=null;class rf{constructor(e,t){this.property=e,this.attribute=t}}rf.prototype.space=null,rf.prototype.boolean=!1,rf.prototype.booleanish=!1,rf.prototype.overloadedBoolean=!1,rf.prototype.number=!1,rf.prototype.commaSeparated=!1,rf.prototype.spaceSeparated=!1,rf.prototype.commaOrSpaceSeparated=!1,rf.prototype.mustUseProperty=!1,rf.prototype.defined=!1;let rp=0,rm=rw(),rh=rw(),rg=rw(),ry=rw(),rv=rw(),rb=rw(),r_=rw();function rw(){return 2**++rp}let rx=Object.keys(i);class rE extends rf{constructor(e,t,n,r){let o=-1;if(super(e,t),rk(this,"space",r),"number"==typeof n)for(;++o<rx.length;){const e=rx[o];rk(this,rx[o],(n&i[e])===i[e])}}}function rk(e,t,n){n&&(e[t]=n)}rE.prototype.defined=!0;let rS={}.hasOwnProperty;function rO(e){let t,n={},r={};for(t in e.properties)if(rS.call(e.properties,t)){let i=e.properties[t],o=new rE(t,e.transform(e.attributes||{},t),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(t)&&(o.mustUseProperty=!0),n[t]=o,r[rd(t)]=t,r[rd(o.attribute)]=t}return new ru(n,r,e.space)}let rD=rO({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),rC=rO({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function rF(e,t){return t in e?e[t]:t}function rA(e,t){return rF(e,t.toLowerCase())}let rP=rO({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:rA,properties:{xmlns:null,xmlnsXLink:null}}),rT=rO({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:rh,ariaAutoComplete:null,ariaBusy:rh,ariaChecked:rh,ariaColCount:ry,ariaColIndex:ry,ariaColSpan:ry,ariaControls:rv,ariaCurrent:null,ariaDescribedBy:rv,ariaDetails:null,ariaDisabled:rh,ariaDropEffect:rv,ariaErrorMessage:null,ariaExpanded:rh,ariaFlowTo:rv,ariaGrabbed:rh,ariaHasPopup:null,ariaHidden:rh,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rv,ariaLevel:ry,ariaLive:null,ariaModal:rh,ariaMultiLine:rh,ariaMultiSelectable:rh,ariaOrientation:null,ariaOwns:rv,ariaPlaceholder:null,ariaPosInSet:ry,ariaPressed:rh,ariaReadOnly:rh,ariaRelevant:null,ariaRequired:rh,ariaRoleDescription:rv,ariaRowCount:ry,ariaRowIndex:ry,ariaRowSpan:ry,ariaSelected:rh,ariaSetSize:ry,ariaSort:null,ariaValueMax:ry,ariaValueMin:ry,ariaValueNow:ry,ariaValueText:null,role:null}}),rV=rO({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:rA,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:rb,acceptCharset:rv,accessKey:rv,action:null,allow:null,allowFullScreen:rm,allowPaymentRequest:rm,allowUserMedia:rm,alt:null,as:null,async:rm,autoCapitalize:null,autoComplete:rv,autoFocus:rm,autoPlay:rm,capture:rm,charSet:null,checked:rm,cite:null,className:rv,cols:ry,colSpan:null,content:null,contentEditable:rh,controls:rm,controlsList:rv,coords:ry|rb,crossOrigin:null,data:null,dateTime:null,decoding:null,default:rm,defer:rm,dir:null,dirName:null,disabled:rm,download:rg,draggable:rh,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:rm,formTarget:null,headers:rv,height:ry,hidden:rm,high:ry,href:null,hrefLang:null,htmlFor:rv,httpEquiv:rv,id:null,imageSizes:null,imageSrcSet:null,inputMode:null,integrity:null,is:null,isMap:rm,itemId:null,itemProp:rv,itemRef:rv,itemScope:rm,itemType:rv,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:rm,low:ry,manifest:null,max:null,maxLength:ry,media:null,method:null,min:null,minLength:ry,multiple:rm,muted:rm,name:null,nonce:null,noModule:rm,noValidate:rm,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:rm,optimum:ry,pattern:null,ping:rv,placeholder:null,playsInline:rm,poster:null,preload:null,readOnly:rm,referrerPolicy:null,rel:rv,required:rm,reversed:rm,rows:ry,rowSpan:ry,sandbox:rv,scope:null,scoped:rm,seamless:rm,selected:rm,shape:null,size:ry,sizes:null,slot:null,span:ry,spellCheck:rh,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ry,step:null,style:null,tabIndex:ry,target:null,title:null,translate:null,type:null,typeMustMatch:rm,useMap:null,value:rh,width:ry,wrap:null,align:null,aLink:null,archive:rv,axis:null,background:null,bgColor:null,border:ry,borderColor:null,bottomMargin:ry,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:rm,declare:rm,event:null,face:null,frame:null,frameBorder:null,hSpace:ry,leftMargin:ry,link:null,longDesc:null,lowSrc:null,marginHeight:ry,marginWidth:ry,noResize:rm,noHref:rm,noShade:rm,noWrap:rm,object:null,profile:null,prompt:null,rev:null,rightMargin:ry,rules:null,scheme:null,scrolling:rh,standby:null,summary:null,text:null,topMargin:ry,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ry,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:rm,disableRemotePlayback:rm,prefix:null,property:null,results:ry,security:null,unselectable:null}}),rM=rO({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:rF,properties:{about:r_,accentHeight:ry,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ry,amplitude:ry,arabicForm:null,ascent:ry,attributeName:null,attributeType:null,azimuth:ry,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ry,by:null,calcMode:null,capHeight:ry,className:rv,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ry,diffuseConstant:ry,direction:null,display:null,dur:null,divisor:ry,dominantBaseline:null,download:rm,dx:null,dy:null,edgeMode:null,editable:null,elevation:ry,enableBackground:null,end:null,event:null,exponent:ry,externalResourcesRequired:null,fill:null,fillOpacity:ry,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:rb,g2:rb,glyphName:rb,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ry,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ry,horizOriginX:ry,horizOriginY:ry,id:null,ideographic:ry,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ry,k:ry,k1:ry,k2:ry,k3:ry,k4:ry,kernelMatrix:r_,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ry,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ry,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ry,overlineThickness:ry,paintOrder:null,panose1:null,path:null,pathLength:ry,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rv,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ry,pointsAtY:ry,pointsAtZ:ry,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:r_,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:r_,rev:r_,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:r_,requiredFeatures:r_,requiredFonts:r_,requiredFormats:r_,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ry,specularExponent:ry,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ry,strikethroughThickness:ry,string:null,stroke:null,strokeDashArray:r_,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ry,strokeOpacity:ry,strokeWidth:null,style:null,surfaceScale:ry,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:r_,tabIndex:ry,tableValues:null,target:null,targetX:ry,targetY:ry,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:r_,to:null,transform:null,u1:null,u2:null,underlinePosition:ry,underlineThickness:ry,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ry,values:null,vAlphabetic:ry,vMathematical:ry,vectorEffect:null,vHanging:ry,vIdeographic:ry,version:null,vertAdvY:ry,vertOriginX:ry,vertOriginY:ry,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ry,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),rj=rc([rC,rD,rP,rT,rV],"html"),rI=rc([rC,rD,rP,rT,rM],"svg"),rN=/^data[-\w.:]+$/i,rL=/-[a-z]/g,rq=/[A-Z]/g;function rR(e,t){let n=rd(t),r=t,i=rf;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&rN.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(rL,rB);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!rL.test(e)){let n=e.replace(rq,r$);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=rE}return new i(r,t)}function r$(e){return"-"+e.toLowerCase()}function rB(e){return e.charAt(1).toUpperCase()}let rH={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};function rz(e){return e.join(" ").trim()}var rU=n(8052);let rW=rU.default||rU,rY=rZ("end"),rJ=rZ("start");function rZ(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function rG(e){let t=rJ(e),n=rY(e);if(t&&n)return{start:t,end:n}}function rQ(e){return e&&"object"==typeof e?"position"in e||"type"in e?rX(e.position):"start"in e||"end"in e?rX(e):"line"in e||"column"in e?rK(e):"":""}function rK(e){return r0(e&&e.line)+":"+r0(e&&e.column)}function rX(e){return rK(e&&e.start)+"-"+rK(e&&e.end)}function r0(e){return e&&"number"==typeof e?e:1}class r1 extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=rQ(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual,this.expected,this.note,this.url}}r1.prototype.file="",r1.prototype.name="",r1.prototype.reason="",r1.prototype.message="",r1.prototype.stack="",r1.prototype.column=void 0,r1.prototype.line=void 0,r1.prototype.ancestors=void 0,r1.prototype.cause=void 0,r1.prototype.fatal=void 0,r1.prototype.place=void 0,r1.prototype.ruleId=void 0,r1.prototype.source=void 0;let r2={}.hasOwnProperty,r4=new Map,r5=/[A-Z]/g,r3=/-([a-z])/g,r6=new Set(["table","tbody","thead","tfoot","tr"]),r9=new Set(["td","th"]),r7="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function r8(e,t){let n;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let r=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=id(r,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");n=ic(r,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?rI:rj,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},o=ie(i,e,void 0);return o&&"string"!=typeof o?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function ie(e,t,n){return"element"===t.type?it(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?ir(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?io(e,t,n):"mdxjsEsm"===t.type?ii(e,t):"root"===t.type?ia(e,t,n):"text"===t.type?il(e,t):void 0}function it(e,t,n){let r=e.schema;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(e.schema=rI),e.ancestors.push(t);let i=iv(e,t.tagName,!1),o=ip(e,t),a=ih(e,t);return r6.has(t.tagName)&&(a=a.filter(function(e){return"string"!=typeof e||!rl(e)})),is(e,o,i,t),iu(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function ir(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ib(e,t.position)}function ii(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ib(e,t.position)}function io(e,t,n){let r=e.schema;"svg"===t.name&&"html"===r.space&&(e.schema=rI),e.ancestors.push(t);let i=null===t.name?e.Fragment:iv(e,t.name,!0),o=im(e,t),a=ih(e,t);return is(e,o,i,t),iu(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function ia(e,t,n){let r={};return iu(r,ih(e,t)),e.create(t,e.Fragment,r,n)}function il(e,t){return t.value}function is(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function iu(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function ic(e,t,n){return r;function r(e,r,i,o){let a=Array.isArray(i.children)?n:t;return o?a(r,i,o):a(r,i)}}function id(e,t){return n;function n(n,r,i,o){let a=Array.isArray(i.children),l=rJ(n);return t(r,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function ip(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&r2.call(t.properties,r)){let o=ig(e,r,t.properties[r]);if(o){let[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&r9.has(t.tagName)?n=a:i[r]=a}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}function im(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let o=i.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else ib(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,i=e.evaluater.evaluateExpression(t.expression)}else ib(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}function ih(e,t){let n=[],r=-1,i=e.passKeys?new Map:r4;for(;++r<t.children.length;){let o,a=t.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let l=ie(e,a,o);void 0!==l&&n.push(l)}return n}function ig(e,t,n){let r=rR(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?rt(n):rz(n)),"style"===r.property){let t="object"==typeof n?n:iy(e,String(n));return"css"===e.stylePropertyNameCase&&(t=i_(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?rH[r.property]||r.property:r.attribute,n]}}function iy(e,t){let n={};try{rW(t,r)}catch(t){if(!e.ignoreInvalidStyle){let n=t,r=new r1("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=r7+"#cannot-parse-style-attribute",r}}return n;function r(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(r3,ix)),n[r]=t}}function iv(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=ro(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}r=e}else r=ro(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return r2.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ib(e)}function ib(e,t){let n=new r1("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=r7+"#cannot-handle-mdx-estrees-without-createevaluater",n}function i_(e){let t,n={};for(t in e)r2.call(e,t)&&(n[iw(t)]=e[t]);return n}function iw(e){let t=e.replace(r5,iE);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function ix(e,t){return t.toUpperCase()}function iE(e){return"-"+e.toLowerCase()}let ik={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};var iS=n(1085);let iO={};function iD(e,t){let n=t||iO;return iC(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function iC(e,t,n){if(iA(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return iF(e.children,t,n)}return Array.isArray(e)?iF(e,t,n):""}function iF(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=iC(e[i],t,n);return r.join("")}function iA(e){return!!(e&&"object"==typeof e)}function iP(e,t,n,r){let i,o=e.length,a=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function iT(e,t){return e.length>0?(iP(e,e.length,0,t),e):t}class iV{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&iM(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),iM(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),iM(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);iM(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);iM(this.left,t.reverse())}}}function iM(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ij(e){let t,n,r,i,o,a,l,s={},u=-1,c=new iV(e);for(;++u<c.length;){for(;u in s;)u=s[u];if(t=c.get(u),u&&"chunkFlow"===t[1].type&&"listItemPrefix"===c.get(u-1)[1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(s,iI(c,u)),u=s[u],l=!0);else if(t[1]._container){for(r=u,n=void 0;r--;)if("lineEnding"===(i=c.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(c.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else break;n&&(t[1].end={...c.get(n)[1].start},(o=c.slice(n,u)).unshift(t),c.splice(n,u-n+1,o))}}return iP(e,0,1/0,c.slice(0)),!l}function iI(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],a=t-1,l=[],s=i._tokenizer||o.parser[i.contentType](i.start),u=s.events,c=[],d={},f=-1,p=i,m=0,h=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(n),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++f<u.length;)"exit"===u[f][0]&&"enter"===u[f-1][0]&&u[f][1].type===u[f-1][1].type&&u[f][1].start.line!==u[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=u.slice(g[f],g[f+1]),n=l.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)d[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return d}function iN(e){for(;!ij(e););return e}let iL={}.hasOwnProperty;function iq(e){let t={},n=-1;for(;++n<e.length;)iR(t,e[n]);return t}function iR(e,t){let n;for(n in t){let r,i=(iL.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){iL.call(i,r)||(i[r]=[]);let e=o[r];i$(i[r],Array.isArray(e)?e:e?[e]:[])}}}function i$(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);iP(e,0,0,r)}let iB=i0(/[A-Za-z]/),iH=i0(/[\dA-Za-z]/),iz=i0(/[#-'*+\--9=?A-Z^-~]/);function iU(e){return null!==e&&(e<32||127===e)}let iW=i0(/\d/),iY=i0(/[\dA-Fa-f]/),iJ=i0(/[!-/:-@[-`{-~]/);function iZ(e){return null!==e&&e<-2}function iG(e){return null!==e&&(e<0||32===e)}function iQ(e){return -2===e||-1===e||32===e}let iK=i0(/\p{P}|\p{S}/u),iX=i0(/\s/);function i0(e){return t;function t(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function i1(e,t,n,r){let i=r?r-1:1/0,o=0;return a;function a(r){return iQ(r)?(e.enter(n),l(r)):t(r)}function l(r){return iQ(r)&&o++<i?(e.consume(r),l):(e.exit(n),t(r))}}let i2={tokenize:i4};function i4(e){let t,n=e.attempt(this.parser.constructs.contentInitial,r,i);return n;function r(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,n,"linePrefix"))}function i(t){return e.enter("paragraph"),o(t)}function o(n){let r=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=r),t=r,a(n)}function a(t){if(null===t){e.exit("chunkText"),e.exit("paragraph"),e.consume(t);return}return iZ(t)?(e.consume(t),e.exit("chunkText"),o):(e.consume(t),a)}}let i5={tokenize:i6},i3={tokenize:i9};function i6(e){let t,n,r,i=this,o=[],a=0;return l;function l(t){if(a<o.length){let n=o[a];return i.containerState=n[1],e.attempt(n[0].continuation,s,u)(t)}return u(t)}function s(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&v();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}y(a);let l=r;for(;l<i.events.length;)i.events[l][1].end={...n},l++;return iP(i.events,o+1,0,i.events.slice(r)),i.events.length=l,u(e)}return l(e)}function u(n){if(a===o.length){if(!t)return f(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(i3,c,d)(n)}function c(e){return t&&v(),y(a),f(e)}function d(e){return i.parser.lazy[i.now().line]=a!==o.length,r=i.now().offset,m(e)}function f(t){return i.containerState={},e.attempt(i3,p,m)(t)}function p(e){return a++,o.push([i.currentConstruct,i.containerState]),f(e)}function m(r){if(null===r){t&&v(),y(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),h(r)}function h(t){if(null===t){g(e.exit("chunkFlow"),!0),y(0),e.consume(t);return}return iZ(t)?(e.consume(t),g(e.exit("chunkFlow")),a=0,i.interrupt=void 0,l):(e.consume(t),h)}function g(e,o){let l=i.sliceStream(e);if(o&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let l=i.events.length,s=l;for(;s--;)if("exit"===i.events[s][0]&&"chunkFlow"===i.events[s][1].type){if(e){n=i.events[s][1].end;break}e=!0}for(y(a),o=l;o<i.events.length;)i.events[o][1].end={...n},o++;iP(i.events,s+1,0,i.events.slice(l)),i.events.length=o}}function y(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function v(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}function i9(e,t,n){return i1(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}let i7={partial:!0,tokenize:i8};function i8(e,t,n){return r;function r(t){return iQ(t)?i1(e,i,"linePrefix")(t):i(t)}function i(e){return null===e||iZ(e)?t(e):n(e)}}let oe={resolve:on,tokenize:or},ot={partial:!0,tokenize:oi};function on(e){return ij(e),e}function or(e,t){let n;return r;function r(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(t)}function i(t){return null===t?o(t):iZ(t)?e.check(ot,a,o)(t):(e.consume(t),i)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function oi(e,t,n){let r=this;return i;function i(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,o,"linePrefix")}function o(i){if(null===i||iZ(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}let oo={tokenize:oa};function oa(e){let t=this,n=e.attempt(i7,r,e.attempt(this.parser.constructs.flowInitial,i,i1(e,e.attempt(this.parser.constructs.flow,i,e.attempt(oe,i)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)}function i(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}let ol={resolveAll:od()},os=oc("string"),ou=oc("text");function oc(e){return{resolveAll:od("text"===e?of:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,a);return o;function o(e){return s(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return s(e)?(t.exit("data"),i(e)):(t.consume(e),l)}function s(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function od(e){return t;function t(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function of(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),a=o.length,l=-1,s=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)s++,l--;if(l)break;l=-1}else if(-2===e)r=!0,s++;else if(-1===e);else{a++;break}}if(s){let o={type:n===e.length||r||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:i.start._bufferIndex+l,_index:i.start._index+a,line:i.end.line,column:i.end.column-s,offset:i.end.offset-s},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}let op={name:"thematicBreak",tokenize:om};function om(e,t,n){let r,i=0;return o;function o(t){return e.enter("thematicBreak"),a(t)}function a(e){return r=e,l(e)}function l(o){return o===r?(e.enter("thematicBreakSequence"),s(o)):i>=3&&(null===o||iZ(o))?(e.exit("thematicBreak"),t(o)):n(o)}function s(t){return t===r?(e.consume(t),i++,s):(e.exit("thematicBreakSequence"),iQ(t)?i1(e,l,"whitespace")(t):l(t))}}let oh={continuation:{tokenize:ob},exit:ow,name:"list",tokenize:ov},og={partial:!0,tokenize:ox},oy={partial:!0,tokenize:o_};function ov(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:iW(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(op,n,u)(t):u(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(t)}return n(t)}function s(t){return iW(t)&&++a<10?(e.consume(t),s):(!r.interrupt||a<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),u(t)):n(t)}function u(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(i7,r.interrupt?n:c,e.attempt(og,f,d))}function c(e){return r.containerState.initialBlankLine=!0,o++,f(e)}function d(t){return iQ(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),f):n(t)}function f(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}function ob(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(i7,i,o);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,i1(e,t,"listItemIndent",r.containerState.size+1)(n)}function o(n){return r.containerState.furtherBlankLines||!iQ(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(oy,t,a)(n))}function a(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,i1(e,e.attempt(oh,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}function o_(e,t,n){let r=this;return i1(e,i,"listItemIndent",r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function ow(e){e.exit(this.containerState.type)}function ox(e,t,n){let r=this;return i1(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(e){let i=r.events[r.events.length-1];return!iQ(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)}}let oE={continuation:{tokenize:oS},exit:oO,name:"blockQuote",tokenize:ok};function ok(e,t,n){let r=this;return i;function i(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)}function o(n){return iQ(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}function oS(e,t,n){let r=this;return i;function i(t){return iQ(t)?i1(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)}function o(r){return e.attempt(oE,t,n)(r)}}function oO(e){e.exit("blockQuote")}function oD(e,t,n,r,i,o,a,l,s){let u=s||1/0,c=0;return d;function d(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),f):null===t||32===t||41===t||iU(t)?n(t):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),h(t))}function f(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(l),f(t)):null===t||60===t||iZ(t)?n(t):(e.consume(t),92===t?m:p)}function m(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function h(i){return!c&&(null===i||41===i||iG(i))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(i)):c<u&&40===i?(e.consume(i),c++,h):41===i?(e.consume(i),c--,h):null===i||32===i||40===i||iU(i)?n(i):(e.consume(i),92===i?g:h)}function g(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function oC(e,t,n,r,i,o){let a,l=this,s=0;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),c}function c(u){return s>999||null===u||91===u||93===u&&!a||94===u&&!s&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(o),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):iZ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||iZ(t)||s++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!iQ(t)),92===t?f:d)}function f(t){return 91===t||92===t||93===t?(e.consume(t),s++,d):d(t)}}function oF(e,t,n,r,i,o){let a;return l;function l(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,s):n(t)}function s(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),u(n))}function u(t){return t===a?(e.exit(o),s(a)):null===t?n(t):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i1(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===a||null===t||iZ(t)?(e.exit("chunkString"),u(t)):(e.consume(t),92===t?d:c)}function d(t){return t===a||92===t?(e.consume(t),c):c(t)}}function oA(e,t){let n;return r;function r(i){return iZ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):iQ(i)?i1(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function oP(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let oT={name:"definition",tokenize:oM},oV={partial:!0,tokenize:oj};function oM(e,t,n){let r,i=this;return o;function o(t){return e.enter("definition"),a(t)}function a(t){return oC.call(i,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}function l(t){return(r=oP(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return iG(t)?oA(e,u)(t):u(t)}function u(t){return oD(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function c(t){return e.attempt(oV,d,d)(t)}function d(t){return iQ(t)?i1(e,f,"whitespace")(t):f(t)}function f(o){return null===o||iZ(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}function oj(e,t,n){return r;function r(t){return iG(t)?oA(e,i)(t):n(t)}function i(t){return oF(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return iQ(t)?i1(e,a,"whitespace")(t):a(t)}function a(e){return null===e||iZ(e)?t(e):n(e)}}let oI={name:"codeIndented",tokenize:oL},oN={partial:!0,tokenize:oq};function oL(e,t,n){let r=this;return i;function i(t){return e.enter("codeIndented"),i1(e,o,"linePrefix",5)(t)}function o(e){let t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?a(e):n(e)}function a(t){return null===t?s(t):iZ(t)?e.attempt(oN,a,s)(t):(e.enter("codeFlowValue"),l(t))}function l(t){return null===t||iZ(t)?(e.exit("codeFlowValue"),a(t)):(e.consume(t),l)}function s(n){return e.exit("codeIndented"),t(n)}}function oq(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):i1(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):iZ(e)?i(e):n(e)}}let oR={name:"headingAtx",resolve:o$,tokenize:oB};function o$(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},iP(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e}function oB(e,t,n){let r=0;return i;function i(t){return e.enter("atxHeading"),o(t)}function o(t){return e.enter("atxHeadingSequence"),a(t)}function a(t){return 35===t&&r++<6?(e.consume(t),a):null===t||iG(t)?(e.exit("atxHeadingSequence"),l(t)):n(t)}function l(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||iZ(n)?(e.exit("atxHeading"),t(n)):iQ(n)?i1(e,l,"whitespace")(n):(e.enter("atxHeadingText"),u(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),l(t))}function u(t){return null===t||35===t||iG(t)?(e.exit("atxHeadingText"),l(t)):(e.consume(t),u)}}let oH={name:"setextUnderline",resolveTo:oz,tokenize:oU};function oz(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=a,e.push(["exit",a,t]),e}function oU(e,t,n){let r,i=this;return o;function o(t){let o,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){o="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||o)?(e.enter("setextHeadingLine"),r=t,a(t)):n(t)}function a(t){return e.enter("setextHeadingLineSequence"),l(t)}function l(t){return t===r?(e.consume(t),l):(e.exit("setextHeadingLineSequence"),iQ(t)?i1(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||iZ(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}let oW=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],oY=["pre","script","style","textarea"],oJ={concrete:!0,name:"htmlFlow",resolveTo:oQ,tokenize:oK},oZ={partial:!0,tokenize:o0},oG={partial:!0,tokenize:oX};function oQ(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oK(e,t,n){let r,i,o,a,l,s=this;return u;function u(e){return c(e)}function c(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),d}function d(a){return 33===a?(e.consume(a),f):47===a?(e.consume(a),i=!0,h):63===a?(e.consume(a),r=3,s.interrupt?t:I):iB(a)?(e.consume(a),o=String.fromCharCode(a),g):n(a)}function f(i){return 45===i?(e.consume(i),r=2,p):91===i?(e.consume(i),r=5,a=0,m):iB(i)?(e.consume(i),r=4,s.interrupt?t:I):n(i)}function p(r){return 45===r?(e.consume(r),s.interrupt?t:I):n(r)}function m(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?s.interrupt?t:C:m:n(r)}function h(t){return iB(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(a){if(null===a||47===a||62===a||iG(a)){let l=47===a,u=o.toLowerCase();return!l&&!i&&oY.includes(u)?(r=1,s.interrupt?t(a):C(a)):oW.includes(o.toLowerCase())?(r=6,l)?(e.consume(a),y):s.interrupt?t(a):C(a):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(a):i?v(a):b(a))}return 45===a||iH(a)?(e.consume(a),o+=String.fromCharCode(a),g):n(a)}function y(r){return 62===r?(e.consume(r),s.interrupt?t:C):n(r)}function v(t){return iQ(t)?(e.consume(t),v):O(t)}function b(t){return 47===t?(e.consume(t),O):58===t||95===t||iB(t)?(e.consume(t),_):iQ(t)?(e.consume(t),b):O(t)}function _(t){return 45===t||46===t||58===t||95===t||iH(t)?(e.consume(t),_):w(t)}function w(t){return 61===t?(e.consume(t),x):iQ(t)?(e.consume(t),w):b(t)}function x(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,E):iQ(t)?(e.consume(t),x):k(t)}function E(t){return t===l?(e.consume(t),l=null,S):null===t||iZ(t)?n(t):(e.consume(t),E)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||iG(t)?w(t):(e.consume(t),k)}function S(e){return 47===e||62===e||iQ(e)?b(e):n(e)}function O(t){return 62===t?(e.consume(t),D):n(t)}function D(t){return null===t||iZ(t)?C(t):iQ(t)?(e.consume(t),D):n(t)}function C(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),V):62===t&&4===r?(e.consume(t),N):63===t&&3===r?(e.consume(t),I):93===t&&5===r?(e.consume(t),j):iZ(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(oZ,L,F)(t)):null===t||iZ(t)?(e.exit("htmlFlowData"),F(t)):(e.consume(t),C)}function F(t){return e.check(oG,A,L)(t)}function A(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),P}function P(t){return null===t||iZ(t)?F(t):(e.enter("htmlFlowData"),C(t))}function T(t){return 45===t?(e.consume(t),I):C(t)}function V(t){return 47===t?(e.consume(t),o="",M):C(t)}function M(t){if(62===t){let n=o.toLowerCase();return oY.includes(n)?(e.consume(t),N):C(t)}return iB(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),M):C(t)}function j(t){return 93===t?(e.consume(t),I):C(t)}function I(t){return 62===t?(e.consume(t),N):45===t&&2===r?(e.consume(t),I):C(t)}function N(t){return null===t||iZ(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),N)}function L(n){return e.exit("htmlFlow"),t(n)}}function oX(e,t,n){let r=this;return i;function i(t){return iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):n(t)}function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function o0(e,t,n){return r;function r(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(i7,t,n)}}let o1={partial:!0,tokenize:o5},o2={concrete:!0,name:"codeFenced",tokenize:o4};function o4(e,t,n){let r,i=this,o={partial:!0,tokenize:w},a=0,l=0;return s;function s(e){return u(e)}function u(t){let n=i.events[i.events.length-1];return a=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,r=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(t)}function c(t){return t===r?(l++,e.consume(t),c):l<3?n(t):(e.exit("codeFencedFenceSequence"),iQ(t)?i1(e,d,"whitespace")(t):d(t))}function d(n){return null===n||iZ(n)?(e.exit("codeFencedFence"),i.interrupt?t(n):e.check(o1,h,_)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return null===t||iZ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(t)):iQ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),i1(e,p,"whitespace")(t)):96===t&&t===r?n(t):(e.consume(t),f)}function p(t){return null===t||iZ(t)?d(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||iZ(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(t)):96===t&&t===r?n(t):(e.consume(t),m)}function h(t){return e.attempt(o,_,g)(t)}function g(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),y}function y(t){return a>0&&iQ(t)?i1(e,v,"linePrefix",a+1)(t):v(t)}function v(t){return null===t||iZ(t)?e.check(o1,h,_)(t):(e.enter("codeFlowValue"),b(t))}function b(t){return null===t||iZ(t)?(e.exit("codeFlowValue"),v(t)):(e.consume(t),b)}function _(n){return e.exit("codeFenced"),t(n)}function w(e,t,n){let o=0;return a;function a(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s}function s(t){return e.enter("codeFencedFence"),iQ(t)?i1(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):u(t)}function u(t){return t===r?(e.enter("codeFencedFenceSequence"),c(t)):n(t)}function c(t){return t===r?(o++,e.consume(t),c):o>=l?(e.exit("codeFencedFenceSequence"),iQ(t)?i1(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||iZ(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}}function o5(e,t,n){let r=this;return i;function i(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o)}function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}let o3=document.createElement("i");function o6(e){let t="&"+e+";";o3.innerHTML=t;let n=o3.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let o9={name:"characterReference",tokenize:o7};function o7(e,t,n){let r,i,o=this,a=0;return l;function l(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s}function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),r=31,i=iH,c(t))}function u(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=iY,c):(e.enter("characterReferenceValue"),r=7,i=iW,c(t))}function c(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return i!==iH||o6(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&a++<r?(e.consume(l),c):n(l)}}let o8={name:"characterEscape",tokenize:ae};function ae(e,t,n){return r;function r(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),i}function i(r){return iJ(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}let at={name:"lineEnding",tokenize:an};function an(e,t){return n;function n(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),i1(e,t,"linePrefix")}}function ar(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let ai={name:"labelEnd",resolveAll:as,resolveTo:au,tokenize:ac},ao={tokenize:ad},aa={tokenize:af},al={tokenize:ap};function as(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&iP(e,0,e.length,n),e}function au(e,t){let n,r,i,o,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(i=a);let s={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},c={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[i-2][1].start}};return o=iT(o=[["enter",s,t],["enter",u,t]],e.slice(r+1,r+l+3)),o=iT(o,[["enter",c,t]]),o=iT(o,ar(t.parser.constructs.insideSpan.null,e.slice(r+l+4,i-3),t)),o=iT(o,[["exit",c,t],e[i-2],e[i-1],["exit",u,t]]),o=iT(o,e.slice(i+1)),o=iT(o,[["exit",s,t]]),iP(e,r,e.length,o),e}function ac(e,t,n){let r,i,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return l;function l(t){return r?r._inactive?d(t):(i=o.parser.defined.includes(oP(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)}function s(t){return 40===t?e.attempt(ao,c,i?c:d)(t):91===t?e.attempt(aa,c,i?u:d)(t):i?c(t):d(t)}function u(t){return e.attempt(al,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}function ad(e,t,n){return r;function r(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),i}function i(t){return iG(t)?oA(e,o)(t):o(t)}function o(t){return 41===t?c(t):oD(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return iG(t)?oA(e,s)(t):c(t)}function l(e){return n(e)}function s(t){return 34===t||39===t||40===t?oF(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function u(t){return iG(t)?oA(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}function af(e,t,n){let r=this;return i;function i(t){return oC.call(r,e,o,a,"reference","referenceMarker","referenceString")(t)}function o(e){return r.parser.defined.includes(oP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}function ap(e,t,n){return r;function r(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),i}function i(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}let am={name:"labelStartImage",resolveAll:ai.resolveAll,tokenize:ah};function ah(e,t,n){let r=this;return i;function i(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o}function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}function ag(e){return null===e||iG(e)||iX(e)?1:iK(e)?2:void 0}let ay={name:"attention",resolveAll:av,tokenize:ab};function av(e,t){let n,r,i,o,a,l,s,u,c=-1;for(;++c<e.length;)if("enter"===e[c][0]&&"attentionSequence"===e[c][1].type&&e[c][1]._close){for(n=c;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[c][1]).charCodeAt(0)){if((e[n][1]._close||e[c][1]._open)&&(e[c][1].end.offset-e[c][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[c][1].end.offset-e[c][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[c][1].end.offset-e[c][1].start.offset>1?2:1;let d={...e[n][1].end},f={...e[c][1].start};a_(d,-l),a_(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[c][1].start},end:f},i={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[c][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[c][1].start={...a.end},s=[],e[n][1].end.offset-e[n][1].start.offset&&(s=iT(s,[["enter",e[n][1],t],["exit",e[n][1],t]])),s=iT(s,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),s=iT(s,ar(t.parser.constructs.insideSpan.null,e.slice(n+1,c),t)),s=iT(s,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[c][1].end.offset-e[c][1].start.offset?(u=2,s=iT(s,[["enter",e[c][1],t],["exit",e[c][1],t]])):u=0,iP(e,n-1,c-n+3,s),c=n+s.length-u-2;break}}for(c=-1;++c<e.length;)"attentionSequence"===e[c][1].type&&(e[c][1].type="data");return e}function ab(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ag(i);return a;function a(t){return n=t,e.enter("attentionSequence"),l(t)}function l(a){if(a===n)return e.consume(a),l;let s=e.exit("attentionSequence"),u=ag(a),c=!u||2===u&&o||r.includes(a),d=!o||2===o&&u||r.includes(i);return s._open=!!(42===n?c:c&&(o||!d)),s._close=!!(42===n?d:d&&(u||!c)),t(a)}}function a_(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let aw={name:"autolink",tokenize:ax};function ax(e,t,n){let r=0;return i;function i(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(t){return iB(t)?(e.consume(t),a):64===t?n(t):u(t)}function a(e){return 43===e||45===e||46===e||iH(e)?(r=1,l(e)):u(e)}function l(t){return 58===t?(e.consume(t),r=0,s):(43===t||45===t||46===t||iH(t))&&r++<32?(e.consume(t),l):(r=0,u(t))}function s(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||iU(r)?n(r):(e.consume(r),s)}function u(t){return 64===t?(e.consume(t),c):iz(t)?(e.consume(t),u):n(t)}function c(e){return iH(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):f(n)}function f(t){if((45===t||iH(t))&&r++<63){let n=45===t?f:d;return e.consume(t),n}return n(t)}}let aE={name:"htmlText",tokenize:ak};function ak(e,t,n){let r,i,o,a=this;return l;function l(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s}function s(t){return 33===t?(e.consume(t),u):47===t?(e.consume(t),w):63===t?(e.consume(t),b):iB(t)?(e.consume(t),k):n(t)}function u(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,m):iB(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),f):iZ(t)?(o=d,V(t)):(e.consume(t),d)}function f(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?T(e):45===e?f(e):d(e)}function m(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?h:m):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),g):iZ(t)?(o=h,V(t)):(e.consume(t),h)}function g(t){return 93===t?(e.consume(t),y):h(t)}function y(t){return 62===t?T(t):93===t?(e.consume(t),y):h(t)}function v(t){return null===t||62===t?T(t):iZ(t)?(o=v,V(t)):(e.consume(t),v)}function b(t){return null===t?n(t):63===t?(e.consume(t),_):iZ(t)?(o=b,V(t)):(e.consume(t),b)}function _(e){return 62===e?T(e):b(e)}function w(t){return iB(t)?(e.consume(t),x):n(t)}function x(t){return 45===t||iH(t)?(e.consume(t),x):E(t)}function E(t){return iZ(t)?(o=E,V(t)):iQ(t)?(e.consume(t),E):T(t)}function k(t){return 45===t||iH(t)?(e.consume(t),k):47===t||62===t||iG(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),T):58===t||95===t||iB(t)?(e.consume(t),O):iZ(t)?(o=S,V(t)):iQ(t)?(e.consume(t),S):T(t)}function O(t){return 45===t||46===t||58===t||95===t||iH(t)?(e.consume(t),O):D(t)}function D(t){return 61===t?(e.consume(t),C):iZ(t)?(o=D,V(t)):iQ(t)?(e.consume(t),D):S(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,F):iZ(t)?(o=C,V(t)):iQ(t)?(e.consume(t),C):(e.consume(t),A)}function F(t){return t===r?(e.consume(t),r=void 0,P):null===t?n(t):iZ(t)?(o=F,V(t)):(e.consume(t),F)}function A(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||iG(t)?S(t):(e.consume(t),A)}function P(e){return 47===e||62===e||iG(e)?S(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function V(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return iQ(t)?i1(e,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):j(t)}function j(t){return e.enter("htmlTextData"),o(t)}}let aS={name:"labelStartLink",resolveAll:ai.resolveAll,tokenize:aO};function aO(e,t,n){let r=this;return i;function i(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}let aD={42:oh,43:oh,45:oh,48:oh,49:oh,50:oh,51:oh,52:oh,53:oh,54:oh,55:oh,56:oh,57:oh,62:oE},aC={91:oT},aF={[-2]:oI,[-1]:oI,32:oI},aA={35:oR,42:op,45:[oH,op],60:oJ,61:oH,95:op,96:o2,126:o2},aP={38:o9,92:o8},aT={[-5]:at,[-4]:at,[-3]:at,33:am,38:o9,42:ay,60:[aw,aE],91:aS,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return r;function r(t){return e.enter("hardBreakEscape"),e.consume(t),i}function i(r){return iZ(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},o8],93:ai,95:ay,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return a;function a(t){return e.enter("codeText"),e.enter("codeTextSequence"),l(t)}function l(t){return 96===t?(e.consume(t),o++,l):(e.exit("codeTextSequence"),s(t))}function s(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),s):96===t?(i=e.enter("codeTextSequence"),r=0,c(t)):iZ(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):(e.enter("codeTextData"),u(t))}function u(t){return null===t||32===t||96===t||iZ(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),u)}function c(n){return 96===n?(e.consume(n),r++,c):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(i.type="codeTextData",u(n))}}}},aV={null:[ay,ol]},aM={null:[42,95]},aj={null:[]};function aI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],a=[],l=[],s={attempt:E(w),check:E(x),consume:v,enter:b,exit:_,interrupt:E(x,{interrupt:!0})},u={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},c=t.tokenize.call(u,s);return t.resolveAll&&o.push(t),u;function d(e){return(a=iT(a,e),g(),null!==a[a.length-1])?[]:(k(t,0),u.events=ar(o,u.events,u),u.events)}function f(e,t){return aL(p(e),t)}function p(e){return aN(a,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function h(e){i[e.line]=e.column,O()}function g(){let e;for(;r._index<a.length;){let t=a[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)y(t.charCodeAt(r._bufferIndex));else y(t)}}function y(e){c=c(e)}function v(e){iZ(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,O()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e}function b(e,t){let n=t||{};return n.type=e,n.start=m(),u.events.push(["enter",n,u]),l.push(n),n}function _(e){let t=l.pop();return t.end=m(),u.events.push(["exit",t,u]),t}function w(e,t){k(e,t.from)}function x(e,t){t.restore()}function E(e,t){return n;function n(n,r,i){let o,a,l,c;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):d(n);function d(e){return t;function t(t){let n=null!==t&&e[t],r=null!==t&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return(o=e,a=0,0===e.length)?i:p(e[a])}function p(e){return n;function n(n){return(c=S(),l=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name))?h(n):e.tokenize.call(t?Object.assign(Object.create(u),t):u,s,m,h)(n)}}function m(t){return e(l,c),r}function h(e){return(c.restore(),++a<o.length)?p(o[a]):i}}}function k(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&iP(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function S(){let e=m(),t=u.previous,n=u.currentConstruct,i=u.events.length,o=Array.from(l);return{from:i,restore:a};function a(){r=e,u.previous=t,u.currentConstruct=n,u.events.length=i,l=o,O()}}function O(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aN(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,a=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,a)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}function aL(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,i.push(o)}return i.join("")}function aq(e){let t={constructs:iq([o,...(e||{}).extensions||[]]),content:n(i2),defined:[],document:n(i5),flow:n(oo),lazy:{},string:n(os),text:n(ou)};return t;function n(e){return n;function n(n){return aI(t,e,n)}}}let aR=/[\0\t\n\r]/g;function a$(){let e,t=1,n="",r=!0;return i;function i(i,o,a){let l,s,u,c,d,f=[];for(i=n+("string"==typeof i?i.toString():new TextDecoder(o||void 0).decode(i)),u=0,n="",r&&(65279===i.charCodeAt(0)&&u++,r=void 0);u<i.length;){if(aR.lastIndex=u,c=(l=aR.exec(i))&&void 0!==l.index?l.index:i.length,d=i.charCodeAt(c),!l){n=i.slice(u);break}if(10===d&&u===c&&e)f.push(-3),e=void 0;else switch(e&&(f.push(-5),e=void 0),u<c&&(f.push(i.slice(u,c)),t+=c-u),d){case 0:f.push(65533),t++;break;case 9:for(s=4*Math.ceil(t/4),f.push(-2);t++<s;)f.push(-1);break;case 10:f.push(-4),t=1;break;default:e=!0,t=1}u=c+1}return a&&(e&&f.push(-5),n&&f.push(n),f.push(null)),f}}function aB(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let aH=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function az(e){return e.replace(aH,aU)}function aU(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return aB(n.slice(t?2:1),t?16:10)}return o6(n)||e}let aW={}.hasOwnProperty;function aY(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),aJ(n)(iN(aq(n).document().write(a$()(e,t,!0))))}function aJ(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(et),autolinkProtocol:S,autolinkEmail:S,atxHeading:o(Q),blockQuote:o(W),characterEscape:S,characterReference:S,codeFenced:o(Y),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Y,a),codeText:o(J,a),codeTextData:S,data:S,codeFlowValue:S,definition:o(Z),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(G),hardBreakEscape:o(K),hardBreakTrailing:o(K),htmlFlow:o(X,a),htmlFlowData:S,htmlText:o(X,a),htmlTextData:S,image:o(ee),label:a,link:o(et),listItem:o(er),listItemValue:f,listOrdered:o(en,d),listUnordered:o(en),paragraph:o(ei),reference:q,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Q),strong:o(eo),thematicBreak:o(el)},exit:{atxHeading:s(),atxHeadingSequence:w,autolink:s(),autolinkEmail:U,autolinkProtocol:z,blockQuote:s(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:$,characterReferenceMarkerNumeric:$,characterReferenceValue:B,characterReference:H,codeFenced:s(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:O,codeIndented:s(y),codeText:s(P),codeTextData:O,data:O,definition:s(),definitionDestinationString:_,definitionLabelString:v,definitionTitleString:b,emphasis:s(),hardBreakEscape:s(C),hardBreakTrailing:s(C),htmlFlow:s(F),htmlFlowData:O,htmlText:s(A),htmlTextData:O,image:s(V),label:j,labelText:M,lineEnding:D,link:s(T),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:R,resourceDestinationString:I,resourceTitleString:N,resource:L,setextHeading:s(k),setextHeadingLineSequence:E,setextHeadingText:x,strong:s(),thematicBreak:s()}};aG(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:c,data:n},s=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?s.push(d):d=i(e,s.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];aW.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},o),e[d][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||aK).call(o,void 0,e[0])}for(r.position={start:aZ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:aZ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r,i,o,a,l=t-1,s=-1,u=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?s++:s--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||s||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!s&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===s&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=l;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",u=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(l,0,["enter",i,t[2]]),l++,n++,o=void 0,a=!0}}}return e[t][1]._spread=u,n}function o(e,t){return n;function n(n){l.call(this,e(n),n),t&&t.call(this,n)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:aZ(t.start),end:void 0}}function s(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||aK).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+rQ({start:e.start,end:e.end})+"): it’s not open");n.position.end=aZ(e.end)}function c(){return iD(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)}function p(){let e=this.resume();this.stack[this.stack.length-1].lang=e}function m(){let e=this.resume();this.stack[this.stack.length-1].meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oP(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume();this.stack[this.stack.length-1].title=e}function _(){let e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)}function x(){this.data.setextHeadingSlurpLineEnding=!0}function E(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function S(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n=ea()).position={start:aZ(e.start),end:void 0},t.push(n)),this.stack.push(n)}function O(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=aZ(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=aZ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(S.call(this,e),O.call(this,e))}function C(){this.data.atHardBreak=!0}function F(){let e=this.resume();this.stack[this.stack.length-1].value=e}function A(){let e=this.resume();this.stack[this.stack.length-1].value=e}function P(){let e=this.resume();this.stack[this.stack.length-1].value=e}function T(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function V(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=az(t),n.identifier=oP(t).toLowerCase()}function j(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t}function I(){let e=this.resume();this.stack[this.stack.length-1].url=e}function N(){let e=this.resume();this.stack[this.stack.length-1].title=e}function L(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function R(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function $(e){this.data.characterReferenceType=e.type}function B(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=aB(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=o6(n);let i=this.stack[this.stack.length-1];i.value+=t}function H(e){this.stack.pop().position.end=aZ(e.end)}function z(e){O.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function U(e){O.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function W(){return{type:"blockquote",children:[]}}function Y(){return{type:"code",lang:null,meta:null,value:""}}function J(){return{type:"inlineCode",value:""}}function Z(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function G(){return{type:"emphasis",children:[]}}function Q(){return{type:"heading",depth:0,children:[]}}function K(){return{type:"break"}}function X(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function en(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function er(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function ei(){return{type:"paragraph",children:[]}}function eo(){return{type:"strong",children:[]}}function ea(){return{type:"text",value:""}}function el(){return{type:"thematicBreak"}}}function aZ(e){return{line:e.line,column:e.column,offset:e.offset}}function aG(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?aG(e,r):aQ(e,r)}}function aQ(e,t){let n;for(n in t)if(aW.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}function aK(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+rQ({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rQ({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+rQ({start:t.start,end:t.end})+") is still open")}function aX(e){let t=this;function n(n){return aY(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}t.parser=n}let a0="object"==typeof self?self:globalThis,a1=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[o,a]=t[i];switch(o){case 0:case -1:return n(a,i);case 1:{let e=n([],i);for(let t of a)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),i);case 4:{let{source:e,flags:t}=a;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of a)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of a)e.add(r(t));return e}case 7:{let{name:e,message:t}=a;return n(new a0[e](t),i)}case 8:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i)}return n(new a0[o](a),i)};return r},a2=e=>a1(new Map,e)(0),a4="",{toString:a5}={},{keys:a3}=Object,a6=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=a5.call(e).slice(8,-1);switch(n){case"Array":return[1,a4];case"Object":return[2,a4];case"Date":return[3,a4];case"RegExp":return[4,a4];case"Map":return[5,a4];case"Set":return[6,a4]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},a9=([e,t])=>0===e&&("function"===t||"symbol"===t),a7=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},o=r=>{if(n.has(r))return n.get(r);let[a,l]=a6(r);switch(a){case 0:{let t=r;switch(l){case"bigint":a=8,t=r.toString();break;case"function":case"symbol":if(e)throw TypeError("unable to serialize "+l);t=null;break;case"undefined":return i([-1],r)}return i([a,t],r)}case 1:{if(l)return i([l,[...r]],r);let e=[],t=i([a,e],r);for(let t of r)e.push(o(t));return t}case 2:{if(l)switch(l){case"BigInt":return i([l,r.toString()],r);case"Boolean":case"Number":case"String":return i([l,r.valueOf()],r)}if(t&&"toJSON"in r)return o(r.toJSON());let n=[],s=i([a,n],r);for(let t of a3(r))(e||!a9(a6(r[t])))&&n.push([o(t),o(r[t])]);return s}case 3:return i([a,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([a,{source:e,flags:t}],r)}case 5:{let t=[],n=i([a,t],r);for(let[n,i]of r)(e||!(a9(a6(n))||a9(a6(i))))&&t.push([o(n),o(i)]);return n}case 6:{let t=[],n=i([a,t],r);for(let n of r)(e||!a9(a6(n)))&&t.push(o(n));return n}}let{message:s}=r;return i([a,{name:l,message:s}],r)};return o},a8=(e,{json:t,lossy:n}={})=>{let r=[];return a7(!(t||n),!!t,new Map,r)(e),r},le="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?a2(a8(e,t)):structuredClone(e):(e,t)=>a2(a8(e,t));function lt(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&iH(e.charCodeAt(n+1))&&iH(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ln(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function lr(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function li(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ln,r=e.options.footnoteBackLabel||lr,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],s=-1;for(;++s<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[s]);if(!i)continue;let o=e.all(i),a=String(i.identifier).toUpperCase(),u=lt(a.toLowerCase()),c=0,d=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++c<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(s,c);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+u+(c>1?"-"+c:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(s,c),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+u},children:e.wrap(o,!0)};e.patch(i,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...le(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}let lo=function(e){if(null==e)return lc;if("function"==typeof e)return lu(e);if("object"==typeof e)return Array.isArray(e)?la(e):ll(e);if("string"==typeof e)return ls(e);throw Error("Expected function, string, or object as test")};function la(e){let t=[],n=-1;for(;++n<e.length;)t[n]=lo(e[n]);return lu(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ll(e){let t=e;return lu(n);function n(n){let r,i=n;for(r in e)if(i[r]!==t[r])return!1;return!0}}function ls(e){return lu(t);function t(t){return t&&t.type===e}}function lu(e){return t;function t(t,n,r){return!!(ld(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function lc(){return!0}function ld(e){return null!==e&&"object"==typeof e&&"type"in e}function lf(e){return e}let lp=[],lm=!0,lh=!1,lg="skip";function ly(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let o=lo(i),a=r?-1:1;function l(e,i,s){let u=e&&"object"==typeof e?e:{};if("string"==typeof u.type){let t="string"==typeof u.tagName?u.tagName:"string"==typeof u.name?u.name:void 0;Object.defineProperty(c,"name",{value:"node ("+lf(e.type+(t?"<"+t+">":""))+")"})}return c;function c(){let u,c,d,f=lp;if((!t||o(e,i,s[s.length-1]||void 0))&&(f=lv(n(e,s)))[0]===lh)return f;if("children"in e&&e.children){let t=e;if(t.children&&f[0]!==lg)for(c=(r?t.children.length:-1)+a,d=s.concat(t);c>-1&&c<t.children.length;){if((u=l(t.children[c],c,d)())[0]===lh)return u;c="number"==typeof u[1]?u[1]:c+a}}return f}}l(e,void 0,[])()}function lv(e){return Array.isArray(e)?e:"number"==typeof e?[lm,e]:null==e?lp:[e]}function lb(e,t,n,r){let i,o,a;function l(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return a(e,r,n)}"function"==typeof t&&"function"!=typeof n?(o=void 0,a=t,i=n):(o=t,a=n,i=r),ly(e,o,l,i)}function l_(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function lw(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=lx(n[r])}return t}function lx(e){let t=e.spread;return null==t?e.children.length>1:t}let lE=9,lk=32;function lS(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(lO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(lO(t.slice(i),i>0,!1)),o.join("")}function lO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===lE||t===lk;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===lE||t===lk;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let lD={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=lt(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),l=e.footnoteCounts.get(i);void 0===l?(l=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(i,l);let s={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let u={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,u),e.applyData(t,u)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return l_(e,t);let i={src:lt(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:lt(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return l_(e,t);let i={href:lt(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:lt(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?lw(n):lx(t),o={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(i||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let s=r[r.length-1];s&&(i||"element"!==s.type||"p"!==s.tagName)&&a.push({type:"text",value:"\n"});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=rJ(t.children[1]),a=rY(t.children[t.children.length-1]);o&&a&&(r.position={start:o,end:a}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length,l=-1,s=[];for(;++l<a;){let n=t.children[l],r={},a=o?o[l]:void 0;a&&(r.align=a);let u={type:"element",tagName:i,properties:r,children:[]};n&&(u.children=e.all(n),e.patch(n,u),u=e.applyData(n,u)),s.push(u)}let u={type:"element",tagName:"tr",properties:{},children:e.wrap(s,!0)};return e.patch(t,u),e.applyData(t,u)},text:function(e,t){let n={type:"text",value:lS(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:lC,yaml:lC,definition:lC,footnoteDefinition:lC};function lC(){}let lF={}.hasOwnProperty,lA={};function lP(e,t){let n=t||lA,r=new Map,i=new Map,o={all:l,applyData:lV,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...lD,...n.handlers},one:a,options:n,patch:lT,wrap:lj};return lb(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o;function a(e,t){let n=e.type,r=o.handlers[n];if(lF.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=le(n);return r.children=o.all(e),r}return le(e)}return(o.options.unknownHandler||lM)(o,e,t)}function l(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=lI(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=lI(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function lT(e,t){e.position&&(t.position=rG(e))}function lV(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,le(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function lM(e,t){let n=t.data||{},r="value"in t&&!(lF.call(n,"hProperties")||lF.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function lj(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function lI(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function lN(e,t){let n=lP(e,t),r=n.one(e,void 0),i=li(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:"\n"},i),o}function lL(e,t){return e&&"run"in e?async function(n,r){let i=lN(n,{file:r,...t});await e.run(i,r)}:function(n,r){return lN(n,{file:r,...e||t})}}function lq(e){if(e)throw e}var lR=n(9710);function l$(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lB(){let e=[],t={run:n,use:r};return t;function n(...t){let r=-1,i=t.pop();if("function"!=typeof i)throw TypeError("Expected function as last argument, not "+i);function o(n,...a){let l=e[++r],s=-1;if(n)return void i(n);for(;++s<t.length;)(null===a[s]||void 0===a[s])&&(a[s]=t[s]);t=a,l?lH(l,o)(...a):i(null,...a)}o(null,...t)}function r(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function lH(e,t){let n;return r;function r(...t){let a,l=e.length>t.length;l&&t.push(i);try{a=e.apply(this,t)}catch(t){let e=t;if(l&&n)throw e;return i(e)}l||(a instanceof Promise?a.then(o,i):a instanceof Error?i(a):o(a))}function i(e,...r){n||(n=!0,t(e,...r))}function o(e){i(null,e)}}let lz=lZ,lU=lG,lW=lQ,lY=lK,lJ="/";function lZ(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');l1(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(i=o):(l=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)}function lG(e){let t;if(l1(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)}function lQ(e){let t;l1(e);let n=e.length,r=-1,i=0,o=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===l?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===i+1?"":e.slice(o,r)}function lK(...e){let t,n=-1;for(;++n<e.length;)l1(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":lX(t)}function lX(e){l1(e);let t=47===e.codePointAt(0),n=l0(e,!t);return 0!==n.length||t||(n="."),n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/"),t?"/"+n:n}function l0(e,t){let n,r,i="",o=0,a=-1,l=0,s=-1;for(;++s<=e.length;){if(s<e.length)n=e.codePointAt(s);else if(47===n)break;else n=47;if(47===n){if(a===s-1||1===l);else if(a!==s-1&&2===l){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=s,l=0;continue}}else if(i.length>0){i="",o=0,a=s,l=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(a+1,s):i=e.slice(a+1,s),o=s-a-1;a=s,l=0}else 46===n&&l>-1?l++:l=-1}return i}function l1(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}let l2=l4;function l4(){return"/"}function l5(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function l3(e){if("string"==typeof e)e=new URL(e);else if(!l5(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return l6(e)}function l6(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}let l9=["history","path","basename","stem","extname","dirname"];class l7{constructor(e){let t,n;t=e?l5(e)?{path:e}:"string"==typeof e||sn(e)?{value:e}:e:{},this.cwd="cwd"in t?"":l2(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<l9.length;){const e=l9[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)l9.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?lz(this.path):void 0}set basename(e){se(e,"basename"),l8(e,"basename"),this.path=lY(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?lU(this.path):void 0}set dirname(e){st(this.basename,"dirname"),this.path=lY(e||"",this.basename)}get extname(){return"string"==typeof this.path?lW(this.path):void 0}set extname(e){if(l8(e,"extname"),st(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=lY(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){l5(e)&&(e=l3(e)),se(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?lz(this.path,this.extname):void 0}set stem(e){se(e,"stem"),l8(e,"stem"),this.path=lY(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new r1(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function l8(e,t){if(e&&e.includes(lJ))throw Error("`"+t+"` cannot be a path: did not expect `"+lJ+"`")}function se(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function st(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function sn(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}let sr=function(e){let t=this,n=t.constructor.prototype,r=n[e],i=function(){return r.apply(i,arguments)};return Object.setPrototypeOf(i,n),i},si={}.hasOwnProperty;class so extends sr{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lB()}copy(){let e=new so,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data(lR(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(su("data",this.frozen),this.namespace[e]=t,this):si.call(this.namespace,e)&&this.namespace[e]||void 0:e?(su("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);let r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=sf(e),n=this.parser||this.Parser;return sl("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),sl("process",this.parser||this.Parser),ss("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=sf(e),a=n.parse(o);function l(e,n){e||!n?i(e):r?r(n):t(void 0,n)}n.run(a,o,function(e,t,r){if(e||!t||!r)return l(e);let i=t,o=n.stringify(i,r);sm(o)?r.value=o:r.result=o,l(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),sl("processSync",this.parser||this.Parser),ss("processSync",this.compiler||this.Compiler),this.process(e,r),sd("processSync","process",n),t;function r(e,r){n=!0,lq(e),t=r}}run(e,t,n){sc(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){let a=sf(t);function l(t,r,a){let l=r||e;t?o(t):i?i(l):n(void 0,l,a)}r.run(e,a,l)}}runSync(e,t){let n,r=!1;return this.run(e,t,i),sd("runSync","run",r),n;function i(e,t){lq(e),n=t,r=!0}}stringify(e,t){this.freeze();let n=sf(t),r=this.compiler||this.Compiler;return ss("stringify",r),sc(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(su("use",this.frozen),null==e);else if("function"==typeof e)l(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if("function"==typeof e)l(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;l(t,n)}else o(e);else throw TypeError("Expected usable value, not `"+e+"`")}function o(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(r.settings=lR(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)i(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function l(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,a=n[i][1];l$(a)&&l$(r)&&(r=lR(!0,a,r)),n[i]=[e,r,...o]}}}}let sa=new so().freeze();function sl(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function ss(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function su(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sc(e){if(!l$(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function sd(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function sf(e){return sp(e)?e:new l7(e)}function sp(e){return!!(e&&"object"==typeof e&&"message"in e&&"messages"in e)}function sm(e){return"string"==typeof e||sh(e)}function sh(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}let sg=[],sy={allowDangerousHtml:!0},sv=/^(https?|ircs?|mailto|xmpp)$/i,sb=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function s_(e){let t=e.allowedElements,n=e.allowElement,r=e.children||"",i=e.className,o=e.components,a=e.disallowedElements,l=e.rehypePlugins||sg,s=e.remarkPlugins||sg,u=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sy}:sy,c=e.skipHtml,d=e.unwrapDisallowed,f=e.urlTransform||sw,p=sa().use(aX).use(s).use(lL,u).use(l),m=new l7;for(let t of("string"==typeof r&&(m.value=r),sb))Object.hasOwn(e,t.from)&&(t.from,t.to&&t.to,t.id);let h=p.parse(m),g=p.runSync(h,m);return i&&(g={type:"element",tagName:"div",properties:{className:i},children:"root"===g.type?g.children:[g]}),lb(g,y),r8(g,{Fragment:iS.Fragment,components:o,ignoreInvalidStyle:!0,jsx:iS.jsx,jsxs:iS.jsxs,passKeys:!0,passNode:!0});function y(e,r,i){if("raw"===e.type&&i&&"number"==typeof r)return c?i.children.splice(r,1):i.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in ik)if(Object.hasOwn(ik,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=ik[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=f(String(n||""),t,e))}}if("element"===e.type){let o=t?!t.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&n&&"number"==typeof r&&(o=!n(e,r,i)),o&&i&&"number"==typeof r)return d&&e.children?i.children.splice(r,1,...e.children):i.children.splice(r,1),r}}}function sw(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t<0||i>-1&&t>i||n>-1&&t>n||r>-1&&t>r||sv.test(e.slice(0,t))?e:""}let sx="-esm-form-engine__markdown-wrapper__markdownWrapper___N6Orn",sE={a:({node:e,...t})=>f().createElement("a",{...t,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer"})},sk=({markdown:e})=>f().createElement("div",{className:sx},f().createElement(s_,{children:e,unwrapDisallowed:!0,allowedElements:["h1","h2","h3","h4","h5","h6","p","strong","em","code","pre","ul","ol","li","a","blockquote","hr","br"],components:sE})),sS=({field:e})=>{let{t}=(0,e9.useTranslation)(),n=e=>Array.isArray(e)?e.map(e=>t(e,{defaultValue:e,interpolation:{escapeValue:!1}})).join("\n\n"):"string"==typeof e?t(e,{defaultValue:e,interpolation:{escapeValue:!1}}):e;return!e.isHidden&&f().createElement(sk,{markdown:n(e.value)})},sO={boldedLabel:"-esm-form-engine__multi-select__boldedLabel___-TJAY",errorLabel:"-esm-form-engine__multi-select__errorLabel___Cx0K1",selectionDisplay:"-esm-form-engine__multi-select__selectionDisplay___KJIF4",tagContainer:"-esm-form-engine__multi-select__tagContainer___jtOs2",checkbox:"-esm-form-engine__multi-select__checkbox___m66zk"},sD=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),[c,p]=(0,d.useState)(0),[m,h]=(0,d.useState)([]),g=(0,d.useRef)(!0),v=e.questionOptions.answers.filter(e=>!e.isHidden).map((t,n)=>({id:`${e.id}-${t.concept}`,concept:t.concept,label:o(t.label),key:n,disabled:t.disable?.isDisabled,readonly:(0,np.H)(e.readonly)})),b=(0,d.useMemo)(()=>t?.length&&c<1?(p(c+1),v.filter(e=>t?.includes(e.concept))):[],[t]),_=({selectedItems:e})=>{i(e.map(e=>e.concept))},w=(0,d.useMemo)(()=>(0,np.H)(e.questionOptions.isCheckboxSearchable),[e.questionOptions.isCheckboxSearchable]);(0,d.useEffect)(()=>{g.current&&1===c&&(h(b.map(e=>e.concept)),g.current=!1)},[b,g]);let x=e=>{let t,n=e.concept;h(t=m.some(e=>e===n)?m.filter(e=>e!==n):m.some(e=>e===n)?m.filter(e=>e!==n):[...m,n]),i(t)},E=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement("div",{className:sO.formField},f().createElement(nU,{label:o(e.label),value:t?u[e.type]?.getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:E})):!e.isHidden&&f().createElement(f().Fragment,null,f().createElement("div",{className:sO.boldedLabel},f().createElement(y.Layer,null,w?f().createElement(y.FilterableMultiSelect,{disabled:e.isDisabled,id:e.id,initialSelectedItems:b,invalid:n.length>0,invalidText:n[0]?.message,items:v,itemToString:e=>e?o(e.label):" ",key:e.id,onChange:_,placeholder:o("search","Search")+"...",readOnly:(0,np.H)(e.readonly),titleText:f().createElement(n1,{field:e}),warn:r.length>0,warnText:r[0]?.message}):f().createElement(y.CheckboxGroup,{legendText:f().createElement(n1,{field:e}),readOnly:(0,np.H)(e.readonly)},v?.map((t,n)=>f().createElement(y.Checkbox,{className:sO.checkbox,checked:m.some(e=>e===t.concept),disabled:t.disabled,id:`${e.id}-${t.concept}`,key:`${e.id}-${t.concept}-${n}`,labelText:o(t.label),name:t.concept,onChange:()=>x(t),readOnly:(0,np.H)(e.readonly)}))))),w&&f().createElement("div",{className:sO.selectionDisplay},t?.length?f().createElement("div",{className:sO.tagContainer},u[e.type]?.getDisplayValue(e,t)?.map((e,t)=>f().createElement(y.Tag,{key:t,type:"cool-gray"},o(e)))):f().createElement(n_,null)))},sC={boldedLabel:"-esm-form-engine__number__boldedLabel___baNvc",errorLabel:"-esm-form-engine__number__errorLabel___vJnNs",controlWidthConstrained:"-esm-form-engine__number__controlWidthConstrained___wjS56"},sF=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=ng(),u=(0,d.useMemo)(()=>isNaN(t)?"":t??"",[t]),c=(0,d.useCallback)(e=>void 0===e||isNaN(Number(e))?void 0:Number(e),[]),p=(0,d.useCallback)((e,{value:t})=>{let n=c(t);i(isNaN(n)?void 0:n)},[i,c]),h=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]),g=c(e.questionOptions.max),v=c(e.questionOptions.min);return"view"==l||"embedded-view"==l?f().createElement("div",{className:sC.formField},f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:h})):!e.isHidden&&f().createElement(y.Layer,null,f().createElement(y.NumberInput,{id:e.id,invalid:n.length>0,invalidText:n[0]?.message,label:f().createElement(n1,{field:e}),max:g,min:v,name:e.id,value:u,onChange:p,allowEmpty:!0,size:"lg",hideSteppers:e.hideSteppers??!1,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),className:m()(sC.controlWidthConstrained,sC.boldedLabel),warn:r.length>0,warnText:r[0]?.message,step:e.questionOptions.step??.01}))},sA="-esm-form-engine__radio__boldedLegend___YisTw",sP="-esm-form-engine__radio__errorMessage___fmThI",sT=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),c=e=>{i(e)},p=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,np.H)(e.readonly)?f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&f().createElement(y.FormGroup,{legendText:f().createElement(n1,{field:e}),className:sA,disabled:e.isDisabled,invalid:n?.length>0},f().createElement(y.RadioButtonGroup,{name:e.id,valueSelected:t,onChange:c,readOnly:(0,np.H)(e.readonly),orientation:e.questionOptions?.orientation||"vertical"},e.questionOptions.answers.filter(e=>!e.isHidden).map((n,r)=>f().createElement(y.RadioButton,{id:`${e.id}-${n.label}`,labelText:o(n.label)??"",value:n.concept,key:r,onClick:e=>{t&&e.target.checked?(e.target.checked=!1,e.preventDefault(),c(null)):c(n.concept)}}))),(n?.length>0||r?.length>0)&&f().createElement("div",null,f().createElement("div",{className:sP},n.length>0?n[0].message:r.length>0?r[0].message:null)))},sV="-esm-form-engine__dropdown__boldedLabel___jRkpD",sM=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=ng(),p=(0,d.useCallback)(({selectedItem:e})=>{i(e===c.ZA?null:e)},[i]),m=(0,d.useCallback)(t=>{let n=e.questionOptions.answers.find(e=>e.value?e.value==t:e.concept==t);return n?o(n.label):""},[e.questionOptions.answers,o]),h=(0,d.useMemo)(()=>{let t=e.questionOptions.answers;return t.some(e=>e.value===c.ZA)||t.unshift({value:c.ZA,label:o("chooseAnOption","Choose an option")}),t.filter(e=>!e.isHidden).map(e=>e.value||e.concept)},[e.questionOptions.answers]),g=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement(nU,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:g}):!e.isHidden&&f().createElement("div",{className:sV},f().createElement(y.Layer,null,f().createElement(y.Dropdown,{"aria-label":o(e.label),disabled:e.isDisabled,id:e.id,invalid:n.length>0,invalidText:n[0]?.message,items:h,itemToString:m,label:"",onChange:p,readOnly:(0,np.H)(e.readonly),selectedItem:ts(t)?c.ZA:t,titleText:f().createElement(n1,{field:e}),warn:r.length>0,warnText:r[0]?.message})))},sj="-esm-form-engine__text-area__boldedLabel___VdRnE",sI=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),[a,l]=(0,d.useState)(t),{layoutType:s,sessionMode:u,workspaceLayout:c}=ng(),p=e=>{e.preventDefault(),a!==t&&l(t)},m=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(u)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,s,c,u),[u,e.readonly,e.inlineRendering,s,c]);return"view"==u||"embedded-view"==u?f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:m}):!e.isHidden&&f().createElement("div",{className:sj},f().createElement(y.Layer,null,f().createElement(y.TextArea,{id:e.id,labelText:f().createElement(n1,{field:e}),name:e.id,onChange:i,onBlur:p,value:t||"",rows:e.questionOptions.rows||4,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),invalid:n.length>0,invalidText:n[0]?.message,warn:r.length>0,warnText:r[0]?.message,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength)})))},sN="-esm-form-engine__text__boldedLabel___WRIlW",sL=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=ng(),[u,c]=(0,d.useState)(null),p=e=>{e.preventDefault(),u!==t&&c(t)},m=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?f().createElement(nU,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:m}):!e.isHidden&&f().createElement("div",{className:sN},f().createElement(y.Layer,null,f().createElement(y.TextInput,{disabled:e.isDisabled,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),id:e.id,invalid:n.length>0,invalidText:n[0]?.message,labelText:f().createElement(n1,{field:e}),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength),name:e.id,onBlur:p,onChange:e=>{i(e.target.value)},readOnly:(0,np.H)(e.readonly),value:t??"",warn:r.length>0,warnText:r.length>0?r[0].message:void 0})))},sq="-esm-form-engine__toggle__boldedLabel___IF1zX",sR=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,e9.useTranslation)(),a=ng(),l=e=>{i(e)};(0,d.useEffect)(()=>{e.meta?.initialValue?.omrsObject||"enter"!=a.sessionMode||a.formFieldAdapters[e.type].transformFieldValue(e,t??!1,a)},[]);let s=(0,d.useMemo)(()=>!!(["view","embedded-view"].includes(a.sessionMode)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,a.layoutType,a.workspaceLayout,a.sessionMode),[a.sessionMode,e.readonly,e.inlineRendering,a.layoutType,a.workspaceLayout]);return"view"==a.sessionMode||"embedded-view"==a.sessionMode?f().createElement(nU,{label:o(e.label),value:ts(t)?t:a.formFieldAdapters[e.type].getDisplayValue(e,t),conceptName:e.meta?.concept?.display,isInline:s}):!e.isHidden&&f().createElement("div",{className:sq},f().createElement(y.Toggle,{labelText:o(e.label),className:sq,id:e.id,labelA:e.questionOptions.toggleOptions.labelFalse,labelB:e.questionOptions.toggleOptions.labelTrue,onToggle:l,toggled:!!t,disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly)}))};var s$=n(7942),sB=n(9600);let sH=function(){return sB.A.Date.now()};var sz=/\s/;let sU=function(e){for(var t=e.length;t--&&sz.test(e.charAt(t)););return t};var sW=/^\s+/;let sY=function(e){return e?e.slice(0,sU(e)+1).replace(sW,""):e};var sJ=n(4089),sZ=0/0,sG=/^[-+]0x[0-9a-f]+$/i,sQ=/^0b[01]+$/i,sK=/^0o[0-7]+$/i,sX=parseInt;let s0=function(e){if("number"==typeof e)return e;if((0,sJ.A)(e))return sZ;if((0,s$.A)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,s$.A)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=sY(e);var n=sQ.test(e);return n||sK.test(e)?sX(e.slice(2),n?2:8):sG.test(e)?sZ:+e};var s1="Expected a function",s2=Math.max,s4=Math.min;let s5=function(e,t,n){var r,i,o,a,l,s,u=0,c=!1,d=!1,f=!0;if("function"!=typeof e)throw TypeError(s1);function p(t){var n=r,o=i;return r=i=void 0,u=t,a=e.apply(o,n)}function m(e){return u=e,l=setTimeout(y,t),c?p(e):a}function h(e){var n=e-s,r=e-u,i=t-n;return d?s4(i,o-r):i}function g(e){var n=e-s,r=e-u;return void 0===s||n>=t||n<0||d&&r>=o}function y(){var e=sH();if(g(e))return v(e);l=setTimeout(y,h(e))}function v(e){return(l=void 0,f&&r)?p(e):(r=i=void 0,a)}function b(){return void 0===l?a:v(sH())}function _(){var e=sH(),n=g(e);if(r=arguments,i=this,s=e,n){if(void 0===l)return m(s);if(d)return clearTimeout(l),l=setTimeout(y,t),p(s)}return void 0===l&&(l=setTimeout(y,t)),a}return t=s0(t)||0,(0,s$.A)(n)&&(c=!!n.leading,o=(d="maxWait"in n)?s2(s0(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),_.cancel=function(){void 0!==l&&clearTimeout(l),u=0,r=s=i=l=void 0},_.flush=b,_},s3=[{name:"drug",datasource:{name:"drug_datasource",config:{class:"8d490dfc-c2cc-11de-8d13-0010c6dffd0f"}}},{name:"select-concept-answers",datasource:{name:"select_concept_answers_datasource",config:{concept:""}}},{name:"encounter-provider",datasource:{name:"provider_datasource"}},{name:"encounter-role",datasource:{name:"encounter_role_datasource"}},{name:"encounter-location",datasource:{name:"location_datasource"}},{name:"problem",datasource:{name:"problem_datasource",config:{class:["8d4918b0-c2cc-11de-8d13-0010c6dffd0f","8d492954-c2cc-11de-8d13-0010c6dffd0f","8d492b2a-c2cc-11de-8d13-0010c6dffd0f"]}}}],s6=e=>s3.find(t=>t.name===e),s9=e=>{let t=e.questionOptions.config?.referencedField,{methods:{control:n}}=ng();return ef({control:n,name:t,exact:!0,disabled:!t})},s7="-esm-form-engine__ui-select-extended__boldedLabel___MlmB3",s8="-esm-form-engine__ui-select-extended__loader___-txFf",ue="-esm-form-engine__ui-select-extended__item___+jYTi",ut="-esm-form-engine__ui-select-extended__code___Sg-vJ",un="-esm-form-engine__ui-select-extended__label___tsm2B",ur=({field:e,errors:t,warnings:n,setFieldValue:r})=>{let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)([]),[l,s]=(0,d.useState)(!1),[u,c]=(0,d.useState)(!1),[p,m]=(0,d.useState)(""),h=(0,d.useRef)(!1),[g,v]=(0,d.useState)(null),[b,_]=(0,d.useState)({}),w=s9(e),x=(0,np.H)(e.questionOptions.isSearchable),{layoutType:E,sessionMode:k,workspaceLayout:S,methods:{control:O,getFieldState:D,getValues:C}}=ng(),F=ef({control:O,name:e.id,exact:!0}),{isDirty:A}=D(e.id),P=(0,d.useMemo)(()=>!!(tg(k)||(0,np.H)(e.readonly))&&t3(e.inlineRendering,E,S,k),[k,e.readonly,e.inlineRendering,E,S]),T=(0,d.useMemo)(()=>o.find(e=>e.uuid==F)||null,[o,F]),V=(0,d.useRef)(0),M=(0,d.useMemo)(()=>s5((t,n)=>{let r=V.current;c(!0),n.fetchData(t,b).then(t=>{r===V.current&&(t.length&&a(r=>{let i=C(e.id),o=r.find(e=>e.uuid==i),a=t.map(e=>n.toUuidAndDisplay(e,b));return o&&!a.some(e=>e.uuid==o.uuid)&&a.unshift(o),a}),c(!1))}).catch(e=>{r===V.current&&(console.error(e),c(!1))})},300),[b,e.id,C]),j=(0,d.useCallback)(e=>o.some(t=>t.display?.toLowerCase().includes(e.toLowerCase())),[o]);return((0,d.useEffect)(()=>{let t=e.questionOptions?.datasource?.name;_(t?e.questionOptions.datasource?.config:s6(e.questionOptions.rendering)?.datasource?.config),dA(t||e.questionOptions.rendering).then(e=>v(e))},[e.questionOptions?.datasource]),(0,d.useEffect)(()=>{let t=!1;return g&&!(0,np.H)(e.questionOptions.isSearchable)&&(a([]),s(!0),g.fetchData(null,{...b,referencedValue:w}).then(e=>{t||(a(e.map(e=>g.toUuidAndDisplay(e,b))),s(!1))}).catch(e=>{t||(console.error(e),s(!1),a([]))})),()=>{t=!0}},[g,b,w]),(0,d.useEffect)(()=>(g&&x&&!ts(p)&&!j(p)?M(p,g):c(!1),()=>{M.cancel(),V.current++}),[g,p,x,M]),(0,d.useEffect)(()=>{let e=!1;return F&&!A&&g&&x&&!o.length&&(s(!0),g.fetchSingleItem(F,b).then(t=>{e||(a([g.toUuidAndDisplay(t,b)]),s(!1))}).catch(t=>{e||(console.error(t),s(!1))})),()=>{e=!0}},[F,A,g,x,o,b]),l)?f().createElement(y.DropdownSkeleton,null):tg(k)||(0,np.H)(e.readonly)?f().createElement(nU,{label:i(e.label),value:F?ui(o.find(e=>e.uuid==F)):F,conceptName:e.meta?.concept?.display,isInline:P}):!e.isHidden&&f().createElement("div",{className:s7},f().createElement(y.Layer,null,f().createElement(y.ComboBox,{id:e.id,titleText:f().createElement(n1,{field:e}),items:o,itemToElement:e=>f().createElement("span",{className:ue},e?.code&&f().createElement("span",{className:ut},e.code),f().createElement("span",{className:un},e?.display)),itemToString:ui,selectedItem:T,placeholder:x?i("search","Search")+"...":null,onChange:({selectedItem:e})=>{M.cancel(),V.current++,c(!1),h.current=!0,r(e?.uuid)},disabled:e.isDisabled,readOnly:(0,np.H)(e.readonly),invalid:t.length>0,invalidText:t.length&&t[0].message,onInputChange:t=>{if(h.current){h.current=!1;return}e.questionOptions.isSearchable&&m(t)},onBlur:e=>{e.target.value||r(null)}}),u&&f().createElement(y.InlineLoading,{className:s8,description:i("searching","Searching")+"..."})))};function ui(e){return e?.code?`${e.code} ${e.display}`:e?.display??""}let uo="-esm-form-engine__workspace-launcher__label___vIWfO",ua="-esm-form-engine__workspace-launcher__workspaceButton___cmGUN",ul="-esm-form-engine__workspace-launcher__noPatientNotification___hhJs2",us=({field:e})=>{let{t}=(0,e9.useTranslation)(),{sessionMode:n,patient:r,visit:i}=ng(),o=async()=>{let n=e.questionOptions?.workspaceName;if(!n)return void(0,u.showSnackbar)({title:t("invalidWorkspaceName","Invalid workspace name."),subtitle:t("invalidWorkspaceNameSubtitle","Please provide a valid workspace name."),kind:"error",isLowContrast:!0});let o=e.questionOptions?.workspaceProps??{},a={patient:r,patientUuid:r?.id,visitContext:i};try{await (0,u.launchWorkspace2)(n,o,a)}catch(e){(0,u.showSnackbar)({title:t("errorLaunchingWorkspace","Error launching workspace"),subtitle:e?.message??t("errorLaunchingWorkspaceSubtitle","An unexpected error occurred while launching the workspace."),kind:"error",isLowContrast:!0})}};return e.isHidden||tg(n)?null:f().createElement("div",null,f().createElement("div",{className:uo},f().createElement(n1,{field:e})),f().createElement("div",{className:ua},f().createElement(y.Button,{disabled:(0,np.H)(e.readonly??!1)||!r,onClick:o},e.questionOptions.buttonLabel?t(e.questionOptions.buttonLabel):t("launchWorkspace","Launch Workspace")),!r&&f().createElement(y.InlineNotification,{className:ul,kind:"info",lowContrast:!0,hideCloseButton:!0,title:t("noPatientContext","No patient selected"),subtitle:t("noPatientContextSubtitle","This button is only active when a patient chart is open.")})))};var uu=n(3322);function uc(e,t,n){let r=[],i=(0,uu.A)(e);return i.questionOptions.repeatOptions={...i.questionOptions.repeatOptions??{}},i.meta={repeat:{...i.meta??{},isClone:!0},initialValue:{omrsObject:t}},i.id=`${i.id}_${n}`,i.questions?.forEach(e=>{r.push(e.id),e.id=`${e.id}_${n}`,e.meta.groupId=i.id,e.meta.initialValue={omrsObject:null,refinedValue:null},e.fieldDependents=new Set,tp(e),e.hide&&e.hide.hideWhenExpression&&(e.hide.hideWhenExpression=ud(e.hide.hideWhenExpression,n,r)),e.validators?.length&&e.validators.forEach(e=>{"js_expression"===e.type&&(e.failsWhenExpression=ud(e.failsWhenExpression,n,r))}),e.questionOptions.calculate?.calculateExpression&&(e.questionOptions.calculate.calculateExpression=ud(e.questionOptions.calculate?.calculateExpression,n,r))}),i}function ud(e,t,n){let r=[...new Set(n)];if(!r.length)return e;let i=r.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return e.replace(RegExp(`\\b(?:${i})\\b`,"g"),e=>`${e}_${t}`)}function uf(e,t){let n=Number(e);return!(ts(e)||isNaN(n))&&t>=n}let up=[],um={async getInitialValue(e,t,n){let r=uE(td((t??n.domainObjectValue).obs),up,e);return tf(e,"file")&&r?.length?uk(e,r):uh(e,r,!0)},async getPreviousValue(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let t=uh(e,uE(td(r.obs),up,e),!0);if(!ts(t))return{value:t,display:this.getDisplayValue(e,t)}}return null},getDisplayValue:(e,t)=>{let n=e.questionOptions.rendering;return ts(t)?t:t instanceof Date?tb(e,t):"checkbox"===n?t.map(t=>e.questionOptions.answers?.find(e=>e.concept==t)?.label):"toggle"===n?t?e.questionOptions.toggleOptions.labelTrue:e.questionOptions.toggleOptions.labelFalse:c.FU.includes(n)?e.questionOptions.answers?.find(e=>e.concept==t)?.label:t},transformFieldValue:(e,t,n)=>(tp(e),!e.meta.initialValue?.omrsObject&&ts(t))?null:tf(e,"checkbox")?uw(e,Array.isArray(t)?t:[t]):tf(e,"file")?ux(e,t):!ts(t)&&u_(e,t)?tm(e,uv(e,t),void 0):e.meta.initialValue?.omrsObject&&ts(t)?tm(e,void 0,uy(e.meta.initialValue.omrsObject)):ts(t)?null:tm(e,ug(e,t),void 0),tearDown:function(){up=[]}};function uh(e,t=[],n=!1){let r=e.questionOptions.rendering;if(e.meta||(e.meta={initialValue:{omrsObject:null,refinedValue:null}}),t.length){if("checkbox"==r)return up.push(...t.map(e=>e.uuid)),e.meta.initialValue.omrsObject=n?t:null,t.map(e=>e.value.uuid);let i=t[0];if(n&&(e.meta.initialValue.omrsObject={...i}),up.push(i.uuid),"string"==typeof i.value||"number"==typeof i.value){if(r.startsWith("date")){let t=ty(i.value);return n&&(e.meta.initialValue.omrsObject.value=tr()(t).format("YYYY-MM-DD HH:mm")),t}return i.value}return"toggle"==r?i.value.uuid===c.t$:"fixed-value"==r?e.fixedValue:i.value?.uuid}return""}function ug(e,t){return ts(t)&&"obsGroup"!==e.type?null:{..."obsGroup"===e.type?{groupMembers:[]}:{value:e.questionOptions.rendering.startsWith("date")?ub(e,t):t},concept:e.questionOptions.concept,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function uy(e){return{uuid:e.uuid,voided:!0}}function uv(e,t){let n=e.meta.initialValue?.omrsObject,r=e.questionOptions.rendering.startsWith("date")?ub(e,t):t;return{uuid:n.uuid,value:r,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function ub(e,t){if(e.datePickerFormat)switch(e.datePickerFormat){case"calendar":default:return tr()(t).format("YYYY-MM-DD");case"timer":return tr()(t).format("HH:mm");case"both":return tr()(t).format("YYYY-MM-DD HH:mm")}return t}function u_(e,t){let n=e.meta.initialValue?.omrsObject;return!ts(n)&&(c.FU.includes(e.questionOptions.rendering)?n.value.uuid!==t:tf(e,"date")?0!==tr()(t).diff(tr()(n.value),"D"):tf(e,"datetime")||"both"===e.datePickerFormat?0!==tr()(t).diff(tr()(n.value),"minute"):tf(e,"toggle")?n.value.uuid===c.t$!==t:n.value!==t)}function uw(e,t=[]){let n=e.meta.initialValue?.omrsObject;if(n?.length&&ts(t))return tm(e,null,n.map(e=>uy(e)));if(n?.length&&!ts(t)){let r=n.filter(e=>!t.includes(e.value.uuid));return tm(e,t.filter(e=>!n.some(t=>t.value.uuid===e)).map(t=>ug(e,t)),r.map(e=>uy(e)))}return tm(e,t.map(t=>ug(e,t)),void 0)}function ux(e,t=[]){let n=t.filter(e=>e.uuid&&e.voided).map(e=>({uuid:e.uuid,voided:!0})),r=e.meta.submission.newValue=t.filter(e=>!e.uuid).map(t=>({formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`,...t}));return tm(e,r,n)}function uE(e,t,n){let r=e.filter(e=>!!tf(n,"file")&&e.formFieldPath==`rfe-forms-${n.id}`||e.formFieldPath==`rfe-forms-${n.id}`&&e.concept.uuid==n.questionOptions.concept);if(!r?.length){let r=e.filter(e=>e.concept.uuid==n.questionOptions.concept);return t?.length?r.filter(e=>!t.includes(e.uuid)):r}return r}async function uk(e,t){let n=new AbortController,r=await Promise.all(t.map(e=>(0,u.getAttachmentByUuid)(e.uuid,n).then(e=>e.data).catch(t=>(console.error(`Failed to fetch attachment ${e.uuid}:`,t),null))));return e.meta.initialValue={omrsObject:t},r.filter(Boolean).map(e=>({uuid:e.uuid,base64Content:`${window.openmrsBase}${u.attachmentUrl}/${e.uuid}/bytes`,fileName:e.filename,fileDescription:e.comment,fileType:e.bytesContentFamily?.toLowerCase()}))}let uS={validate:(e,t)=>!ts(t)&&c.FU.includes(e.questionOptions.rendering)&&!(Array.isArray(t)?t:[t]).every(t=>e.questionOptions.answers?.find(e=>e.concept===t||e.value===t))?[{resultType:"error",errCode:"invalid.defaultValue",message:"Value not found in coded answers list"}]:ts(t)||"date"!=e.questionOptions.rendering||tr()(t).isValid()?!ts(t)&&"number"==e.questionOptions.rendering&&isNaN(t)?[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid numerical value: '${t}'`}]:[]:[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid date value: '${t}'`}]},uO=[],uD="testorder",uC="6f0c9a92-6f24-11e3-af88-005056821db0",uF={transformFieldValue:function(e,t,n){if(tp(e),"edit"===n.sessionMode&&e.meta.initialValue?.omrsObject)return uP(t,e,n.currentProvider.uuid);let r=uA(t,e,n.currentProvider.uuid);return tm(e,r,null),r},getInitialValue:function(e,t,n){let r=e.questionOptions.answers?.map(e=>e.concept)||[],i=t?.orders.filter(e=>!uO.includes(e.uuid)&&!e.voided).find(e=>r.includes(e.concept.uuid));return i?(e.meta={...e.meta||{},initialValue:{omrsObject:i,refinedValue:i.concept.uuid}},uO.push(i.uuid),i.concept.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){uO=[]}};function uA(e,t,n){return e?{action:"NEW",concept:e,type:t?.questionOptions?.orderType||uD,careSetting:t?.questionOptions?.orderSettingUuid||uC,orderer:n}:null}function uP(e,t,n){let r=t.meta.initialValue?.omrsObject;if(e===r?.concept?.uuid)return null;let i={uuid:r?.uuid,voided:!0};return tm(t,uA(e,t,n),i),t.meta.submission.newValue||null}let uT=[],uV={transformFieldValue:function(e,t,n){if(tp(e),e.meta.initialValue?.omrsObject&&ts(t))return tm(e,void 0,uN(e.meta.initialValue.omrsObject));if(!ts(t)){let r=e.meta.initialValue?.omrsObject;if(uI(r,t))return tm(e,uj(t,e,r,n.patient.id),void 0)}let r=uM(t,e,n.patient.id);return tm(e,r,null),r},getInitialValue:function(e,t,n){let r=(t??n.domainObjectValue).diagnoses.find(t=>t.formFieldPath===`rfe-forms-${e.id}`);return r?(e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r.diagnosis?.coded.uuid}},uT.includes(r.diagnosis?.coded?.uuid)||uT.push(r.diagnosis?.coded?.uuid),r.diagnosis?.coded.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){uT=[]}},uM=(e,t,n)=>e?{patient:n,condition:null,diagnosis:{coded:e},certainty:(0,np.H)(t.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:t.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${t.id}`,formFieldNamespace:"rfe-forms"}:null;function uj(e,t,n,r){return{patient:r,condition:null,diagnosis:{coded:e},certainty:(0,np.H)(t.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:t.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${t.id}`,formFieldNamespace:"rfe-forms",uuid:n.uuid}}function uI(e,t){return!ts(e)&&e.value!==t}function uN(e){return{uuid:e.uuid,voided:!0}}function uL(e,t,n,r,i){let{patient:o,formJson:a,domainObjectValue:l,formFields:s,visit:u,deletedFields:c}=e,d=[...s,...c],f=[];uY(f,d);let p=uQ(d),m=u4(d),h={};return l?(Object.assign(h,l),-1===h.encounterProviders.findIndex(e=>e.provider.uuid==r)&&(h.encounterProviders=[...h.encounterProviders,{provider:r,encounterRole:n}]),t&&(h.encounterDatetime=t),h.location=i,h.form={uuid:a.uuid},u&&(h.visit=u.uuid),h.obs=f,h.orders=p,h.diagnoses=m):(h={patient:o.id,location:i,encounterType:a.encounterType,encounterProviders:[{provider:r,encounterRole:n}],obs:f,form:{uuid:a.uuid},visit:u?.uuid,orders:p,diagnoses:m},t&&(h.encounterDatetime=t)),h}function uq(e,t){return e.filter(e=>"patientIdentifier"===e.type&&th(e)).map(e=>e.meta.submission.newValue)}function uR(e,t){return t.map(t=>(0,tj.savePatientIdentifier)(t,e.id))}function u$(e){return e.filter(e=>"personAttribute"===e.type&&th(e)).map(e=>e.meta.submission.newValue)}function uB(e,t){return t.map(t=>(0,tj.savePersonAttribute)(t,e.id))}function uH(e,t,n){let r=e.filter(e=>"programState"===e.type&&th(e)),i=new Map;return r.forEach(e=>{let r=e.questionOptions.programUuid,o=e.meta.submission.newValue,a=n.find(e=>e.program.uuid===r);a?i.has(r)?i.get(r).states.push(o):i.set(r,{uuid:a.uuid,states:[o]}):i.has(r)?i.get(r).states.push(o):i.set(r,{patient:t.id,program:r,states:[o],dateEnrolled:tr()().format()})}),Array.from(i.values())}function uz(e){let t=new AbortController;return Promise.all(e.map(e=>(0,tj.saveProgramEnrollment)(e,t)))}function uU(e,t,n){let r=e?.filter(e=>e?.questionOptions.rendering==="file"&&th(e));return r?.length?Promise.all(r.flatMap(e=>{let n="string"==typeof t?.patient?t?.patient:t?.patient?.uuid;return(e.meta.submission.newValue??[]).map(e=>(0,tj.createAttachment)(n,t.uuid,e))})):[]}function uW(e){let{formFields:t,location:n,currentProvider:r,customDependencies:i,sessionDate:o,domainObjectValue:a,visit:l}=e,{defaultEncounterRole:s}=i,u=t.find(e=>"encounterRole"===e.type)?.meta.submission?.newValue||s?.uuid,c=t.find(e=>"encounterProvider"===e.type)?.meta.submission?.newValue||r.uuid,d=t.find(e=>"encounterDatetime"===e.type)?.meta.submission?.newValue,f=l?.stopDatetime?o:void 0;return{encounterRole:u,encounterProvider:c,encounterDate:d??(a?.encounterDatetime?new Date(a.encounterDatetime):f),encounterLocation:t.find(e=>"encounterLocation"===e.type)?.meta.submission?.newValue||a?.location?.uuid||n.uuid}}function uY(e,t){t.filter(e=>u0(e)).forEach(n=>uJ(e,n,t))}function uJ(e,t,n){uX(t)&&t.meta.initialValue.omrsObject?uG(e,t):"obsGroup"===t.type?uZ(e,t,n):(tf(t,"file")||uK(e,t.meta.submission.newValue),uK(e,t.meta.submission.voidedValue))}function uZ(e,t,n){if(t.meta.submission?.voidedValue)return void uK(e,t.meta.submission.voidedValue);let r=ug(t,null);t.meta.initialValue?.omrsObject&&(r.uuid=t.meta.initialValue.omrsObject.uuid),t.questions.forEach(e=>{let t=n.find(t=>t.id===e.id)??e;if(uX(t))uG(r.groupMembers,t);else if("obsGroup"===t.type){let e=[];uZ(e,t,n),uK(r.groupMembers,e)}else th(t)&&(uK(r.groupMembers,t.meta.submission.newValue),uK(r.groupMembers,t.meta.submission.voidedValue))}),(r.groupMembers?.length||r.voided)&&uK(e,r)}function uG(e,t){let n=t.meta.initialValue?.omrsObject;n&&uK(e,(Array.isArray(n)?n:[n]).map(e=>uy(e)))}function uQ(e){return e.filter(e=>"testOrder"===e.type&&th(e)).flatMap(e=>uX(e)?[e.meta.submission.newValue?void 0:e.meta.submission.voidedValue]:[e.meta.submission.newValue,e.meta.submission.voidedValue]).filter(e=>e)}function uK(e,t){t&&(Array.isArray(t)?e.push(...t):e.push(t))}function uX(e){return!!(e.isHidden||e.isParentHidden)}function u0(e){let{questionOptions:{isTransient:t},type:n}=e;return!t&&!!["obs","obsGroup"].includes(n)&&!e.meta.groupId&&(!!(uX(e)&&e.meta.initialValue?.omrsObject)||!uX(e)&&("obsGroup"===n||th(e)))}function u1(e){if("toggle"==e.questionOptions.rendering&&"boolean"!=typeof e.questionOptions.defaultValue)return e.questionOptions.defaultValue==c.t$;let t=uS.validate(e,e.questionOptions.defaultValue);return t.length?(console.error(`Default value validation errors for field "${e.id}" with value "${e.questionOptions.defaultValue}":`,t),null):e.questionOptions.defaultValue}async function u2(e,t,n,r){let i=1,{formFieldAdapters:o}=r,a=t.obs.filter(t=>t.concept.uuid===e.questionOptions.concept&&t.uuid!=e.meta.initialValue?.omrsObject?.uuid&&!up.includes(t.uuid)),l=t.orders.filter(t=>(e.questionOptions.answers?.map(e=>e.concept)||[]).includes(t.concept?.uuid)&&!uO.includes(t.uuid));if("testOrder"===e.type)return Promise.all(l.filter(e=>!e.voided).map(async t=>{let a=uc(e,t,i++);return n[a.id]=await o[e.type].getInitialValue(a,{orders:[t]},r),a}));let s=t.diagnoses.filter(t=>!t.voided&&!uT.includes(t?.diagnosis?.coded.uuid)&&t.formFieldPath.startsWith(`rfe-forms-${e.id}_`));return"diagnosis"===e.type?Promise.all(s.map(async t=>{let i=parseInt(t.formFieldPath.split("_")[1]),a=uc(e,t,i);return n[a.id]=await o[e.type].getInitialValue(a,{diagnoses:[t]},r),uT.includes(t.diagnosis.coded.uuid)||uT.push(t.diagnosis.coded.uuid),a})):Promise.all(a.map(async t=>{let a=uc(e,t,i++);return await Promise.all(a.questions.map(async i=>{n[i.id]=await o[e.type].getInitialValue(i,{obs:[t]},r)})),up.push(t.uuid),[a,...a.questions]})).then(e=>e.flat())}function u4(e){return e.filter(e=>"diagnosis"===e.type&&th(e)).map(e=>uX(e)?e.meta.submission.newValue?void 0:e.meta.submission.voidedValue:e.meta.submission.newValue||e.meta.submission.voidedValue).filter(e=>e)}function u5(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u3{getDomainObject(){return this.domainObjectValue}async loadDependencies(e,t,n){return Promise.resolve({})}constructor(e){u5(this,"formJson",void 0),u5(this,"domainObjectValue",void 0),this.formJson=e}}var u6=n(1807),u9=n(7361),u7=n(6956),u8=n(7313),ce="[object String]";let ct=function(e){return"string"==typeof e||!(0,u7.A)(e)&&(0,u8.A)(e)&&(0,u9.A)(e)==ce};function cn(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!0),[o,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let t=new AbortController;return!ts(e.encounter)&&ct(e.encounter)?(0,u.openmrsFetch)(`${u.restBaseUrl}/encounter/${e.encounter}?v=${c.RZ}`,{signal:t.signal}).then(e=>{n(e.data),i(!1)}).catch(e=>{a(e)}):(ts(e.encounter)||n(e.encounter),i(!1)),()=>{t.abort()}},[e.encounter]),{encounter:t,error:o,isLoading:r}}var cr=n(3660),ci=n.n(cr);function co(){let{data:e,error:t,isLoading:n}=ci()(`${u.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,u.openmrsFetch),r=e?.data.results.find(e=>"Clinician"===e.name);return r?{encounterRole:r,error:t,isLoading:n}:{encounterRole:e?.data.results[0],error:t,isLoading:n}}var ca=n(1619),cl=n.n(ca);let cs=e=>{let t="custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(startDate,endDate,state:(uuid,name,retired,concept:(uuid),programWorkflow:(uuid)))",n=`${u.restBaseUrl}/programenrollment?patient=${e}&v=${t}`,{data:r,error:i,isLoading:o}=cl()(e?n:null,u.openmrsFetch),a=r?.data?.results.length>0?r?.data.results.sort((e,t)=>t.dateEnrolled>e.dateEnrolled?1:-1):null;return{activePrograms:a?.filter(e=>!e.dateCompleted),error:i,isLoading:o}},cu=(e,t)=>{let{activePrograms:n,error:r,isLoading:i}=cs(t.meta?.programs?.hasProgramFields?e:null);return{patientPrograms:n,errorFetchingPatientPrograms:r,isLoadingPatientPrograms:i}};function cc(e){let[t,n]=(0,d.useState)(!0),{encounter:r,isLoading:i}=cn(e.formJson),{encounterRole:o,isLoading:a}=co(),{isLoadingPatientPrograms:l,patientPrograms:s}=cu(e.patient?.id,e.formJson);return(0,d.useEffect)(()=>{n(l||i||a)},[l,i,a]),{data:{encounter:r,patientPrograms:s,encounterRole:o},isLoading:t,error:null,updateContext:(t,{setDomainObjectValue:n,setCustomDependencies:i})=>{e.processor.domainObjectValue=r,n(r),i(e=>({...e,patientPrograms:s,defaultEncounterRole:o}))}}}let cd={checkbox:[],toggle:!1,text:""},cf=["encounterProvider","encounterDatetime","encounterLocation","patientIdentifier","encounterRole","programState","personAttribute"];class cp extends u3{prepareFormSchema(e){let t=new Set;function n(e,r,i,o){e.id&&t.add(e.id),e.inlineRendering=e.inlineRendering??r.inlineRendering??i.inlineRendering??o.inlineRendering,e.readonly=e.readonly??r.readonly??i.readonly??o.readonly,e.questionOptions?.rendering!="fixed-value"||e.meta.fixedValue||(e.meta.fixedValue=e.value,delete e.value),(e.questionOptions?.rendering=="group"||"obsGroup"===e.type)&&e.questions?.forEach(t=>(t.readonly=t.readonly??e.readonly,n(t,r,i,o)))}return e.pages.forEach(t=>{t.sections.forEach(r=>{r.questions.forEach(i=>{n(i,r,t,e)})})}),ch(e,t),e}async processSubmission(e,t){let{encounterRole:n,encounterProvider:r,encounterDate:i,encounterLocation:o}=uW(e),a=(e,t,n)=>(0,u.translateFrom)(u6.L,e,t,n),l=uq(e.formFields,o),s=uL(e,i,n,r,o);try{await Promise.all(uR(e.patient,l)),l?.length&&(0,u.showSnackbar)({title:a("patientIdentifiersSaved","Patient identifier(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPatientIdentifiers","Error saving patient identifiers"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let t=u$(e.formFields);await Promise.all(uB(e.patient,t)),t?.length&&(0,u.showSnackbar)({title:a("personAttributesSaved","Person attribute(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPersonAttributes","Error saving person attributes"),description:e.join(", "),kind:"error",critical:!0})}try{let t=uH(e.formFields,e.patient,e.customDependencies.patientPrograms),n=await await uz(t);n?.length&&(0,u.showSnackbar)({title:a("patientProgramsSaved","Patient program(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingPatientPrograms","Error saving patient program(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let{data:n}=await (0,tj.saveEncounter)(t,s,s.uuid),r=n.orders.map(e=>e.orderNumber),i=n.diagnoses.map(e=>e.display);r.length&&(0,u.showSnackbar)({title:a("ordersSaved","Order(s) saved successfully"),subtitle:r.join(", "),kind:"success",isLowContrast:!0}),i.length&&(0,u.showSnackbar)({title:a("diagnosisSaved","Diagnosis(es) saved successfully"),subtitle:i.join(", "),kind:"success",isLowContrast:!0});try{let r=await uU(e.formFields,n,t);r?.length&&(0,u.showSnackbar)({title:a("attachmentsSaved","Attachment(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){console.error("Error saving attachments",t);let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingAttachments","Error saving attachment(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}return n}catch(t){console.error("Error saving encounter",t);let e=(0,ns.j)(t);return Promise.reject({title:a("errorSavingEncounter","Error saving encounter"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}}getCustomHooks(){return{useCustomHooks:cc}}async getInitialValues(e){let{domainObjectValue:t,formFields:n,formFieldAdapters:r}=e,i={},o=[];if(t){await Promise.all(n.map(async n=>{let a=r[n.type];if(n.meta.initialValue?.omrsObject&&!ts(n.meta.initialValue.refinedValue)){i[n.id]=n.meta.initialValue.refinedValue;return}if(a){tf(n,"repeating")&&!n.meta?.repeat?.isClone&&o.push(n);let r=null;try{r=await a.getInitialValue(n,t,e),n.meta.initialValue.refinedValue=r}catch(e){console.error(e)}if("obsGroup"===n.type)return;if(ts(r)?ts(n.questionOptions.defaultValue)?i[n.id]=cd[n.questionOptions.rendering]??"":i[n.id]=u1(n):i[n.id]=r,n.questionOptions.calculate?.calculateExpression)try{await cm(n,i,e)}catch(e){console.error(e)}}else console.warn(`No adapter found for field type ${n.type}`)}));let a=await Promise.all(o.flatMap(n=>u2(n,t,i,e))).then(e=>e.flat());n.push(...a)}else{let t=n.filter(e=>"group"!==e.questionOptions.rendering&&"obsGroup"!==e.type),o=[];await Promise.all(t.map(async t=>{let n=r[t.type];if(i[t.id]=cd[t.questionOptions.rendering]??null,ts(i[t.id])&&cf.includes(t.type))try{i[t.id]=await n.getInitialValue(t,null,e)}catch(e){console.error(e)}t.questionOptions.defaultValue&&(i[t.id]=u1(t)),t.questionOptions.calculate?.calculateExpression&&o.push(t)})),await Promise.all(o.map(async t=>{try{await cm(t,i,e)}catch(e){console.error(e)}}))}return i}async loadDependencies(e,t,{setPreviousDomainObjectValue:n}){let{patient:r,formJson:i}=e;return n(await (0,tj.getPreviousEncounter)(r?.id,i.encounterType)),e}async getHistoricalValue(e,t){let{formFields:n,sessionMode:r,patient:i,methods:{getValues:o},formFieldAdapters:a,previousDomainObjectValue:l,visit:s}=t,u={value:e,type:"field"},c=a[e.type];if(e.historicalExpression){let t=await t1(e.historicalExpression,u,n,o(),{mode:r,patient:i,previousEncounter:l,visit:s});return t?nr(e,t):null}return l&&e.questionOptions.enablePreviousValue?await c.getPreviousValue(e,l,t):null}}async function cm(e,t,n){let{formFields:r,sessionMode:i,patient:o,visit:a}=n,l=e.questionOptions.calculate.calculateExpression,s={value:e,type:"field"},u={mode:i,patient:o,visit:a},c=await t1(l,s,r,t,u);ts(c)||(t[e.id]=c)}function ch(e,t){let n=/(['"])([a-zA-Z_][a-zA-Z0-9_]*)\1/g;function r(e,r){for(let i of e.matchAll(n)){let e=i[2];t.has(e)&&console.error(`The calculateExpression for the field '${r}' incorrectly quotes the field ID '${e}' as a string. Field IDs must be referenced as variables without quotes to access their values. Remove the quotes: use ${e} instead of '${e}'.`)}}function i(e){e.questionOptions?.calculate?.calculateExpression&&r(e.questionOptions.calculate.calculateExpression,e.id),e.questions&&e.questions.forEach(i)}e.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(i)})})}var cg=n(9804);function cy(e){let{formFields:t,formFieldValidators:n,patient:r,sessionMode:i,addInvalidField:o,updateFormField:a,methods:{getValues:l,trigger:s}}=e,u=l();return 0===t.filter(e=>!e.isHidden&&!e.isParentHidden&&!e.isDisabled&&!e.meta.submission?.unspecified).flatMap(e=>e.validators?.flatMap(l=>{let s=n[l.type];if(s){let n=s.validate(e,u[e.id],{formFields:t,values:u,expressionContext:{patient:r,mode:i},...l}).filter(e=>"error"===e.resultType);return n.length&&(e.meta.submission={...e.meta.submission,errors:n},a(e),o(e)),n}})).filter(e=>!!e).length}async function cv(e,t,n,r,i){return Promise.all(e.map(async({postAction:e,config:o,actionId:a,enabled:l})=>{try{let i=[];if(t)if(t.forEach(e=>{e?.data&&i.push(e.data),e?.uuid&&i.push(e)}),i.length)(!l||(0,cg.g)(l,i))&&await e.applyAction({patient:n,sessionMode:r,encounters:i},o);else throw Error("No encounter data to process post submission action");else throw Error("No handlers available to process post submission action")}catch(t){let e=(0,ns.j)(t);(0,u.showSnackbar)({title:String(i("errorDescriptionTitle",a?a.replace(/([a-z])([A-Z])/g,"$1 $2"):"Post Submission Error")),subtitle:String(i("errorDescription","{{errors}}",{errors:e.join(", ")})),kind:"error",isLowContrast:!1})}}))}function cb({patientUuid:e,formUuid:t,setIsSubmitting:n,setIsValidating:r}){let{t:i}=(0,e9.useTranslation)();(0,d.useEffect)(()=>{let o=o=>{let{formUuid:a,patientUuid:l,action:s}=o.detail;if(!s||!a||!l)return void(0,ns.N)(Error("The form action event is missing required details (formUuid, patientUuid, or action)."),i("formActionFailed","Form action failed"));if(a===t&&l===e)switch(s){case"onSubmit":n(!0);break;case"validateForm":r(!0);break;default:(0,ns.N)(Error(`Unsupported form action: "${s}"`),i("formActionFailed","Form action failed"))}};return window.addEventListener("ampath-form-action",o),()=>{window.removeEventListener("ampath-form-action",o)}},[n,r,t,e])}function c_(e){let[t,n]=(0,d.useState)([]);return(0,d.useEffect)(()=>{let t=[];e?.length&&e.map(e=>{let n="string"==typeof e?e:e.actionId;dC(n)?.then(r=>t.push({postAction:r,config:e.config,actionId:n,enabled:e.enabled}))}),n(t)},[e]),t}let cw=(0,d.createContext)(void 0),cx=({patient:e,patientUUID:t,sessionMode:n,sessionDate:r,formJson:i,workspaceLayout:o,location:a,provider:l,visit:s,isFormExpanded:c=!0,children:p,isLoadingDependencies:m=!1,formSubmissionProps:h,hideFormCollapseToggle:g,handleConfirmQuestionDeletion:y,setIsFormDirty:v})=>{let{t:b}=(0,e9.useTranslation)(),_=(0,d.useRef)(void 0),w=(0,d.useRef)({}),x=(0,u.useLayoutType)(),{isSubmitting:E,setIsSubmitting:k,onSubmit:S,onError:O,handleClose:D}=h,[C,F]=(0,d.useState)(!1),A=c_(i.postSubmissionActions),P=new AbortController,T=(0,d.useCallback)((e,t,n)=>{t?w.current[e]=n:_.current=n},[]),V=(0,d.useRef)({EncounterFormProcessor:cp}),M=(0,d.useCallback)(()=>{let e=[_.current,...Object.values(w.current)],t=e.every(e=>cy(e));return{forms:e,isValid:t}},[]);return cb({patientUuid:t,formUuid:i?.uuid,setIsSubmitting:k,setIsValidating:F}),(0,d.useEffect)(()=>{C&&(m||M(),F(!1))},[C,M,m]),(0,d.useEffect)(()=>{if(E){if(m)return void k(!1);let{forms:t,isValid:r}=M();r?Promise.all(t.map(e=>e.processor.processSubmission(e,P))).then(async t=>{h.setIsSubmitting(!1),"edit"===n?(0,u.showSnackbar)({title:b("updatedRecord","Record updated"),subtitle:b("updatedRecordDescription","The patient encounter was updated"),kind:"success",isLowContrast:!0}):(0,u.showSnackbar)({title:b("submittedForm","Form submitted"),subtitle:b("submittedFormDescription","Form submitted successfully"),kind:"success",isLowContrast:!0}),A&&await cv(A,t,e,n,b),g(),S?S(t):D()}).catch(e=>{k(!1),e instanceof Error?(0,u.showSnackbar)({title:b("errorProcessingFormSubmission","Error processing form submission"),kind:"error",subtitle:e.message,isLowContrast:!1}):(0,u.showSnackbar)(e)}):k(!1)}return()=>{P.abort()}},[E,M,m]),f().createElement(cw.Provider,{value:{patient:e,sessionMode:n,sessionDate:r,formJson:i,formProcessors:V.current,layoutType:x,workspaceLayout:o,visit:s,location:a,provider:l,isFormExpanded:c,registerForm:T,handleConfirmQuestionDeletion:y,setIsFormDirty:v}},V.current&&p)},cE=()=>{let e=(0,d.useContext)(cw);if(!e)throw Error("useFormFactoryContext must be used within a FormFactoryProvider");return e},ck={actionButtons:"-esm-form-engine__repeat-controls__actionButtons___RPDJa"},cS=function({question:e,rows:t,handleDelete:n,handleAdd:r,questionIndex:i}){let{t:o}=(0,e9.useTranslation)();return f().createElement("div",{className:ck.actionButtons},i>0&&f().createElement(y.Button,{className:ck.button,kind:"danger",onClick:n},f().createElement("span",null,o("remove","Remove"))),i===t.length-1&&f().createElement(y.Button,{className:ck.button,iconDescription:o("add","Add"),kind:"primary",disabled:uf(e.questionOptions.repeatOptions?.limit,t.length),onClick:r},f().createElement("span",null,e.questionOptions.repeatOptions?.addText||o("add","Add"))))},cO="-esm-form-engine__repeat__nodeContainer___WpV+2",cD="-esm-form-engine__repeat__divider___m-qDa",cC={obsGroup:"group",testOrder:"select",diagnosis:"ui-select-extended"};function cF(e){return e.questions?.length?e.questions?.some(e=>!e.isHidden):!e.isHidden}function cA(e){return{...e,questionOptions:{...e.questionOptions,rendering:cC[e.type]||null}}}let cP=({field:e})=>{let[t,n]=(0,d.useState)([]),r=ng(),{handleConfirmQuestionDeletion:i}=cE(),{patient:o,sessionMode:a,formFieldAdapters:l,formFields:s,methods:{getValues:c,setValue:p,unregister:m},addFormField:h,removeFormField:g,deletedFields:y,setDeletedFields:v,visit:b}=r;(0,d.useEffect)(()=>{n(s.filter(t=>t.questionOptions.concept===e.questionOptions.concept&&t.id.startsWith(e.id)&&!t.meta?.repeat?.wasDeleted))},[s,e]);let _=(0,d.useCallback)(i=>{let u=[];function d(e){e.hide?.hideWhenExpression&&(e.isHidden=t0(e.hide.hideWhenExpression,{value:e,type:"field"},[...s,...u],c(),{mode:a,patient:o,visit:b})),e.questionOptions.calculate?.calculateExpression&&t1(e.questionOptions.calculate?.calculateExpression,{value:e,type:"field"},[...s,...u],c(),{mode:a,patient:o,visit:b}).then(t=>{ts(t)||(p(e.id,t),l[e.type]?.transformFieldValue(e,t,r))})}let f=uc(e,null,i);u.push(f),"obsGroup"===f.type&&f.questions?.forEach(e=>{u.push(e)}),u.forEach(e=>{d(e),h(e)}),n([...t,f])},[s,e,t,r]),w=e=>{e.meta.initialValue?.omrsObject?(l[e.type]?.transformFieldValue(e,null,r),e.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},"obsGroup"===e.type&&e.questions.forEach(t=>{t.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},l[t.type]?.transformFieldValue(t,null,r)})):(tp(e),m(e.id),e.questions?.forEach(e=>m(e.id))),n(t.filter(t=>t.id!==e.id)),v([...y,e]),g(e.id)},x=e=>{if(i&&"function"==typeof i){let t=i(e);t&&"function"==typeof t.then&&"function"==typeof t.catch?t.then(()=>w(e)).catch(()=>(0,u.createErrorHandler)()):"boolean"==typeof t?t&&w(e):w(e)}else w(e)},E=(0,d.useMemo)(()=>t.map((n,r)=>{let i=f().createElement(nT,{fieldId:n.id,valueAdapter:l[n.type],repeatOptions:{targetRendering:cA(n).questionOptions.rendering}});return f().createElement("div",{key:n.id+"_wrapper"},0!==r&&f().createElement("div",null,f().createElement("hr",{className:cD})),f().createElement("div",{className:cO},i),!tg(a)&&f().createElement(cS,{question:n,rows:t,questionIndex:r,handleDelete:()=>{x(n)},handleAdd:()=>{_(t.reduce((t,n)=>{let r=Number(n.id.slice(e.id.length+1));return Number.isFinite(r)?Math.max(t,r):t},0)+1)}}))}),[t]);return!e.isHidden&&E&&cF(e)?f().createElement(f().Fragment,null,f().createElement("div",null,E)):null};var cT=n(5848);let cV={label:"-esm-form-engine__file__label___rUrrs",thumbnailGrid:"-esm-form-engine__file__thumbnailGrid___FRMXX",thumbnailContainer:"-esm-form-engine__file__thumbnailContainer___4S7Rq"},cM="-esm-form-engine__file-thumbnail__thumbnail___AGjAZ",cj="-esm-form-engine__file-thumbnail__imageThumbnail___nKfAe",cI="-esm-form-engine__file-thumbnail__pdfThumbnail___CfkjD",cN="-esm-form-engine__file-thumbnail__removeButton___DhEu3",cL="-esm-form-engine__file-thumbnail__closeIcon___zKRmf";var cq=n(529),cR=n(1899);function c$({bytesContentFamily:e,removeFileCb:t,...n}){let r=(0,d.useMemo)(()=>{switch(e){case"image":return cB;case"pdf":return cH;default:return cz}},[]);return f().createElement("div",{className:cM},f().createElement(r,n),f().createElement(y.Button,{kind:"ghost",className:cN,onClick:t},f().createElement(cq.bm,{size:16,className:cL})))}function cB(e){return f().createElement("img",{className:cj,src:e.src,alt:e.title})}function cH(e){return f().createElement("div",{className:cI,role:"button",tabIndex:0},f().createElement(cR.aD,{size:24}))}function cz(e){return f().createElement("div",{className:cI,role:"button",tabIndex:0},f().createElement(cR.WZ,{size:24}))}let cU=[{name:"drug",baseControlComponent:ur},{name:"problem",baseControlComponent:ur},{name:"encounter-provider",baseControlComponent:ur},{name:"encounter-location",baseControlComponent:ur},{name:"select-concept-answers",baseControlComponent:ur},{name:"encounter-role",baseControlComponent:ur}],cW=[{name:"text",component:sL},{name:"textarea",component:sI},{name:"select",component:sM},{name:"checkbox",component:sD},{name:"radio",component:sT},{name:"date",component:n8},{name:"datetime",component:n8},{name:"number",component:sF},{name:"content-switcher",component:n2},{name:"toggle",component:sR},{name:"workspace-launcher",component:us},{name:"group",component:nN},{name:"repeating",component:cP},{name:"markdown",component:sS},{name:"fixed-value",component:re},{name:"ui-select-extended",component:ur},{name:"file",component:({field:e,value:t,setFieldValue:n})=>{let{t:r}=(0,e9.useTranslation)(),{sessionMode:i}=ng(),o="tablet"===(0,u.useLayoutType)(),a=(0,d.useCallback)(()=>{let r=(0,u.showModal)("capture-photo-modal",{saveFile:e=>(e.capturedFromWebcam&&!e.fileName.includes(".")&&(e.fileName=`${e.fileName}.png`),n([...t||[],e]),r(),Promise.resolve()),closeModal:()=>{r()},allowedExtensions:e.questionOptions.allowedFileTypes,multipleFiles:e.questionOptions.allowMultiple,collectDescription:!0})},[t,e]),l=(0,d.useCallback)(e=>{let r=[...t],i=r[e];i.uuid?r[e]={...i,voided:!0}:r.splice(e,1),n(r)},[t]);return tg(i)&&!t?f().createElement(nU,{label:r(e.label),value:null,conceptName:e.meta.concept?.display,isInline:!1}):f().createElement("div",null,f().createElement("div",{className:m()(cV.label,"cds--label")},f().createElement(n1,{field:e})),!tg(i)&&f().createElement("div",null,f().createElement(y.Button,{className:cV.uploadButton,kind:o?"ghost":"tertiary",onClick:a,renderIcon:e=>f().createElement(cT.OM,{size:16,...e})},e.questionOptions.buttonLabel?r(e.questionOptions.buttonLabel):r("addFile","Add file"))),f().createElement("div",{className:cV.thumbnailGrid},t&&t.filter(e=>!e.voided).map((e,t)=>f().createElement("div",{className:cV.thumbnailContainer},f().createElement(c$,{title:e.fileName,src:e.base64Content,bytesContentFamily:e.fileType,removeFileCb:()=>l(t)})))))}},...s3.map(e=>({name:e.name,component:cU.find(t=>t.name===e.name).baseControlComponent}))],cY={validate:(e,t,n)=>{let r=new Date,i=t?[]:ta.validate(e,t);return i.length?i:t&&!(0,np.H)(n?.allowFutureDates)&&t.getTime&&t.getTime()>r.getTime()?[{resultType:"error",errCode:"value.invalid",message:"Future dates not allowed"}]:[]}},cJ=[{name:"default_value",component:uS},{name:"form_field",component:ta},{name:"date",component:cY},{name:"js_expression",component:{validate:function(e,t,n){let r="value.invalid",i="Invalid value",o="Field has warnings";return n.expressionContext.myValue=t,Object.keys(n).filter(e=>"failsWhenExpression"===e||"warnsWhenExpression"===e).flatMap(a=>{let l="failsWhenExpression"===a;return t0(n[a],{value:e,type:"field"},n.formFields,{...n.values,[e.id]:t},n.expressionContext)?[{resultType:l?"error":"warning",errCode:l?r:null,message:n.message?n.message:l?i:o}]:[]})}}},{name:"conditionalAnswered",component:{validate:function(e,t,n){let{referenceQuestionId:r,referenceQuestionAnswers:i,values:o,formFields:a,message:l}=n,s=o[a.find(e=>e.id===r).id];return ts(t)||i.includes(s)?[]:[{resultType:"error",errCode:"invalid.valueSelected",message:l}]}}}];function cZ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class cG{fetchData(e){return(0,u.openmrsFetch)(e?`${this.url}&q=${e}`:this.url).then(({data:e})=>e.results)}fetchSingleItem(e){let t=this.url;if(t.includes("?")){let n=t.split("?");t=`${n[0]}/${e}?${n[1]}`}else t=`${t}/${e}`;return(0,u.openmrsFetch)(t).then(({data:e})=>e)}toUuidAndDisplay(e){if(void 0===e.uuid||void 0===e.display)throw Error("'uuid' or 'display' not found in the OpenMRS object.");return e}constructor(e){cZ(this,"url",void 0),this.url=e}}let cQ="custom:(uuid,display,conceptClass:(uuid,display))",cK="custom:(uuid,display,conceptClass:(uuid,display),mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid))))",cX="35543629-7d8c-11e1-909d-c80aa9edcf4e";class c0 extends cG{fetchData(e,t){if(ts(t?.class)&&ts(t?.concept)&&!t?.useSetMembersByConcept&&ts(e))return Promise.resolve([]);let n=t?.conceptSourceUuid?cK:cQ,r=`${u.restBaseUrl}/concept?name=&searchType=fuzzy&v=${n}`;if(t?.class)if("string"!=typeof t.class)return(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results.filter(e=>e.conceptClass&&t.class.includes(e.conceptClass.uuid)));else{let e=r.split("searchType=fuzzy");r=`${e[0]}searchType=fuzzy&class=${t.class}&${e[1]}`}if(t?.concept&&t?.useSetMembersByConcept){let n=r.split("?name=&searchType=fuzzy&v="),i=t?.conceptSourceUuid?"custom:(uuid,setMembers:(uuid,display,mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid)))))":"custom:(uuid,setMembers:(uuid,display))";return r=`${n[0]}/${t.concept}?v=${i}`,(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.setMembers)}return(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results)}fetchSingleItem(e,t){let n=t?.conceptSourceUuid?cK:cQ;return(0,u.openmrsFetch)(`${u.restBaseUrl}/concept/${e}?v=${n}`).then(({data:e})=>e)}toUuidAndDisplay(e,t){let n=super.toUuidAndDisplay(e),r=this.getConceptSourceMapping(e,t?.conceptSourceUuid)?.conceptReferenceTerm?.code;return r?{...n,code:r}:n}getConceptSourceMapping(e,t){if(!t)return;let n=e.mappings?.filter(e=>e.conceptReferenceTerm?.conceptSource?.uuid===t)??[];return n.find(e=>e.conceptMapType?.uuid===cX||e.conceptMapType?.display?.toUpperCase()==="SAME-AS")??n[0]}constructor(){super(`${u.restBaseUrl}/concept?v=${cQ}`)}}class c1 extends cG{fetchData(e,t,n){let r=this.url,i=r.split("?");return t?.tag&&(r=`${i[0]}?tag=${t.tag}&${i[1]}`),n&&(r=`${i[0]}/${n}?${i[1]}`),(0,u.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results?e.results:e)}constructor(){super(`${u.restBaseUrl}/location?v=custom:(uuid,display)`)}}class c2 extends cG{async fetchData(e,t){let n="v=custom:(uuid,display)",r=`${u.restBaseUrl}/provider?${n}`,{data:i}=await (0,u.openmrsFetch)(e?`${r}&q=${e}`:r);return i?.results}async fetchSingleItem(e){let{data:t}=await (0,u.openmrsFetch)(`${u.restBaseUrl}/provider/${e}?v=custom:(uuid,display)`);return t}constructor(){super(null)}}class c4 extends cG{fetchSingleItem(e){return(0,u.openmrsFetch)(this.buildUrl(e)).then(({data:e})=>e)}fetchData(e,t){let n=this.buildUrl(t.referencedValue||t.concept);return(0,u.openmrsFetch)(n).then(({data:e})=>e.setMembers.length?e.setMembers:e.answers)}buildUrl(e){return this.url.replace(":conceptUuid",e)}constructor(){super(`${u.restBaseUrl}/concept/:conceptUuid?v=custom:(uuid,display,setMembers:(uuid,display),answers:(uuid,display))`)}}class c5 extends cG{async fetchData(e,t){let n="v=custom:(uuid,display,name)",r=`${u.restBaseUrl}/encounterrole?${n}`,{data:i}=await (0,u.openmrsFetch)(e?`${r}&q=${e}`:r);return i?.results}constructor(){super(null)}}let c3=[{name:"location_datasource",component:new c1},{name:"drug_datasource",component:new c0},{name:"problem_datasource",component:new c0},{name:"select_concept_answers_datasource",component:new c4},{name:"provider_datasource",component:new c2},{name:"encounter_role_datasource",component:new c5}],c6=[{name:"ProgramEnrollmentSubmissionAction",load:()=>n.e("8720").then(n.bind(n,3696))},{name:"MarkPatientAsDeceasedAction",load:()=>n.e("5897").then(n.bind(n,8128))}];function c9(e,t,n){if("programState"===e.type){let e=n.meta??{};e.programs=e.programs?{...e.programs,hasProgramFields:!0}:{hasProgramFields:!0},n.meta=e}try{c8(e),dt(e),dn(e),dr(e),e.questions?.length&&("obsGroup"===e.type&&e.questions.length?e.questions.forEach(e=>c9(e,t,n)):e.questions.forEach(e=>c9(e,t,n))),e.meta.pageId=t.id}catch(e){console.error(e)}}function c7(e){let t=[];return e?.forEach(e=>{if(t.push(e),"inlineDate"!==e.type&&(0,np.H)(e.questionOptions?.showDate)){let n={id:`${e.id}_inline_date`,label:`Date for ${e.label}`,type:"inlineDate",questionOptions:{rendering:"date",isTransient:!0},validators:e.questionOptions.shownDateOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownDateOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.obsDatetime}}};t.push(n)}}),t}function c8(e){de(e,"readonly"),de(e,"required"),de(e,"unspecified"),de(e.questionOptions,"disallowDecimals"),de(e.questionOptions,"isSearchable"),de(e.questionOptions,"isTransient"),de(e.questionOptions,"enablePreviousValue"),de(e.questionOptions,"allowMultiple"),e.meta||(e.meta={submission:null,initialValue:{omrsObject:null,refinedValue:null}})}function de(e,t){if(e&&"string"==typeof e[t]){let n=e[t].trim().toLowerCase();("true"===n||"false"===n)&&(e[t]="true"===n)}return e}function dt(e){!tf(e,"group")&&(e.validators=e.validators||[],0>e.validators.findIndex(e=>"form_field"===e.type)&&e.validators.push({type:"form_field"}),0>e.validators.findIndex(e=>"default_value"===e.type)&&e.validators.push({type:"default_value"}))}function dn(e){switch(e.type){case"encounterProvider":e.questionOptions.rendering="encounter-provider";break;case"encounterLocation":e.questionOptions.rendering="encounter-location";break;case"encounterRole":e.questionOptions.rendering="encounter-role";break;case"encounterDatetime":e.questionOptions.rendering=tf(e,"ui-select-extended")?"date":e.questionOptions.rendering;break;case"diagnosis":dc(e)}}function dr(e){switch(e.questionOptions.rendering){case"checkbox-searchable":case"multiCheckbox":di(e);break;case"numeric":e.questionOptions.rendering="number";break;case"select-concept-answers":dl(e);break;case"repeating":case"group":da(e);break;case"date":e.datePickerFormat=e.datePickerFormat??"calendar";break;case"datetime":e.datePickerFormat=e.datePickerFormat??"both";break;case"workspace-launcher":case"markdown":e.type="control";break;case"drug":case"problem":e.questionOptions.isSearchable=!0}return e}function di(e){"multiCheckbox"===e.questionOptions.rendering&&(e.questionOptions.rendering="checkbox-searchable",(0,np.H)(e.inlineMultiCheckbox)&&(e.questionOptions.rendering="checkbox")),tf(e,"checkbox-searchable")&&(e.questionOptions.rendering="checkbox",e.questionOptions.isCheckboxSearchable=!0)}function da(e){tf(e,"group")&&e.questions?.length&&e.questions.forEach(da),"testOrder"===e.type&&e.questionOptions.selectableOrders?.length&&(e.questionOptions.answers=e.questionOptions.selectableOrders||[],delete e.questionOptions.selectableOrders)}function dl(e){e.questionOptions.isSearchable=!0,e.questionOptions.datasource?.config||(e.questionOptions.datasource={name:"select_concept_answers_datasource",config:{concept:e.questionOptions.concept}})}function ds(e){if(e.meta.programs.isEnrollment||e.meta.programs.discontinuationDateQuestionId){let t={programUuid:e.meta.programs.uuid};e.meta.programs.isEnrollment?t.enrollmentDate="":t.completionDate=e.meta.programs.discontinuationDateQuestionId,e.postSubmissionActions=[{actionId:"ProgramEnrollmentSubmissionAction",enabled:"true",config:t}]}}function du(e){let t=[];return e?.forEach(e=>{if(t.push(e),"obsComment"!==e.type&&(0,np.H)(e.questionOptions?.showComment)){let n={id:`${e.id}_obs_comment`,label:`Comment for ${e.label}`,type:"obsComment",questionOptions:{rendering:"text",isTransient:!0},validators:e.questionOptions.shownCommentOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownCommentOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.comment}}};t.push(n)}}),t}function dc(e){if("dataSource"in e.questionOptions&&"diagnoses"===e.questionOptions.dataSource||"diagnosis"===e.type){let t=e.questionOptions.datasource?.config;e.questionOptions.datasource={name:"problem_datasource",config:{...t,class:e.questionOptions.diagnosis?.conceptClasses??t?.class}},e.questionOptions.diagnosis?.conceptSet&&(e.questionOptions={...e.questionOptions,concept:e.questionOptions.diagnosis?.conceptSet,datasource:{name:"problem_datasource",config:{...t,concept:e.questionOptions.diagnosis.conceptSet,useSetMembersByConcept:!0}}}),e.questionOptions.isSearchable=!0,delete e.questionOptions.dataSource}}function dd(e,t){Object.entries(t).forEach(([t,n])=>{e?.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(e=>{e.id===t?e.questionOptions.defaultValue=n:Array.isArray(e?.questions)&&e.questions.length>0&&e.questions.forEach(e=>{e.id===t&&(e.questionOptions.defaultValue=n)})})})})})}let df=[{name:"DefaultFormSchemaTransformer",component:{transform:(e,t)=>(de(e,"readonly"),e.pages.forEach((t,n)=>{let r=t.label??"";t.id=`page-${r.replace(/\s/g,"")}-${n}`,de(t,"readonly"),t.sections&&t.sections.forEach(n=>{n.questions=c7(n.questions),n.questions=du(n.questions),de(n,"readonly"),de(n,"isExpanded"),n?.questions?.forEach((n,r)=>c9(n,t,e))})}),t&&"object"==typeof t&&dd(e,t),e.meta?.programs&&ds(e),e)}}];function dp(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].provider}return null}function dm(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].encounterRole}return null}function dh(e,t){return u_(e,t)||!ts(e.meta.submission.newValue.obsDatetime)}let dg=[{type:"obs",component:um},{type:"control",component:{getDisplayValue:(e,t)=>t,transformFieldValue:function(e,t,n){return null},getInitialValue:function(e,t,n){return null},getPreviousValue:function(e,t,n){return null},tearDown:function(){}}},{type:"obsGroup",component:um},{type:"testOrder",component:uF},{type:"programState",component:{transformFieldValue:function(e,t,n){if(tp(e),e.meta?.initialValue?.omrsObject?.uuid===t||ts(t))return null;e.meta.submission.newValue={state:t,startDate:tr()().format()}},getInitialValue:function(e,t,n){let r=n.customDependencies.patientPrograms?.find(t=>t.program.uuid===e.questionOptions.programUuid);if(r?.states?.length>0){let t=r.states.filter(e=>!e.endDate).find(t=>t.state.programWorkflow?.uuid===e.questionOptions.workflowUuid)?.state;return e.meta={...e.meta||{},initialValue:{omrsObject:t}},t?.uuid}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterLocation",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){return t&&t.location?.uuid?t.location.uuid:n.location.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;return{value:r?.location?.uuid,display:r?.location?.name}},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterProvider",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){let r=dp(t);return r?.uuid?r.uuid:n.currentProvider?.uuid},getPreviousValue:function(e,t,n){let r=dp(t??n.previousDomainObjectValue);return{value:r?.uuid,display:r?.name}},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterRole",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){let r=t??n.domainObjectValue;return r?dm(r)?.uuid:n.customDependencies.defaultEncounterRole.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let e=dm(r);return{value:e?.uuid,display:e?.name}}return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"obsComment",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=r.meta.initialValue?.omrsObject;if(r.meta.submission?.newValue)ts(t)&&!dh(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.comment=t;else if(!th(r)&&o){if(ts(t)&&ts(o.comment))return null;let e=uv(r,i);r.meta.submission={newValue:{...e,comment:t}}}return null},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_obs_comment")[0],r=n.formFields.find(e=>e.id===t);return r?.meta.initialValue.omrsObject?.comment}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterDatetime",component:{transformFieldValue:function(e,t,n){tm(e,t,null)},getInitialValue:function(e,t,n){return t?.encounterDatetime?new Date(t.encounterDatetime):n.sessionDate},getPreviousValue:function(e,t,n){if(t?.encounterDatetime){let n=new Date(t.encounterDatetime);return{value:n,display:this.getDisplayValue(e,n)}}return null},getDisplayValue:function(e,t){return(0,u.formatDate)(t)},tearDown:function(){}}},{type:"inlineDate",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=t instanceof Date?(0,u.toOmrsIsoString)(t):t;if(r.meta.submission?.newValue)ts(o)&&!dh(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.obsDatetime=o;else if(!th(r)&&r.meta.initialValue?.omrsObject){if(ts(t)&&ts(r.meta.initialValue.omrsObject?.obsDatetime))return null;let e=uv(r,i);r.meta.submission={newValue:{...e,obsDatetime:o}}}},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_inline_date")[0],r=n.formFields.find(e=>e.id===t),i=r?.meta.initialValue?.omrsObject;if(i?.obsDatetime)return(0,u.parseDate)(i.obsDatetime)}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?(0,u.formatDate)(t):null},tearDown:function(){}}},{type:"patientIdentifier",component:{transformFieldValue:function(e,t,n){return(tp(e),e.meta.initialValue?.refinedValue===t||ts(t))?null:(e.meta.submission.newValue={identifier:t,identifierType:e.questionOptions.identifierType,uuid:e.meta.initialValue?.omrsObject?.id,location:n.location},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.identifier?.find(t=>t.type?.coding[0]?.code===e.questionOptions.identifierType);return e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r?.value}},r?.value},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"personAttribute",component:{transformFieldValue:function(e,t,n){return(tp(e),e.meta.initialValue?.refinedValue===t||ts(t))?null:(e.meta.submission.newValue={value:t,attributeType:e.questionOptions.attributeType,uuid:e.meta.initialValue?.omrsObject?.uuid},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.extension?.find(t=>t.url===`http://fhir.openmrs.org/ext/person-attribute/${e.questionOptions.attributeType}`);return e.meta={...e.meta,initialValue:{omrsObject:r,refinedValue:r?.valueString||r?.valueReference?.reference}},e.meta.initialValue.refinedValue},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"diagnosis",component:uV}],dy={},dv={},db={},d_={},dw={},dx={};function dE(e,t){dT().expressionHelpers[e]=t}async function dk(e){if(dv[e])return dv[e];let t=cW.find(t=>t.name===e||t?.alias===e)?.component;if(!t){let n=await dT().controls.find(t=>t.name===e||t?.alias===e)?.load?.();t=n?.default}return dv[e]=t,t}function dS(e){return dV(e)&&!tf(e,"file")?(e.disabled=!0,e.isDisabled=!0,dk("text")):dk(e.questionOptions.rendering)}async function dO(e){if(db[e])return db[e];let t=dg.find(t=>t.type===e)?.component;if(!t){let n=await dT().fieldValueAdapters.find(t=>t.type===e)?.load?.();t=n?.default}return db[e]=t,t}async function dD(){let e=[],t=dx;if(Object.keys(t).length)return Object.values(t);let n=dT().formSchemaTransformers||[];return e.push(...(await Promise.all(n.map(async e=>{let t=await e.load?.();return t?.default}))).filter(e=>void 0!==e)),e.push(...df.map(e=>e.component)),e.forEach(e=>{dx[df.find(t=>t.component===e).name]=e}),e}async function dC(e){let t=d_[e];if(t)return t;let n=c6.find(t=>t.name===e);if(n){let t=n.load,r=await t();return d_[e]=r.default,r.default}let r=dT().postSubmissionActions.find(t=>t.name===e);if(r){let t=r.load,n=await t();return d_[e]=n.default,n.default}return console.error(`No loader found for PostSubmissionAction registration of id: ${e}`),null}async function dF(e){if(dy[e])return dy[e];let t=cJ.find(t=>t.name===e)?.component;if(!t){let n=await dT().fieldValidators.find(t=>t.name===e)?.load?.();t=n?.default}return dy[e]=t,t}async function dA(e){if(dw[e])return dw[e];let t=c3.find(t=>t.name===e)?.component;if(!t){let n=s6(e);if(n)t=c3.find(e=>e.name===n.datasource.name)?.component;else{let n=await dT().dataSources.find(t=>t.name===e)?.load?.();if(!n)throw Error("Datasource not found");t=n.default}}return dw[e]=t,t}function dP(){return dT().expressionHelpers}function dT(){return(0,u.getGlobalStore)(c.RA,{controls:[],postSubmissionActions:[],expressionHelpers:{},fieldValidators:[],fieldValueAdapters:[],dataSources:[],formSchemaTransformers:[]}).getState()}function dV(e){return"obs"==e.type&&!e.questionOptions.concept&&"fixed-value"!==e.questionOptions.rendering}function dM(e,t,n,r,i){let[o,a]=(0,d.useState)(null),[l,s]=(0,d.useState)(dq(e,t));return(0,d.useEffect)(()=>{let o=new AbortController,l=e=>{if(e?.translations){let t=window.i18next.language;window.i18next.addResourceBundle(t,u6.L,e.translations,!0,!0)}a(e)};return dj(e,t,r,i).then(e=>{l({...e,encounter:n})}).catch(e=>{"AbortError"!==e.name&&(console.error(e),s(Error("Error loading form JSON: "+e.message)))}),()=>{o.abort()}},[r,e,t,n]),{formJson:o,isLoading:!o&&!l,formError:l}}async function dj(e,t,n,r){let i=await (0,tj.fetchOpenMRSForm)(e),o=await (0,tj.fetchClobData)(i),a=await dD(),l=o?{...o,uuid:i.uuid}:d$(t),s=dI(l);dL(l,await dN(s,n));let u=dz(l),c=await dU(u),d=u.reduce((e,t)=>(e[t.formName]=t.alias,e),{});return dY(l,dW(c),d),dR(l,a,n,r)}function dI(e){return e.pages.filter(e=>e.isSubform&&!e.subform.form&&e.subform?.name).map(e=>e.subform?.name)}async function dN(e,t){return Promise.all(e.map(e=>dj(e,null,t)))}function dL(e,t){t.forEach(t=>{let n=e.pages.find(e=>e.subform?.name===t.name);n&&(n.subform.form=t)})}function dq(e,t){return e||t?e&&t?Error("InvalidArgumentsErr: Both formUuid and formJson cannot be provided at the same time."):void 0:Error("InvalidArgumentsErr: Neither formUuid nor formJson was provided")}function dR(e,t=[],n,r){return dB(e,n),t.reduce((e,t)=>t.transform(e,r),e),dH(e),a(n,e)}function d$(e){return"string"==typeof e?JSON.parse(e):JSON.parse(JSON.stringify(e))}function dB(e,t){for(let n=e.pages.length-1;n>=0;n--){let r=e.pages[n];(0,np.H)(r.isSubform)&&!(0,np.H)(r.isHidden)&&r.subform?.form?.encounterType===e.encounterType&&(r.subform.form.pages.filter(e=>!(0,np.H)(e.isSubform)),e.pages.splice(n,1,...dR(r.subform.form,[],t).pages))}}function dH(e){e.encounter&&"string"==typeof e.encounter&&!e.encounterType&&(e.encounterType=e.encounter,delete e.encounter)}function dz(e){let t=e?.referencedForms;return t||[]}async function dU(e){return Promise.all(e.map(e=>dj(e.formName,null,null)))}function dW(e){let t=new Map;return e.forEach(e=>{t.set(e.name,e)}),t}function dY(e,t,n){t.forEach((t,r)=>{e.pages.forEach(e=>{e.sections&&e.sections.forEach(e=>{if(e.reference&&(e.reference.form===r||e.reference.form===n[r])){let n=dJ(e,t);Object.assign(e,n)}})})})}function dJ(e,t){let n,r=t.pages.filter(t=>t.label===e.reference.page);if(r.length>0){let t=r[0].sections.filter(t=>t.label===e.reference.section);t.length>0&&(n=t[0])}return dZ(n,e.reference)}function dZ(e,t){if(t?.excludeQuestions){let n=t.excludeQuestions;e.questions=e.questions.filter(e=>!n.includes(e.id))}return e}var dG=function(e,t){return(dG=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function dQ(e,t){function n(){this.constructor=e}dG(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function dK(e){return"function"==typeof e}var dX=!1,d0={Promise:void 0,set useDeprecatedSynchronousErrorHandling(value){value&&Error().stack,dX=value},get useDeprecatedSynchronousErrorHandling(){return dX}};function d1(e){setTimeout(function(){throw e},0)}var d2={closed:!0,next:function(e){},error:function(e){if(d0.useDeprecatedSynchronousErrorHandling)throw e;d1(e)},complete:function(){}},d4=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}();function d5(e){return null!==e&&"object"==typeof e}var d3=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),d6=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return e.prototype.unsubscribe=function(){if(!this.closed){var t,n=this,r=n._parentOrParents,i=n._ctorUnsubscribe,o=n._unsubscribe,a=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof e)r.remove(this);else if(null!==r)for(var l=0;l<r.length;++l)r[l].remove(this);if(dK(o)){i&&(this._unsubscribe=void 0);try{o.call(this)}catch(e){t=e instanceof d3?d9(e.errors):[e]}}if(d4(a))for(var l=-1,s=a.length;++l<s;){var u=a[l];if(d5(u))try{u.unsubscribe()}catch(e){t=t||[],e instanceof d3?t=t.concat(d9(e.errors)):t.push(e)}}if(t)throw new d3(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw Error("unrecognized teardown "+t+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof e){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function d9(e){return e.reduce(function(e,t){return e.concat(t instanceof d3?t.errors:t)},[])}var d7=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),d8=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=d2;break;case 1:if(!n){o.destination=d2;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new fe(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new fe(o,n,r,i)}return o}return dQ(t,e),t.prototype[d7]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(d6),fe=function(e){function t(t,n,r,i){var o,a=e.call(this)||this;a._parentSubscriber=t;var l=a;return dK(n)?o=n:n&&(o=n.next,r=n.error,i=n.complete,n!==d2&&(dK((l=Object.create(n)).unsubscribe)&&a.add(l.unsubscribe.bind(l)),l.unsubscribe=a.unsubscribe.bind(a))),a._context=l,a._next=o,a._error=r,a._complete=i,a}return dQ(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;d0.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=d0.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?this.__tryOrSetError(t,this._error,e):this.__tryOrUnsub(this._error,e),this.unsubscribe();else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):d1(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;d1(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};d0.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,n):this.__tryOrUnsub(n),this.unsubscribe()}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),d0.useDeprecatedSynchronousErrorHandling)throw e;d1(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!d0.useDeprecatedSynchronousErrorHandling)throw Error("bad call");try{t.call(this._context,n)}catch(t){if(d0.useDeprecatedSynchronousErrorHandling)return e.syncErrorValue=t,e.syncErrorThrown=!0,!0;return d1(t),!0}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(d8);function ft(e){for(;e;){var t=e,n=t.closed,r=t.destination,i=t.isStopped;if(n||i)return!1;e=r&&r instanceof d8?r:null}return!0}function fn(e,t,n){if(e){if(e instanceof d8)return e;if(e[d7])return e[d7]()}return e||t||n?new d8(e,t,n):new d8(d2)}var fr=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function fi(e){return e}function fo(e){return 0===e.length?fi:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var fa=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,i=fn(e,t,n);if(r?i.add(r.call(i,this.source)):i.add(this.source||d0.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),d0.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){d0.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),ft(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=fl(t))(function(t,r){var i;i=n.subscribe(function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}},r,t)})},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[fr]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:fo(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=fl(e))(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function fl(e){if(e||(e=d0.Promise||Promise),!e)throw Error("no Promise impl found");return e}var fs=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),fu=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return dQ(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(d6),fc=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return dQ(t,e),t}(d8),fd=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return dQ(t,e),t.prototype[d7]=function(){return new fc(this)},t.prototype.lift=function(e){var t=new ff(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new fs;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new fs;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new fs;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new fs},t.prototype._subscribe=function(e){if(this.closed)throw new fs;return this.hasError?(e.error(this.thrownError),d6.EMPTY):this.isStopped?(e.complete(),d6.EMPTY):(this.observers.push(e),new fu(this,e))},t.prototype.asObservable=function(){var e=new fa;return e.source=this,e},t.create=function(e,t){return new ff(e,t)},t}(fa),ff=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return dQ(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):d6.EMPTY},t}(fd),fp=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return dQ(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new fs},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(fd);function fm(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class fh{setEvaluatedPagesVisibility(e){this.evaluatedPagesVisibilitySubject.next(e)}updateScrollablePages(e){this.scrollablePagesSubject.next(e)}updatePagesWithErrors(e){this.pagesWithErrorsSubject.next(new Set(e))}addActivePage(e){let t=this.activePagesSubject.value;t.add(e),this.activePagesSubject.next(t)}removeInactivePage(e){let t=this.activePagesSubject.value;t.delete(e),this.activePagesSubject.next(t)}getActivePagesObservable(){return this.activePagesSubject.asObservable()}getScrollablePagesObservable(){return this.scrollablePagesSubject.asObservable()}getPagesWithErrorsObservable(){return this.pagesWithErrorsSubject.asObservable()}getEvaluatedPagesVisibilityObservable(){return this.evaluatedPagesVisibilitySubject.asObservable()}clear(){this.scrollablePagesSubject.next([]),this.pagesWithErrorsSubject.next(new Set),this.activePagesSubject.next(new Set),this.evaluatedPagesVisibilitySubject.next(!1)}constructor(){fm(this,"scrollablePagesSubject",new fp([])),fm(this,"pagesWithErrorsSubject",new fp(new Set)),fm(this,"activePagesSubject",new fp(new Set)),fm(this,"evaluatedPagesVisibilitySubject",new fp(null))}}let fg=new fh,fy=new Set;function fv(e){e&&Object.values(e).forEach(e=>{fy.add(e)})}function fb(){fy.forEach(e=>{try{e.tearDown()}catch(e){}}),fy.clear(),fg.clear()}function f_(e){let[t,n]=(0,d.useState)(void 0),r=(0,d.useCallback)(()=>{let e=new CustomEvent("openmrs:form-view-embedded",{detail:{value:!1}});window.dispatchEvent(e)},[]),i=(0,d.useCallback)(e=>{n(e.detail.value)},[]);return(0,d.useEffect)(()=>{let t=new CustomEvent("openmrs:form-view-embedded",{detail:{value:"embedded-view"!=e}});window.dispatchEvent(t)},[e]),(0,d.useEffect)(()=>(window.addEventListener("openmrs:form-collapse-toggle",i),()=>{window.removeEventListener("openmrs:form-collapse-toggle",i)}),[]),{isFormExpanded:t,hideFormCollapseToggle:r}}let fw=26.25,fx=32.25,fE=48.25;function fk(e){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>t<=fw?"narrow":t<=fx?"wider":t<=fE?"extra-wide":"ultra-wide",[t]);return(0,d.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.parentElement?.offsetWidth,r=parseInt(getComputedStyle(document.documentElement).fontSize);t&&n(tw(t,r))};t();let r=new ResizeObserver(e=>{t()});return e.current?.parentElement&&r.observe(e.current?.parentElement),()=>{r.disconnect()}},[e]),r}let fS=()=>{let[e,t]=(0,d.useState)({pages:[],pagesWithErrors:[],activePages:[],evaluatedPagesVisibility:!1,hasMultiplePages:null});return(0,d.useEffect)(()=>{let e=[fg.getScrollablePagesObservable().subscribe(e=>{t(t=>({...t,pages:e,hasMultiplePages:e.length>1}))}),fg.getPagesWithErrorsObservable().subscribe(e=>{t(t=>({...t,pagesWithErrors:Array.from(e)}))}),fg.getActivePagesObservable().subscribe(e=>{t(t=>({...t,activePages:Array.from(e)}))}),fg.getEvaluatedPagesVisibilityObservable().subscribe(e=>{t(t=>({...t,evaluatedPagesVisibility:e}))})];return()=>e.forEach(e=>e.unsubscribe())},[]),e};function fO(e){let t=new Date,n=t.getFullYear()-e.getFullYear();return t.getMonth()<e.getMonth()||t.getMonth()===e.getMonth()&&t.getDate()<e.getDate()?n-1:n}let fD={female:"F",male:"M",other:"O",unknown:"U"},fC=e=>{let{patient:t,isLoading:n,error:r}=(0,u.usePatient)(e);return t&&!n&&(t.age=fO(new Date(t?.birthDate)),t.sex=fD[t.gender]??"U"),{patient:t,isLoadingPatient:n,patientError:r}},fF=(e,t,n,r)=>{let{loadDependencies:i}=e,{formJson:o}=t,[a,l]=(0,d.useState)(0),[s,u]=(0,d.useState)(null),c=(0,d.useCallback)(()=>l(e=>e+1),[]),f=s?.loadDependencies===i&&s?.attempt===a?s:null;return(0,d.useEffect)(()=>{let e=!1;return async function(){let l=await Promise.allSettled([Promise.resolve().then(()=>i?.(t,n,r)),tq(o)]);if(!e){let e=l.find(e=>"rejected"===e.status);u({loadDependencies:i,attempt:a,error:e?Error(e.reason?.message??String(e.reason)):null})}}(),()=>{e=!0}},[i,a]),{isLoading:!f||!!f.error,error:f?.error,retry:c}},fA=(e,t,n)=>{let[r,i]=(0,d.useState)(!0),[o,a]=(0,d.useState)({}),[l,s]=(0,d.useState)(null),u=(0,d.useRef)(n);u.current=n;let c=(0,d.useRef)(!1),f=n.formFields?.length>0,p=Object.keys(n.formFieldAdapters??{}).length>0;return(0,d.useEffect)(()=>{if(e&&!t&&f&&p&&!c.current){c.current=!0;let t=u.current;e.getInitialValues(t).then(e=>{a(e),i(!1)}).catch(e=>{console.error(e),s(e),i(!1)})}},[e,t,f,p]),{isLoadingInitialValues:r,initialValues:o,error:l}},fP="-esm-form-engine__section-renderer__section___OpnOG",fT="-esm-form-engine__section-renderer__sectionBody___lI63X",fV=({section:e})=>{let{formFieldAdapters:t}=ng(),n=(0,d.useMemo)(()=>e.label.replace(/\s/g,""),[e.label]);return f().createElement("div",{className:fP},e.questions.map(e=>t[e.type]?f().createElement("div",{key:`${n}-${e.id}`,className:fT},f().createElement(nT,{key:e.id,fieldId:e.id,valueAdapter:t[e.type]})):null))};var fM=n(9086),fj=!!("u">typeof window&&window.document&&window.document.createElement);function fI(){if(!fj||!window.addEventListener||!window.removeEventListener||!Object.defineProperty)return!1;var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return function(){e=!0}}()}),n=function(){};window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t)}catch(e){}return e}var fN=void 0;function fL(){return void 0===fN&&(fN=fI()),fN}function fq(e){if(e)return fL()?e:!!e.capture}function fR(e){return e?!0===e?100:(0|e.capture)+(e.passive<<1)+(e.once<<2):0}function f$(e){e.handlers===e.nextHandlers&&(e.nextHandlers=e.handlers.slice())}function fB(e){this.target=e,this.events={}}fB.prototype.getEventHandlers=function(){return function(e,t){var n=String(e)+" "+String(fR(t));return this.events[n]||(this.events[n]={handlers:[],handleEvent:void 0},this.events[n].nextHandlers=this.events[n].handlers),this.events[n]}}(),fB.prototype.handleEvent=function(){return function(e,t,n){var r=this.getEventHandlers(e,t);r.handlers=r.nextHandlers,r.handlers.forEach(function(e){e&&e(n)})}}(),fB.prototype.add=function(){return function(e,t,n){var r=this,i=this.getEventHandlers(e,n);f$(i),0===i.nextHandlers.length&&(i.handleEvent=this.handleEvent.bind(this,e,n),this.target.addEventListener(e,i.handleEvent,n)),i.nextHandlers.push(t);var o=!0;return function(){return function(){if(o){o=!1,f$(i);var a=i.nextHandlers.indexOf(t);i.nextHandlers.splice(a,1),0===i.nextHandlers.length&&(r.target&&r.target.removeEventListener(e,i.handleEvent,n),i.handleEvent=void 0)}}}()}}();var fH="__consolidated_events_handlers__";function fz(e,t,n,r){e[fH]||(e[fH]=new fB(e));var i=fq(r);return e[fH].add(t,n,i)}var fU=n(524);function fW(e){if("%"===e.slice(-1))return parseFloat(e.slice(0,-1))/100}function fY(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseFloat(e):"px"===e.slice(-2)?parseFloat(e.slice(0,-2)):void 0}function fJ(e,t){var n=fY(e);if("number"==typeof n)return n;var r=fW(e);if("number"==typeof r)return r*t}var fZ="above",fG="inside",fQ="below",fK="invisible";function fX(e){return"string"==typeof e.type}var f0="<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a DOM element (e.g. <div>) nor does it use the innerRef prop.\n\nSee https://goo.gl/LrBNgw for more info.";function f1(e,t){if(e&&!fX(e)&&!t)throw Error(f0)}function f2(e){return e.viewportBottom-e.viewportTop==0?fK:e.viewportTop<=e.waypointTop&&e.waypointTop<=e.viewportBottom||e.viewportTop<=e.waypointBottom&&e.waypointBottom<=e.viewportBottom||e.waypointTop<=e.viewportTop&&e.viewportBottom<=e.waypointBottom?fG:e.viewportBottom<e.waypointTop?fQ:e.waypointTop<e.viewportTop?fZ:fK}var f4=[];function f5(e){f4.push(e),r||(r=setTimeout(function(){var e;for(r=null;e=f4.shift();)e()},0));var t=!0;return function(){if(t){t=!1;var n=f4.indexOf(e);-1!==n&&(f4.splice(n,1),!f4.length&&r&&(clearTimeout(r),r=null))}}}function f3(e){return"window"===e?n.g.window:e}var f6="u">typeof window,f9={debug:!1,scrollableAncestor:void 0,children:void 0,topOffset:"0px",bottomOffset:"0px",horizontal:!1,onEnter:function(){},onLeave:function(){},onPositionChange:function(){},fireOnRapidScroll:!0},f7=function(e){function t(t){var n;return(n=e.call(this,t)||this).refElement=function(e){n._ref=e},n}(0,fM.A)(t,e);var n=t.prototype;return n.componentDidMount=function(){var e=this;f6&&(this.cancelOnNextTick=f5(function(){e.cancelOnNextTick=null;var t=e.props,n=t.children;t.debug,f1(n,e._ref),e._handleScroll=e._handleScroll.bind(e),e.scrollableAncestor=e._findScrollableAncestor(),e.scrollEventListenerUnsubscribe=fz(e.scrollableAncestor,"scroll",e._handleScroll,{passive:!0}),e.resizeEventListenerUnsubscribe=fz(window,"resize",e._handleScroll,{passive:!0}),e._handleScroll(null)}))},n.componentDidUpdate=function(){var e=this;f6&&this.scrollableAncestor&&(this.cancelOnNextTick||(this.cancelOnNextTick=f5(function(){e.cancelOnNextTick=null,e._handleScroll(null)})))},n.componentWillUnmount=function(){f6&&(this.scrollEventListenerUnsubscribe&&this.scrollEventListenerUnsubscribe(),this.resizeEventListenerUnsubscribe&&this.resizeEventListenerUnsubscribe(),this.cancelOnNextTick&&this.cancelOnNextTick())},n._findScrollableAncestor=function(){var e=this.props,t=e.horizontal,n=e.scrollableAncestor;if(n)return f3(n);for(var r=this._ref;r.parentNode&&(r=r.parentNode)!==document.body;){var i=window.getComputedStyle(r),o=(t?i.getPropertyValue("overflow-x"):i.getPropertyValue("overflow-y"))||i.getPropertyValue("overflow");if("auto"===o||"scroll"===o||"overlay"===o)return r}return window},n._handleScroll=function(e){if(this._ref){var t=this._getBounds(),n=f2(t),r=this._previousPosition,i=this.props,o=(i.debug,i.onPositionChange),a=i.onEnter,l=i.onLeave,s=i.fireOnRapidScroll;if(this._previousPosition=n,r!==n){var u={currentPosition:n,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom};o.call(this,u),n===fG?a.call(this,u):r===fG&&l.call(this,u);var c=r===fQ&&n===fZ,d=r===fZ&&n===fQ;s&&(c||d)&&(a.call(this,{currentPosition:fG,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}),l.call(this,{currentPosition:n,previousPosition:fG,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}))}}},n._getBounds=function(){var e,t,n=this.props,r=n.horizontal;n.debug;var i=this._ref.getBoundingClientRect(),o=i.left,a=i.top,l=i.right,s=i.bottom,u=r?o:a,c=r?l:s;this.scrollableAncestor===window?(e=r?window.innerWidth:window.innerHeight,t=0):(e=r?this.scrollableAncestor.offsetWidth:this.scrollableAncestor.offsetHeight,t=r?this.scrollableAncestor.getBoundingClientRect().left:this.scrollableAncestor.getBoundingClientRect().top);var d=this.props,f=d.bottomOffset,p=fJ(d.topOffset,e),m=fJ(f,e),h=t+e;return{waypointTop:u,waypointBottom:c,viewportTop:t+p,viewportBottom:h-m}},n.render=function(){var e=this,t=this.props.children;if(!t)return f().createElement("span",{ref:this.refElement,style:{fontSize:0}});if(fX(t)||(0,fU.isForwardRef)(t)){var n=function(n){e.refElement(n),t.ref&&("function"==typeof t.ref?t.ref(n):t.ref.current=n)};return f().cloneElement(t,{ref:n})}return f().cloneElement(t,{innerRef:this.refElement})},t}(f().PureComponent);f7.above=fZ,f7.below=fQ,f7.inside=fG,f7.invisible=fK,f7.defaultProps=f9,f7.displayName="Waypoint";let f8={pageContent:"-esm-form-engine__page-renderer__pageContent___ZYB9J",pageHeader:"-esm-form-engine__page-renderer__pageHeader___XuC5+",pageTitle:"-esm-form-engine__page-renderer__pageTitle___AbChc",collapseIcon:"-esm-form-engine__page-renderer__collapseIcon___eEY4D",sectionContainer:"-esm-form-engine__page-renderer__sectionContainer___nfi1A",accordionContainer:"-esm-form-engine__page-renderer__accordionContainer___M2pxs",firstSection:"-esm-form-engine__page-renderer__firstSection___IQTsd",lastSection:"-esm-form-engine__page-renderer__lastSection___sooKZ",formSection:"-esm-form-engine__page-renderer__formSection___PGg8p",hiddenAccordion:"-esm-form-engine__page-renderer__hiddenAccordion___-29II"};function pe({section:e,sectionIndex:t,visibleSections:n,isFormExpanded:r}){let{t:i}=(0,e9.useTranslation)(),[o,a]=(0,d.useState)(r);return(0,d.useEffect)(()=>{a(r)},[r]),f().createElement(y.AccordionItem,{title:i(e.label),open:o,className:m()(f8.sectionContainer,{[f8.firstSection]:0===t,[f8.lastSection]:t===n.length-1})},f().createElement("div",{className:f8.formSection},f().createElement(fV,{section:e})))}let pt=function({page:e,isFormExpanded:t}){let{t:n}=(0,e9.useTranslation)(),[r,i]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>e.sections.filter(e=>{let t=e.questions.some(e=>!(0,np.H)(e.isHidden));return!(0,np.H)(e.isHidden)&&t}),[e.sections]),a=()=>i(!r);return(0,d.useEffect)(()=>(i(!t),()=>{fg.removeInactivePage(e.id)}),[t]),f().createElement("div",null,f().createElement(f7,{key:e.id,onEnter:()=>fg.addActivePage(e.id),onLeave:()=>fg.removeInactivePage(e.id),topOffset:"40%",bottomOffset:"40%"},f().createElement("div",{id:e.id,className:f8.pageContent},f().createElement("div",{className:f8.pageHeader,onClick:a},f().createElement("p",{className:f8.pageTitle},n(e.label),f().createElement("span",{className:f8.collapseIconWrapper},r?f().createElement(u.ChevronDownIcon,{className:f8.collapseIcon,"aria-label":"Expand"}):f().createElement(u.ChevronUpIcon,{className:f8.collapseIcon,"aria-label":"Collapse"})))),f().createElement("div",{className:m()({[f8.hiddenAccordion]:r,[f8.accordionContainer]:!r})},f().createElement(y.Accordion,null,o.map((e,n)=>f().createElement(pe,{key:`section-${e.label}`,section:e,sectionIndex:n,visibleSections:o,isFormExpanded:t})))))))},pn={formFields:[],invalidFields:[],formJson:null,deletedFields:[]},pr=(e,t)=>{switch(t.type){case"SET_FORM_FIELDS":return{...e,formFields:t.value};case"ADD_FORM_FIELD":return{...e,formFields:[...e.formFields,t.value]};case"UPDATE_FORM_FIELD":return{...e,formFields:e.formFields.map(e=>e.id===t.value.id?t.value:e)};case"REMOVE_FORM_FIELD":return{...e,formFields:e.formFields.filter(e=>e.id!==t.value)};case"SET_INVALID_FIELDS":return{...e,invalidFields:t.value};case"ADD_INVALID_FIELD":return{...e,invalidFields:[...e.invalidFields,t.value]};case"REMOVE_INVALID_FIELD":return{...e,invalidFields:e.invalidFields.filter(e=>e.id!==t.value)};case"CLEAR_INVALID_FIELDS":return{...e,invalidFields:[]};case"SET_FORM_JSON":return{...e,formJson:t.value};case"SET_DELETED_FIELDS":return{...e,deletedFields:t.value};default:return e}},pi=(e,t)=>{let{formFields:n,patient:r,sessionMode:i,visit:o}=t,[a,l]=(0,d.useState)(t.formJson),[s,u]=(0,d.useState)(!1),c=(0,d.useMemo)(()=>n?.map(t=>{let a={value:t,type:"field"},l={patient:r,mode:i,visit:o};if(t.hide?.hideWhenExpression){let r=t0(t.hide.hideWhenExpression,a,n,e,l);t.isHidden=r,Array.isArray(t.questions)&&t.questions.forEach(e=>{e.isHidden=r})}else t.isHidden=!1;"object"==typeof t.required&&"conditionalRequired"===t.required.type?t.isRequired=t9(t,n,e):t.isRequired=(0,np.H)(t.required),"object"==typeof t.disabled&&t.disabled.disableWhenExpression?t.isDisabled=t0(t.disabled.disableWhenExpression,a,n,e,l):t.isDisabled=(0,np.H)(t.disabled),t.validators?.some(e=>"conditionalAnswered"===e.type)&&t6(t,n),t.questionOptions.answers?.filter(e=>!ts(e.hide?.hideWhenExpression)).forEach(t=>{t.isHidden=t0(t.hide.hideWhenExpression,a,n,e,l)}),t.questionOptions.answers?.filter(e=>!ts(e.disable?.disableWhenExpression)).forEach(t=>{t.disable.isDisabled=t0(t.disable?.disableWhenExpression,a,n,e,l)}),"string"==typeof t.readonly&&po(t.readonly)&&(t.meta.readonlyExpression=t.readonly,t.readonly=t0(t.readonly,a,n,e,l));let s=t.questionOptions.repeatOptions?.limitExpression;return"repeating"!==t.questionOptions.rendering||ts(s)||(t.questionOptions.repeatOptions.limit=t0(s,a,n,e,l)),t}),[e,n,r,i]);return(0,d.useEffect)(()=>{t.formJson?.pages?.forEach(t=>{t.hide?t8({value:t,type:"page"},n,e,i,r,t0,null):t.isHidden=!1,t?.sections?.forEach(t=>{t.hide?t8({value:t,type:"section"},n,e,i,r,t0,null):t.isHidden=!1})}),l(t_(t.formJson)),u(!0)},[t.formJson,n]),{evaluatedFormJson:a,evaluatedFields:c,evaluatedPagesVisibility:s}};function po(e){return"true"!==e&&"false"!==e}function pa(e,t){let n=(0,d.useCallback)(t=>{e({type:"ADD_FORM_FIELD",value:t})},[]),r=(0,d.useCallback)(n=>{if(n.meta.groupId){let e=t.find(e=>e.id===n.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===n.id?n:e),r(e))}e({type:"UPDATE_FORM_FIELD",value:(0,uu.A)(n)})},[t]),i=(0,d.useCallback)(e=>t.find(t=>t.id===e),[t]),o=(0,d.useCallback)(t=>{e({type:"REMOVE_FORM_FIELD",value:t})},[]),a=(0,d.useCallback)(t=>{e({type:"SET_INVALID_FIELDS",value:t})},[]),l=(0,d.useCallback)(t=>{e({type:"ADD_INVALID_FIELD",value:t})},[]),s=(0,d.useCallback)(t=>{e({type:"REMOVE_INVALID_FIELD",value:t})},[]);return{addFormField:n,updateFormField:r,getFormField:i,removeFormField:o,setInvalidFields:a,addInvalidField:l,removeInvalidField:s,setForm:(0,d.useCallback)(t=>{e({type:"SET_FORM_JSON",value:t_(t)})},[]),setDeletedFields:(0,d.useCallback)(t=>{e({type:"SET_DELETED_FIELDS",value:t})},[])}}let pl=({processorContext:e,initialValues:t,isSubForm:n,setIsLoadingFormDependencies:r})=>{let{evaluatedFields:i,evaluatedFormJson:o,evaluatedPagesVisibility:a}=pi(t,e),{registerForm:l,setIsFormDirty:s,workspaceLayout:u,isFormExpanded:c}=cE(),p=e6({defaultValues:t,mode:"onChange",reValidateMode:"onChange",criteriaMode:"all"}),{formState:{isDirty:m}}=p,[{formFields:h,invalidFields:g,formJson:y,deletedFields:v},b]=(0,d.useReducer)(pr,{...pn,formFields:i,formJson:o}),{addFormField:_,updateFormField:w,getFormField:x,removeFormField:E,setInvalidFields:k,addInvalidField:S,removeInvalidField:O,setForm:D,setDeletedFields:C}=pa(b,h);(0,d.useEffect)(()=>{let e=y.pages.filter(e=>!e.isSubform).map(e=>e);fg.updateScrollablePages(e)},[y.pages]),(0,d.useEffect)(()=>{fg.setEvaluatedPagesVisibility(a)},[a]),(0,d.useEffect)(()=>{fg.updatePagesWithErrors(g.map(e=>e.meta.pageId))},[g]);let F=(0,d.useMemo)(()=>({...e,workspaceLayout:u,methods:p,formFields:h,formJson:y,invalidFields:g,deletedFields:v,addFormField:_,updateFormField:w,getFormField:x,removeFormField:E,setInvalidFields:k,addInvalidField:S,removeInvalidField:O,setForm:D,setDeletedFields:C}),[e,u,p,h,y,g,v]);return(0,d.useEffect)(()=>{l(y.name,n,F)},[y.name,n,F]),(0,d.useEffect)(()=>{s(m)},[m]),f().createElement(nh,F,y.pages.map(e=>e.isSubform||ni(e)?e.isSubform&&e.subform?.form?f().createElement(px,{key:e.subform.form.uuid,formJson:e.subform.form,isSubForm:!0,setIsLoadingFormDependencies:r}):f().createElement(pt,{key:e.label,page:e,isFormExpanded:c}):null))},ps=({context:e,setContext:t,setters:n,useCustomHooks:r,setIsLoadingCustomHooks:i})=>{let{isLoading:o=!1,error:a=null,data:l,updateContext:s}=r(e);return(0,d.useEffect)(()=>{!o&&s&&(s(t,n),i(!1))},[o]),null};function pu(e){let[t,n]=(0,d.useMemo)(()=>{let t=[],n=new Set,r=(e,i)=>{let o=i?{...e,meta:{...e.meta,groupId:i}}:e;t.push(o),o.questionOptions?.concept&&n.add(o.questionOptions.concept),o.questionOptions?.answers?.forEach(e=>{e.concept&&n.add(e.concept)}),"obsGroup"===o.type&&o.questions&&o.questions.forEach(e=>{r(e,o.id)})};return e.pages?.forEach(e=>e.sections?.forEach(e=>{e.questions?.forEach(e=>r(e))})),[t,JSON.stringify(Array.from(n).sort())]},[e]);return{formFields:t,conceptReferences:(0,d.useMemo)(()=>new Set(JSON.parse(n)),[n])}}let pc="custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))";function pd(e){let{data:t,error:n,isLoading:r}=cl()([`${u.restBaseUrl}/conceptreferences?v=${pc}`,e],([e,t])=>(0,u.openmrsFetch)(e,{headers:{"Content-Type":"application/json"},body:{references:t},method:"POST"}),{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1,shouldRetryOnError:!1});return{concepts:(0,d.useMemo)(()=>t?.data?Object.values(t.data):void 0,[t]),isLoading:r,error:n}}let pf={};function pp(e){let t=(0,d.useMemo)(()=>{let t=new Set;return e.forEach(e=>{e.validators?.forEach(e=>t.add(e.type))}),Array.from(t).sort().join(",")},[e]),{data:n}=ci()(t?["formFieldValidators",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>dF(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??pf}function pm(e,t){return(0,d.useMemo)(()=>e.length&&t?.length?e.map(e=>{let n=nt(e.questionOptions.concept,t);return e.questionOptions.concept=n?n.uuid:e.questionOptions.concept,e.label=e.label?e.label:n?.display,c.FU.includes(e.questionOptions.rendering)&&!e.questionOptions.answers?.length&&n?.conceptClass?.display==="Question"&&n?.answers?.length&&(e.questionOptions.answers=n.answers.map(e=>({concept:e?.uuid,label:e?.display}))),e.meta={...e.meta||{},concept:n},e.questionOptions.answers&&(e.questionOptions.answers=e.questionOptions.answers.map(e=>{let n=nt(e.concept,t);return{...e,concept:n?n.uuid:e.concept,label:e.label?e.label:n?.display}})),e}):e??[],[t,e])}let ph={},pg=e=>{let t=(0,d.useMemo)(()=>{let t=new Set;return e.forEach(e=>t.add(e.type)),Array.from(t).sort().join(",")},[e]),{data:n}=ci()(t?["formFieldValueAdapters",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>dO(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??ph},py="-esm-form-engine__loader__loaderContainer___78hu3",pv="-esm-form-engine__loader__loader___dnvKS",pb=()=>{let{t:e}=(0,e9.useTranslation)();return f().createElement("div",{className:py},f().createElement(y.InlineLoading,{className:pv,description:`${e("loading","Loading")} ...`}))},p_=["patient","formJson","visit","sessionMode","sessionDate","location","currentProvider","layoutType","processor","formFields","formFieldAdapters","formFieldValidators"];function pw(e,t){let n=p_.filter(n=>n in t&&t[n]!==e[n]);n.length&&console.warn(`A form processor tried to set the context propert${1===n.length?"y":"ies"} ${n.join(", ")}, which the form engine derives itself. ${1===n.length?"It was":"They were"} ignored. Use the setters passed alongside setContext to update the domain object or custom dependencies.`)}let px=({formJson:e,isSubForm:t=!1,setIsLoadingFormDependencies:n})=>{let{patient:r,sessionMode:i,formProcessors:o,layoutType:a,location:l,provider:s,sessionDate:u,visit:c}=cE(),{t:p}=(0,e9.useTranslation)(),m=(0,d.useId)(),h=(0,d.useMemo)(()=>{let t,n=o[e.processor];return n?t=new n(e):(console.error(`Form processor ${e.processor} not found, defaulting to EncounterFormProcessor`),t=new cp(e)),t.prepareFormSchema(e),t},[o,e.processor]),{formFields:g,conceptReferences:v}=pu(e),{concepts:b,isLoading:_}=pd(Array.from(v)),w=pm(g,b),x=pg(g),E=pp(g),k=(0,d.useMemo)(()=>w?.length?w:g??[],[w,g]),[S,O]=(0,d.useState)({}),D=(0,d.useMemo)(()=>({patient:r,formJson:e,sessionMode:i,layoutType:a,location:l,currentProvider:s,processor:h,sessionDate:u,visit:c,formFields:k,formFieldAdapters:x??{},formFieldValidators:E??{}}),[r,e,i,a,l,s,h,u,c,k,x,E]),C=(0,d.useMemo)(()=>({...D,...S}),[D,S]),F=(0,d.useCallback)(e=>{O(t=>{let n={...D,...t},r="function"==typeof e?e(n):e;return"function"==typeof e&&pw(n,r),{domainObjectValue:r.domainObjectValue,previousDomainObjectValue:r.previousDomainObjectValue,customDependencies:r.customDependencies}})},[D]),A=(0,d.useMemo)(()=>({setDomainObjectValue:e=>O(t=>({...t,domainObjectValue:e})),setPreviousDomainObjectValue:e=>O(t=>({...t,previousDomainObjectValue:e})),setCustomDependencies:e=>O(t=>({...t,customDependencies:"function"==typeof e?e(t.customDependencies??{}):e}))}),[]),{isLoading:P,error:T,retry:V}=fF(h,C,F,A),M=h.getCustomHooks().useCustomHooks,[j,I]=(0,d.useState)(!!M),{isLoadingInitialValues:N,initialValues:L,error:q}=fA(h,P||j||_,C),R=(0,d.useMemo)(()=>P||j||_||N,[P,j,_,N]);return(0,d.useEffect)(()=>{n(m,R)},[m,R,n]),(0,d.useEffect)(()=>()=>n(m,!1),[m,n]),(0,d.useEffect)(()=>{(0,ns.N)(q,p("errorLoadingInitialValues","Error loading initial values"))},[q,p]),(0,d.useEffect)(()=>{x&&fv(x)},[x]),f().createElement(f().Fragment,null,M&&f().createElement(ps,{context:C,setContext:F,setters:A,useCustomHooks:M,setIsLoadingCustomHooks:I}),T?f().createElement("div",null,f().createElement(y.InlineNotification,{kind:"error",hideCloseButton:!0,title:p("errorLoadingFormDependencies","Unable to load form data"),subtitle:p("retryLoadingFormDependencies","Required form data could not be loaded. Retry to complete and save this form.")}),f().createElement(y.Button,{kind:"tertiary",onClick:V},p("retry","Retry"))):R?f().createElement(pb,null):f().createElement(pl,{processorContext:C,initialValues:L,isSubForm:t,setIsLoadingFormDependencies:n}))},pE="-esm-form-engine__patient-banner__patientBannerContainer___w28t3",pk=({patient:e,hideActionsOverflow:t})=>f().createElement("div",{className:pE},f().createElement(u.ExtensionSlot,{name:"patient-header-slot",state:{patient:e,patientUuid:e.id,hideActionsOverflow:t}})),pS=({pages:e,defaultPage:t,activePages:n,evaluatedPagesVisibility:r})=>{let[i,o]=(0,d.useState)(null),[a,l]=(0,d.useState)(!1),[s,u]=(0,d.useState)(null),c=(0,d.useRef)(!0);return(0,d.useEffect)(()=>{a||!r||((()=>{let n=e.find(({label:e})=>e===t);if(n&&!n.isHidden)o(n.id),nn(n.id);else{let t=e.find(e=>!e.isHidden);t&&o(t.id)}})(),l(!0))},[e,t,r,a]),(0,d.useEffect)(()=>{let e=null;return a&&(e=setTimeout(()=>{c.current=!1},200)),()=>{e&&clearTimeout(e)}},[a]),(0,d.useEffect)(()=>{if(c.current)return;let t=null;if(s&&n.includes(s)){o(s),t=setTimeout(()=>{u(null)},100);return}return!s&&n.length>0&&o(n.reduce((t,n)=>e.findIndex(e=>e.id===t)<e.findIndex(e=>e.id===n)?t:n)),()=>{t&&clearTimeout(t)}},[n,s,e]),{currentActivePage:i,requestPage:(0,d.useCallback)(e=>{c.current=!1,u(e),o(e),nn(e)},[])}},pO="-esm-form-engine__sidebar__pageLink___ivjRs",pD="-esm-form-engine__sidebar__pageLinkTablet___DzG-5",pC="-esm-form-engine__sidebar__activePage___PtOKZ",pF="-esm-form-engine__sidebar__errorPage___56UzK",pA="-esm-form-engine__sidebar__activeErrorPage___FRrGU",pP="-esm-form-engine__sidebar__sidebar___oko66",pT="-esm-form-engine__sidebar__sideNavActions___hQ7Cj",pV="-esm-form-engine__sidebar__divider___qNrzq",pM="-esm-form-engine__sidebar__closeButton___X671g",pj="-esm-form-engine__sidebar__saveButton___1qxAl",pI="-esm-form-engine__sidebar__topMargin___XINCj";function pN({page:e,currentActivePage:t,pagesWithErrors:n,requestPage:r}){let{t:i}=(0,e9.useTranslation)(),o=e.id===t,a=n.includes(e.id),l="tablet"===(0,u.useLayoutType)();return f().createElement("div",{className:m()(pO,{[pC]:o&&!a,[pF]:a&&!o,[pA]:a&&o,[pD]:l})},f().createElement("button",{onClick:t=>{t.preventDefault(),r(e.id)}},f().createElement("span",null,i(e.label))))}let pL=({defaultPage:e,isFormSubmitting:t,sessionMode:n,onCancel:r,handleClose:i,hideFormCollapseToggle:o,hideControls:a})=>{let{t:l}=(0,e9.useTranslation)(),{pages:s,pagesWithErrors:c,activePages:p,evaluatedPagesVisibility:h}=fS(),{currentActivePage:g,requestPage:v}=pS({pages:s,defaultPage:e,activePages:p,evaluatedPagesVisibility:h}),b=(0,u.useLayoutType)(),_=(0,d.useMemo)(()=>"tablet"===b?"lg":"sm",[b]);return f().createElement("div",{className:pP},s.filter(e=>ni(e)).map(e=>f().createElement(pN,{key:e.id,page:e,currentActivePage:g,pagesWithErrors:c,requestPage:v})),"view"!==n&&!a&&f().createElement("hr",{className:pV}),!a&&f().createElement("div",{className:pT},"view"!==n&&f().createElement(y.Button,{className:pj,disabled:t,type:"submit",size:_},t?f().createElement(y.InlineLoading,{description:l("submitting","Submitting")+"..."}):f().createElement("span",null,`${l("save","Save")}`)),f().createElement(y.Button,{className:m()(pM,{[pI]:"view"===n}),kind:"tertiary",onClick:()=>{r?.(),i?.(),o()},size:_},"view"===n?l("close","Close"):l("cancel","Cancel"))))},pq="-esm-form-engine__form-engine__form___G3zJ0",pR="-esm-form-engine__form-engine__formContainer___SqLcw",p$="-esm-form-engine__form-engine__formContent___wWrk8",pB="-esm-form-engine__form-engine__formContentInner___z1h1C",pH="-esm-form-engine__form-engine__formBody___Fb2k2",pz="-esm-form-engine__form-engine__minifiedButtons___SnmW7",pU="-esm-form-engine__form-engine__markdownContainer___A3eX9",pW="-esm-form-engine__form-engine__linearActivity___boIRq",pY="-esm-form-engine__form-engine__indeterminate___nUedJ",pJ="-esm-form-engine__form-engine__saveButton___T0Txa",pZ=({formJson:e,patientUUID:t,formUUID:n,encounterUUID:r,visit:i,formSessionIntent:o,mode:a,onSubmit:l,onCancel:s,handleClose:c,handleConfirmQuestionDeletion:p,markFormAsDirty:h,hideControls:g=!1,hidePatientBanner:v=!1,preFilledQuestions:b})=>{let{t:_}=(0,e9.useTranslation)(),w=(0,u.useSession)(),x=(0,d.useRef)(null),E=(0,d.useRef)(new Date),k=(0,d.useMemo)(()=>tv(E.current,i),[i?.startDatetime,i?.stopDatetime]),S=fk(x),{patient:O,isLoadingPatient:D}=fC(t),[C,F]=(0,d.useState)(!0),A=(0,d.useRef)(new Set),P=(0,d.useCallback)((e,t)=>{t?A.current.add(e):A.current.delete(e),F(A.current.size>0)},[]),[T,V]=(0,d.useState)(!1),[M,j]=(0,d.useState)(!1),I=ts(a)?ts(r)?"enter":"edit":a,{isFormExpanded:N,hideFormCollapseToggle:L}=f_(I),{hasMultiplePages:q}=fS(),{formJson:R,isLoading:$,formError:B}=dM(n,e,r,o,b),H=(0,d.useMemo)(()=>!v&&O&&"ultra-wide"===S&&"embedded-view"!==a,[O,a,S,v]),z=(0,d.useMemo)(()=>["narrow"].includes(S),[S]),U=(0,d.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&(z||!q),[a,z,C,q]),W=(0,d.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&!z&&q,[z,C,q]);(0,d.useEffect)(()=>{(0,ns.N)(B,_("errorLoadingFormSchema","Error loading form schema"))},[B]),(0,d.useEffect)(()=>()=>{fb()},[]),(0,d.useEffect)(()=>{h?.(M)},[M]);let Y=(0,d.useCallback)(e=>{e.preventDefault(),V(!0)},[]);return f().createElement("form",{ref:x,noValidate:!0,className:m()("cds--form",pq),onSubmit:Y},D||$?f().createElement(pb,null):f().createElement(cx,{patient:O,isLoadingDependencies:C,patientUUID:t,sessionMode:I,sessionDate:k,formJson:R,workspaceLayout:"ultra-wide"===S?"maximized":"minimized",location:w?.sessionLocation,provider:w?.currentProvider,visit:i,handleConfirmQuestionDeletion:p,isFormExpanded:N,formSubmissionProps:{isSubmitting:T,setIsSubmitting:V,onSubmit:l,onError:()=>{},handleClose:()=>{}},hideFormCollapseToggle:L,setIsFormDirty:j},f().createElement("div",{className:pR},C&&f().createElement("div",{className:pW},f().createElement("div",{className:pY})),f().createElement("div",{className:p$},W&&f().createElement(pL,{isFormSubmitting:T,sessionMode:a,defaultPage:R.defaultPage,onCancel:s,handleClose:c,hideFormCollapseToggle:L,hideControls:g}),f().createElement("div",{className:pB},H&&f().createElement(pk,{patient:O,hideActionsOverflow:!0}),R.markdown&&f().createElement("div",{className:pU},f().createElement(sk,{markdown:R.markdown})),f().createElement("div",{className:pH},f().createElement(px,{formJson:R,setIsLoadingFormDependencies:P})),U&&!g&&f().createElement(y.ButtonSet,{className:pz},f().createElement(y.Button,{kind:"secondary",onClick:()=>{s&&s(),c&&c(),L()}},"view"===a?_("close","Close"):_("cancel","Cancel")),f().createElement(y.Button,{className:pJ,disabled:C||T||"view"===a,kind:"primary",type:"submit"},T?f().createElement(y.InlineLoading,{description:_("submitting","Submitting")+"..."}):f().createElement("span",null,`${_("save","Save")}`))))))))},pG=function(e){return f().createElement(d.Suspense,{fallback:f().createElement(pb,null)},f().createElement(e9.I18nextProvider,{i18n:window.i18next,defaultNS:u6.L},f().createElement(pZ,e)))}},1809(e,t,n){"use strict";function r(e){return"boolean"==typeof e?e:"string"==typeof e?"true"==e:!!e}function i(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}n.d(t,{H:()=>r,O:()=>i})},8059(e,t,n){"use strict";n.d(t,{N:()=>i,j:()=>o});var r=n(2664);function i(e,t){if(e){let n=o(e).join(", ");console.error(e),(0,r.showSnackbar)({subtitle:n,title:t,kind:"error",isLowContrast:!1})}}function o(e){let t=e?.responseBody?.error?.fieldErrors,n=e?.responseBody?.error?.globalErrors;return t&&0!==Object.keys(t).length||n?n?.length?n.flatMap(e=>e.message):Object.values(t).flatMap(e=>e.map(e=>e.message)):[e?.responseBody?.error?.message??e?.message]}},9804(__unused_rspack_module,__webpack_exports__,__webpack_require__){"use strict";function evaluatePostSubmissionExpression(expression,encounters){let match,encounter=encounters[0],regx=/(?:\w+|'(?:\\'|[^'\n])*')/g,fieldIds=new Set;try{let replacedExpression;for(;match=regx.exec(expression);){let value=match[0].replace(/\\'/g,"'"),isBoolean=/^(true|false)$/i.test(value),isNumber=/^-?\d+$/.test(value),isFloat=/^-?\d+\.\d+$/.test(value);value.startsWith("'")&&value.endsWith("'")||"string"!=typeof value||isBoolean||isNumber||isFloat||fieldIds.add(value)}let fieldToValueMap={};return fieldIds.size&&(fieldToValueMap=getFieldValues(fieldIds,encounter)),replacedExpression=Object.keys(fieldToValueMap).length?expression.replace(/(\w+)/g,e=>Object.prototype.hasOwnProperty.call(fieldToValueMap,e)?fieldToValueMap[e]:e):expression,eval(replacedExpression)}catch(error){throw Error("Error evaluating expression")}}function getFieldValues(e,t){let n={};return e.forEach(e=>{let r=t.obs?.find(t=>t.formFieldPath.includes(e))?.value;"object"==typeof r&&(r=r.uuid),r&&(r=formatValue(r)),n[e]=r}),n}function formatValue(e){if("string"==typeof e&&(!(e.length>=2)||"'"!==e[0]||"'"!==e[e.length-1]))return`'${e}'`;return e}__webpack_require__.d(__webpack_exports__,{g:()=>evaluatePostSubmissionExpression})},1630(e){!function(t){e.exports=t()}(function(){"use strict";var e={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"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,a={},l=function(e){return(e*=1)+(e>68?1900:2e3)},s=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e||"Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],c=function(e){var t=a[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=a.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[o,function(e){this.afternoon=d(e,!1)}],a:[o,function(e){this.afternoon=d(e,!0)}],Q:[n,function(e){this.month=3*(e-1)+1}],S:[n,function(e){this.milliseconds=100*e}],SS:[r,function(e){this.milliseconds=10*e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[i,s("seconds")],ss:[i,s("seconds")],m:[i,s("minutes")],mm:[i,s("minutes")],H:[i,s("hours")],h:[i,s("hours")],HH:[i,s("hours")],hh:[i,s("hours")],D:[i,s("day")],DD:[r,s("day")],Do:[o,function(e){var t=a.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],w:[i,s("week")],ww:[r,s("week")],M:[i,s("month")],MM:[r,s("month")],MMM:[o,function(e){var t=c("months"),n=(c("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw Error();this.month=n%12||n}],MMMM:[o,function(e){var t=c("months").indexOf(e)+1;if(t<1)throw Error();this.month=t%12||t}],Y:[/[+-]?\d+/,s("year")],YY:[r,function(e){this.year=l(e)}],YYYY:[/\d{4}/,s("year")],Z:u,ZZ:u};function p(n){var r,i;r=n,i=a&&a.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(t),l=o.length,s=0;s<l;s+=1){var u=o[s],c=f[u],d=c&&c[0],p=c&&c[1];o[s]=p?{regex:d,parser:p}:u.replace(/^\[|\]$/g,"")}return function(e){for(var t={},n=0,r=0;n<l;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else{var a=i.regex,s=i.parser,u=e.slice(r),c=a.exec(u)[0];s.call(t,c),e=e.replace(c,"")}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(l=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,o=e.args;this.$u=r;var l=o[1];if("string"==typeof l){var s=!0===o[2],u=!0===o[3],c=s||u,d=o[2];u&&(d=o[2]),a=this.$locale(),!s&&d&&(a=n.Ls[d]),this.$d=function(e,t,n,r){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var i=p(t)(e),o=i.year,a=i.month,l=i.day,s=i.hours,u=i.minutes,c=i.seconds,d=i.milliseconds,f=i.zone,m=i.week,h=new Date,g=l||(o||a?1:h.getDate()),y=o||h.getFullYear(),v=0;o&&!a||(v=a>0?a-1:h.getMonth());var b,_=s||0,w=u||0,x=c||0,E=d||0;return f?new Date(Date.UTC(y,v,g,_,w,x,E+60*f.offset*1e3)):n?new Date(Date.UTC(y,v,g,_,w,x,E)):(b=new Date(y,v,g,_,w,x,E),m&&(b=r(b).week(m).toDate()),b)}catch(e){return new Date("")}}(t,l,r,n),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),c&&t!=this.format(l)&&(this.$d=new Date("")),a={}}else if(l instanceof Array)for(var f=l.length,m=1;m<=f;m+=1){o[1]=l[m-1];var h=n.apply(this,o);if(h.isValid()){this.$d=h.$d,this.$L=h.$L,this.init();break}m===f&&(this.$d=new Date(""))}else i.call(this,e)}}})},9710(e){"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,i=t.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!i&&!o)return!1;for(r in e);return void 0===r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;else if(i)return i(e,n).value}return e[n]};e.exports=function e(){var t,n,r,i,u,c,d=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<p;++f)if(t=arguments[f],null!=t)for(n in t)r=s(d,n),d!==(i=s(t,n))&&(m&&i&&(a(i)||(u=o(i)))?(u?(u=!1,c=r&&o(r)?r:[]):c=r&&a(r)?r:{},l(d,{name:n,newValue:e(m,c,i)})):void 0!==i&&l(d,{name:n,newValue:i}));return d}},5937(e){var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,s=/^\s+|\s+$/g,u="\n",c="/",d="*",f="",p="comment",m="declaration";function h(e){return e?e.replace(s,f):f}e.exports=function(e,s){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];s=s||{};var g=1,y=1;function v(e){var t=e.match(n);t&&(g+=t.length);var r=e.lastIndexOf(u);y=~r?e.length-r:y+e.length}function b(){var e={line:g,column:y};return function(t){return t.position=new _(e),k(),t}}function _(e){this.start=e,this.end={line:g,column:y},this.source=s.source}_.prototype.content=e;var w=[];function x(t){var n=Error(s.source+":"+g+":"+y+": "+t);if(n.reason=t,n.filename=s.source,n.line=g,n.column=y,n.source=e,s.silent)w.push(n);else throw n}function E(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function k(){E(r)}function S(e){var t;for(e=e||[];t=O();)!1!==t&&e.push(t);return e}function O(){var t=b();if(c==e.charAt(0)&&d==e.charAt(1)){for(var n=2;f!=e.charAt(n)&&(d!=e.charAt(n)||c!=e.charAt(n+1));)++n;if(n+=2,f===e.charAt(n-1))return x("End of comment missing");var r=e.slice(2,n-2);return y+=2,v(r),e=e.slice(n),y+=2,t({type:p,comment:r})}}function D(){var e=b(),n=E(i);if(n){if(O(),!E(o))return x("property missing ':'");var r=E(a),s=e({type:m,property:h(n[0].replace(t,f)),value:r?h(r[0].replace(t,f)):f});return E(l),s}}function C(){var e,t=[];for(S(t);e=D();)!1!==e&&(t.push(e),S(t));return t}return k(),C()}},3103(e,t,n){e.exports=n(4715)(n(8942),"DataView")},5098(e,t,n){var r=n(3305),i=n(9361),o=n(1112),a=n(5276),l=n(5071);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},1386(e,t,n){var r=n(2393),i=n(2049),o=n(7144),a=n(7452),l=n(3964);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9770(e,t,n){e.exports=n(4715)(n(8942),"Map")},8250(e,t,n){var r=n(9753),i=n(5681),o=n(88),a=n(4732),l=n(9068);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9413(e,t,n){e.exports=n(4715)(n(8942),"Promise")},4512(e,t,n){e.exports=n(4715)(n(8942),"Set")},3212(e,t,n){var r=n(8250),i=n(1877),o=n(8006);function a(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}a.prototype.add=a.prototype.push=i,a.prototype.has=o,e.exports=a},1340(e,t,n){var r=n(1386),i=n(4103),o=n(1779),a=n(4162),l=n(7462),s=n(6638);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=i,u.prototype.delete=o,u.prototype.get=a,u.prototype.has=l,u.prototype.set=s,e.exports=u},5650(e,t,n){e.exports=n(8942).Symbol},1623(e,t,n){e.exports=n(8942).Uint8Array},9270(e,t,n){e.exports=n(4715)(n(8942),"WeakMap")},9968(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},9847(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}},358(e,t,n){var r=n(6137),i=n(3283),o=n(3142),a=n(5853),l=n(9632),s=n(8666),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=o(e),c=!n&&i(e),d=!n&&!c&&a(e),f=!n&&!c&&!d&&s(e),p=n||c||d||f,m=p?r(e.length,String):[],h=m.length;for(var g in e)(t||u.call(e,g))&&!(p&&("length"==g||d&&("offset"==g||"parent"==g)||f&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||l(g,h)))&&m.push(g);return m}},5111(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}},1129(e){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},6465(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},7034(e,t,n){var r=n(6285);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return -1}},4570(e,t,n){var r=n(7170);e.exports=n(5770)(r)},4661(e,t,n){var r=n(4570);e.exports=function(e,t){var n=[];return r(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}},7250(e){e.exports=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return -1}},5636(e,t,n){e.exports=n(6596)()},7170(e,t,n){var r=n(5636),i=n(1211);e.exports=function(e,t){return e&&r(e,t,i)}},7923(e,t,n){var r=n(3526),i=n(6040);e.exports=function(e,t){t=r(t,e);for(var n=0,o=t.length;null!=e&&n<o;)e=e[i(t[n++])];return n&&n==o?e:void 0}},8244(e,t,n){var r=n(1129),i=n(3142);e.exports=function(e,t,n){var o=t(e);return i(e)?o:r(o,n(e))}},7379(e,t,n){var r=n(5650),i=n(8870),o=n(9005),a="[object Null]",l="[object Undefined]",s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?l:a:s&&s in Object(e)?i(e):o(e)}},3636(e){e.exports=function(e,t){return null!=e&&t in Object(e)}},6027(e,t,n){var r=n(7379),i=n(547),o="[object Arguments]";e.exports=function(e){return i(e)&&r(e)==o}},4687(e,t,n){var r=n(353),i=n(547);function o(e,t,n,a,l){return e===t||(null!=e&&null!=t&&(i(e)||i(t))?r(e,t,n,a,o,l):e!=e&&t!=t)}e.exports=o},353(e,t,n){var r=n(1340),i=n(3934),o=n(8861),a=n(1182),l=n(8486),s=n(3142),u=n(5853),c=n(8666),d=1,f="[object Arguments]",p="[object Array]",m="[object Object]",h=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,g,y,v){var b=s(e),_=s(t),w=b?p:l(e),x=_?p:l(t);w=w==f?m:w,x=x==f?m:x;var E=w==m,k=x==m,S=w==x;if(S&&u(e)){if(!u(t))return!1;b=!0,E=!1}if(S&&!E)return v||(v=new r),b||c(e)?i(e,t,n,g,y,v):o(e,t,w,n,g,y,v);if(!(n&d)){var O=E&&h.call(e,"__wrapped__"),D=k&&h.call(t,"__wrapped__");if(O||D){var C=O?e.value():e,F=D?t.value():t;return v||(v=new r),y(C,F,n,g,v)}}return!!S&&(v||(v=new r),a(e,t,n,g,y,v))}},8330(e,t,n){var r=n(1340),i=n(4687),o=1,a=2;e.exports=function(e,t,n,l){var s=n.length,u=s,c=!l;if(null==e)return!u;for(e=Object(e);s--;){var d=n[s];if(c&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++s<u;){var f=(d=n[s])[0],p=e[f],m=d[1];if(c&&d[2]){if(void 0===p&&!(f in e))return!1}else{var h=new r;if(l)var g=l(p,m,f,e,t,h);if(!(void 0===g?i(m,p,o|a,l,h):g))return!1}}return!0}},9624(e,t,n){var r=n(3655),i=n(4759),o=n(1580),a=n(4066),l=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,u=Object.prototype,c=Function.prototype.toString,d=u.hasOwnProperty,f=RegExp("^"+c.call(d).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?f:s).test(a(e))}},674(e,t,n){var r=n(7379),i=n(5387),o=n(547),a="[object Arguments]",l="[object Array]",s="[object Boolean]",u="[object Date]",c="[object Error]",d="[object Function]",f="[object Map]",p="[object Number]",m="[object Object]",h="[object RegExp]",g="[object Set]",y="[object String]",v="[object WeakMap]",b="[object ArrayBuffer]",_="[object DataView]",w="[object Float64Array]",x="[object Int8Array]",E="[object Int16Array]",k="[object Int32Array]",S="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",C="[object Uint32Array]",F={};F["[object Float32Array]"]=F[w]=F[x]=F[E]=F[k]=F[S]=F[O]=F[D]=F[C]=!0,F[a]=F[l]=F[b]=F[s]=F[_]=F[u]=F[c]=F[d]=F[f]=F[p]=F[m]=F[h]=F[g]=F[y]=F[v]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!F[r(e)]}},3334(e,t,n){var r=n(6526),i=n(2343),o=n(2053),a=n(3142),l=n(3282);e.exports=function(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?a(e)?i(e[0],e[1]):r(e):l(e)}},195(e,t,n){var r=n(4882),i=n(8121),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},6526(e,t,n){var r=n(8330),i=n(4367),o=n(3904);e.exports=function(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},2343(e,t,n){var r=n(4687),i=n(6123),o=n(7276),a=n(5187),l=n(7267),s=n(3904),u=n(6040),c=1,d=2;e.exports=function(e,t){return a(e)&&l(t)?s(u(e),t):function(n){var a=i(n,e);return void 0===a&&a===t?o(n,e):r(t,a,c|d)}}},2762(e){e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},8880(e,t,n){var r=n(7923);e.exports=function(e){return function(t){return r(t,e)}}},6137(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},2291(e,t,n){var r=n(5650),i=n(5111),o=n(3142),a=n(1187),l=1/0,s=r?r.prototype:void 0,u=s?s.toString:void 0;function c(e){if("string"==typeof e)return e;if(o(e))return i(e,c)+"";if(a(e))return u?u.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}e.exports=c},6403(e,t,n){var r=n(2945),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},9460(e){e.exports=function(e){return function(t){return e(t)}}},5568(e){e.exports=function(e,t){return e.has(t)}},3997(e,t,n){var r=n(2053);e.exports=function(e){return"function"==typeof e?e:r}},3526(e,t,n){var r=n(3142),i=n(5187),o=n(6493),a=n(5243);e.exports=function(e,t){return r(e)?e:i(e,t)?[e]:o(a(e))}},1950(e,t,n){e.exports=n(8942)["__core-js_shared__"]},5770(e,t,n){var r=n(6529);e.exports=function(e,t){return function(n,i){if(null==n)return n;if(!r(n))return e(n,i);for(var o=n.length,a=t?o:-1,l=Object(n);(t?a--:++a<o)&&!1!==i(l[a],a,l););return n}}},6596(e){e.exports=function(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),l=a.length;l--;){var s=a[e?l:++i];if(!1===n(o[s],s,o))break}return t}}},3934(e,t,n){var r=n(3212),i=n(6465),o=n(5568),a=1,l=2;e.exports=function(e,t,n,s,u,c){var d=n&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=-1,y=!0,v=n&l?new r:void 0;for(c.set(e,t),c.set(t,e);++g<f;){var b=e[g],_=t[g];if(s)var w=d?s(_,b,g,t,e,c):s(b,_,g,e,t,c);if(void 0!==w){if(w)continue;y=!1;break}if(v){if(!i(t,function(e,t){if(!o(v,t)&&(b===e||u(b,e,n,s,c)))return v.push(t)})){y=!1;break}}else if(!(b===_||u(b,_,n,s,c))){y=!1;break}}return c.delete(e),c.delete(t),y}},8861(e,t,n){var r=n(5650),i=n(1623),o=n(6285),a=n(3934),l=n(5894),s=n(9828),u=1,c=2,d="[object Boolean]",f="[object Date]",p="[object Error]",m="[object Map]",h="[object Number]",g="[object RegExp]",y="[object Set]",v="[object String]",b="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",x=r?r.prototype:void 0,E=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,k,S){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case _:if(e.byteLength!=t.byteLength||!k(new i(e),new i(t)))break;return!0;case d:case f:case h:return o(+e,+t);case p:return e.name==t.name&&e.message==t.message;case g:case v:return e==t+"";case m:var O=l;case y:var D=r&u;if(O||(O=s),e.size!=t.size&&!D)break;var C=S.get(e);if(C)return C==t;r|=c,S.set(e,t);var F=a(O(e),O(t),r,x,k,S);return S.delete(e),F;case b:if(E)return E.call(e)==E.call(t)}return!1}},1182(e,t,n){var r=n(393),i=1,o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,a,l,s){var u=n&i,c=r(e),d=c.length;if(d!=r(t).length&&!u)return!1;for(var f=d;f--;){var p=c[f];if(!(u?p in t:o.call(t,p)))return!1}var m=s.get(e),h=s.get(t);if(m&&h)return m==t&&h==e;var g=!0;s.set(e,t),s.set(t,e);for(var y=u;++f<d;){var v=e[p=c[f]],b=t[p];if(a)var _=u?a(b,v,p,t,e,s):a(v,b,p,e,t,s);if(!(void 0===_?v===b||l(v,b,n,a,s):_)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var w=e.constructor,x=t.constructor;w!=x&&"constructor"in e&&"constructor"in t&&!("function"==typeof w&&w instanceof w&&"function"==typeof x&&x instanceof x)&&(g=!1)}return s.delete(e),s.delete(t),g}},4967(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},393(e,t,n){var r=n(8244),i=n(7979),o=n(1211);e.exports=function(e){return r(e,o,i)}},4700(e,t,n){var r=n(9067);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},4367(e,t,n){var r=n(7267),i=n(1211);e.exports=function(e){for(var t=i(e),n=t.length;n--;){var o=t[n],a=e[o];t[n]=[o,a,r(a)]}return t}},4715(e,t,n){var r=n(9624),i=n(155);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},8870(e,t,n){var r=n(5650),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,l=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,l),n=e[l];try{e[l]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[l]=n:delete e[l]),i}},7979(e,t,n){var r=n(9847),i=n(9306),o=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;e.exports=a?function(e){return null==e?[]:r(a(e=Object(e)),function(t){return o.call(e,t)})}:i},8486(e,t,n){var r=n(3103),i=n(9770),o=n(9413),a=n(4512),l=n(9270),s=n(7379),u=n(4066),c="[object Map]",d="[object Object]",f="[object Promise]",p="[object Set]",m="[object WeakMap]",h="[object DataView]",g=u(r),y=u(i),v=u(o),b=u(a),_=u(l),w=s;(r&&w(new r(new ArrayBuffer(1)))!=h||i&&w(new i)!=c||o&&w(o.resolve())!=f||a&&w(new a)!=p||l&&w(new l)!=m)&&(w=function(e){var t=s(e),n=t==d?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case g:return h;case y:return c;case v:return f;case b:return p;case _:return m}return t}),e.exports=w},155(e){e.exports=function(e,t){return null==e?void 0:e[t]}},5899(e,t,n){var r=n(3526),i=n(3283),o=n(3142),a=n(9632),l=n(5387),s=n(6040);e.exports=function(e,t,n){t=r(t,e);for(var u=-1,c=t.length,d=!1;++u<c;){var f=s(t[u]);if(!(d=null!=e&&n(e,f)))break;e=e[f]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&l(c)&&a(f,c)&&(o(e)||i(e))}},3305(e,t,n){var r=n(4497);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},9361(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t}},1112(e,t,n){var r=n(4497),i="__lodash_hash_undefined__",o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===i?void 0:n}return o.call(t,e)?t[e]:void 0}},5276(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:i.call(t,e)}},5071(e,t,n){var r=n(4497),i="__lodash_hash_undefined__";e.exports=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=r&&void 0===t?i:t,this}},9632(e){var t=0x1fffffffffffff,n=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var i=typeof e;return!!(r=null==r?t:r)&&("number"==i||"symbol"!=i&&n.test(e))&&e>-1&&e%1==0&&e<r}},5187(e,t,n){var r=n(3142),i=n(1187),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||i(e))||a.test(e)||!o.test(e)||null!=t&&e in Object(t)}},9067(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4759(e,t,n){var r=n(1950),i=function(){var e=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();e.exports=function(e){return!!i&&i in e}},4882(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},7267(e,t,n){var r=n(1580);e.exports=function(e){return e==e&&!r(e)}},2393(e){e.exports=function(){this.__data__=[],this.size=0}},2049(e,t,n){var r=n(7034),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0)&&(n==t.length-1?t.pop():i.call(t,n,1),--this.size,!0)}},7144(e,t,n){var r=n(7034);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},7452(e,t,n){var r=n(7034);e.exports=function(e){return r(this.__data__,e)>-1}},3964(e,t,n){var r=n(7034);e.exports=function(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},9753(e,t,n){var r=n(5098),i=n(1386),o=n(9770);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(o||i),string:new r}}},5681(e,t,n){var r=n(4700);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=!!t,t}},88(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).get(e)}},4732(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).has(e)}},9068(e,t,n){var r=n(4700);e.exports=function(e,t){var n=r(this,e),i=n.size;return n.set(e,t),this.size+=+(n.size!=i),this}},5894(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},3904(e){e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},6853(e,t,n){var r=n(9011),i=500;e.exports=function(e){var t=r(e,function(e){return n.size===i&&n.clear(),e}),n=t.cache;return t}},4497(e,t,n){e.exports=n(4715)(Object,"create")},8121(e,t,n){e.exports=n(3766)(Object.keys,Object)},2306(e,t,n){e=n.nmd(e);var r=n(4967),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i&&r.process,l=function(){try{var e=o&&o.require&&o.require("util").types;if(e)return e;return a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=l},9005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},3766(e){e.exports=function(e,t){return function(n){return e(t(n))}}},8942(e,t,n){var r=n(4967),i="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||i||Function("return this")()},1877(e){var t="__lodash_hash_undefined__";e.exports=function(e){return this.__data__.set(e,t),this}},8006(e){e.exports=function(e){return this.__data__.has(e)}},9828(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4103(e,t,n){var r=n(1386);e.exports=function(){this.__data__=new r,this.size=0}},1779(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4162(e){e.exports=function(e){return this.__data__.get(e)}},7462(e){e.exports=function(e){return this.__data__.has(e)}},6638(e,t,n){var r=n(1386),i=n(9770),o=n(8250),a=200;e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var l=n.__data__;if(!i||l.length<a-1)return l.push([e,t]),this.size=++n.size,this;n=this.__data__=new o(l)}return n.set(e,t),this.size=n.size,this}},6493(e,t,n){var r=n(6853),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g;e.exports=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(i,function(e,n,r,i){t.push(r?i.replace(o,"$1"):n||e)}),t})},6040(e,t,n){var r=n(1187),i=1/0;e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},4066(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},2945(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},6285(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},7581(e,t,n){var r=n(9847),i=n(4661),o=n(3334),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t,3))}},2154(e,t,n){var r=n(7250),i=n(3334),o=n(7642),a=Math.max;e.exports=function(e,t,n){var l=null==e?0:e.length;if(!l)return -1;var s=null==n?0:o(n);return s<0&&(s=a(l+s,0)),r(e,i(t,3),s)}},7289(e,t,n){e.exports=n(3981)},3657(e,t,n){var r=n(9968),i=n(4570),o=n(3997),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t))}},6123(e,t,n){var r=n(7923);e.exports=function(e,t,n){var i=null==e?void 0:r(e,t);return void 0===i?n:i}},7276(e,t,n){var r=n(3636),i=n(5899);e.exports=function(e,t){return null!=e&&i(e,t,r)}},3981(e){e.exports=function(e){return e&&e.length?e[0]:void 0}},2053(e){e.exports=function(e){return e}},3283(e,t,n){var r=n(6027),i=n(547),o=Object.prototype,a=o.hasOwnProperty,l=o.propertyIsEnumerable;e.exports=r(function(){return arguments}())?r:function(e){return i(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},3142(e){e.exports=Array.isArray},6529(e,t,n){var r=n(3655),i=n(5387);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},5853(e,t,n){e=n.nmd(e);var r=n(8942),i=n(4772),o=t&&!t.nodeType&&t,a=o&&e&&!e.nodeType&&e,l=a&&a.exports===o?r.Buffer:void 0,s=(l?l.isBuffer:void 0)||i;e.exports=s},3655(e,t,n){var r=n(7379),i=n(1580),o="[object AsyncFunction]",a="[object Function]",l="[object GeneratorFunction]",s="[object Proxy]";e.exports=function(e){if(!i(e))return!1;var t=r(e);return t==a||t==l||t==o||t==s}},5387(e){var t=0x1fffffffffffff;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=t}},1580(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},1187(e,t,n){var r=n(7379),i=n(547),o="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||i(e)&&r(e)==o}},8666(e,t,n){var r=n(674),i=n(9460),o=n(2306),a=o&&o.isTypedArray;e.exports=a?i(a):r},1211(e,t,n){var r=n(358),i=n(195),o=n(6529);e.exports=function(e){return o(e)?r(e):i(e)}},8087(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},9011(e,t,n){var r=n(8250),i="Expected a function";function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError(i);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},3282(e,t,n){var r=n(2762),i=n(8880),o=n(5187),a=n(6040);e.exports=function(e){return o(e)?r(a(e)):i(e)}},9306(e){e.exports=function(){return[]}},4772(e){e.exports=function(){return!1}},3301(e,t,n){var r=n(6131),i=1/0,o=17976931348623157e292;e.exports=function(e){return e?(e=r(e))===i||e===-i?(e<0?-1:1)*o:e==e?e:0:0===e?e:0}},7642(e,t,n){var r=n(3301);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},6131(e,t,n){var r=n(6403),i=n(1580),o=n(1187),a=0/0,l=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return a;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=s.test(e);return n||u.test(e)?c(e.slice(2),n?2:8):l.test(e)?a:+e}},5243(e,t,n){var r=n(2291);e.exports=function(e){return null==e?"":r(e)}},2281(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},6783(e,t,n){"use strict";let r=n(4517),i=n(3955),{safeRe:o,t:a}=n(2841);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){let r,i=t.includePrerelease?o[a.COERCERTLFULL]:o[a.COERCERTL];for(;(r=i.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&r.index+r[0].length===n.index+n[0].length||(n=r),i.lastIndex=r.index+r[1].length+r[2].length;i.lastIndex=-1}else n=e.match(t.includePrerelease?o[a.COERCEFULL]:o[a.COERCE]);if(null===n)return null;let l=n[2],s=n[3]||"0",u=n[4]||"0",c=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${l}.${s}.${u}${c}${d}`,t)}},6106(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n)=>{let i=new r(e,n),o=new r(t,n);return i.compare(o)||i.compareBuild(o)}},2132(e,t,n){"use strict";let r=n(7851);e.exports=(e,t)=>r(e,t,!0)},3269(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,null,!0),i=r(t,null,!0),o=n.compare(i);if(0===o)return null;let a=o>0,l=a?n:i,s=a?i:n,u=!!l.prerelease.length;if(s.prerelease.length&&!u){if(!s.patch&&!s.minor)return"major";if(0===s.compareMain(l))return s.minor&&!s.patch?"minor":"patch"}let c=u?"pre":"";return n.major!==i.major?c+"major":n.minor!==i.minor?c+"minor":n.patch!==i.patch?c+"patch":"prerelease"}},8868(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,o).version}catch(e){return null}}},6381(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).major},1353(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).minor},3955(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},6082(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).patch},9428(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},7555(e,t,n){"use strict";let r=n(7851);e.exports=(e,t,n)=>r(t,e,n)},3810(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(n,e,t))},4042(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(e,n,t))},8474(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n?n.version:null}},2722(e,t,n){"use strict";let r=n(2841),i=n(9543),o=n(4517),a=n(3806),l=n(3955),s=n(8474),u=n(2281),c=n(8868),d=n(3269),f=n(6381),p=n(1353),m=n(6082),h=n(9428),g=n(7851),y=n(7555),v=n(2132),b=n(6106),_=n(4042),w=n(3810),x=n(9761),E=n(1262),k=n(8848),S=n(8220),O=n(2386),D=n(9639),C=n(4004),F=n(6783),A=n(1565),P=n(7476),T=n(7229),V=n(6364),M=n(5039),j=n(5357),I=n(1280),N=n(7403),L=n(8854),q=n(7226),R=n(7183),$=n(8623);e.exports={parse:l,valid:s,clean:u,inc:c,diff:d,major:f,minor:p,patch:m,prerelease:h,compare:g,rcompare:y,compareLoose:v,compareBuild:b,sort:_,rsort:w,gt:x,lt:E,eq:k,neq:S,gte:O,lte:D,cmp:C,coerce:F,Comparator:A,Range:P,satisfies:T,toComparators:V,maxSatisfying:M,minSatisfying:j,minVersion:I,validRange:N,outside:L,gtr:q,ltr:R,intersects:$,simplifyRange:n(6486),subset:n(583),SemVer:o,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},7226(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,">",n)},8623(e,t,n){"use strict";let r=n(7476);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},7183(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,"<",n)},5039(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||-1===a.compare(e))&&(a=new r(o=e,n))}),o}},5357(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||1===a.compare(e))&&(a=new r(o=e,n))}),o}},1280(e,t,n){"use strict";let r=n(4517),i=n(7476),o=n(9761);e.exports=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)||(n=new r("0.0.0-0"),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],a=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":(!a||o(t,a))&&(a=t);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),a&&(!n||o(n,a))&&(n=a)}return n&&e.test(n)?n:null}},8854(e,t,n){"use strict";let r=n(4517),i=n(1565),{ANY:o}=i,a=n(7476),l=n(7229),s=n(9761),u=n(1262),c=n(9639),d=n(2386);e.exports=(e,t,n,f)=>{let p,m,h,g,y;switch(e=new r(e,f),t=new a(t,f),n){case">":p=s,m=c,h=u,g=">",y=">=";break;case"<":p=u,m=d,h=s,g="<",y="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(l(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let r=t.set[n],a=null,l=null;if(r.forEach(e=>{e.semver===o&&(e=new i(">=0.0.0")),a=a||e,l=l||e,p(e.semver,a.semver,f)?a=e:h(e.semver,l.semver,f)&&(l=e)}),a.operator===g||a.operator===y||(!l.operator||l.operator===g)&&m(e,l.semver)||l.operator===y&&h(e,l.semver))return!1}return!0}},6486(e,t,n){"use strict";let r=n(7229),i=n(7851);e.exports=(e,t,n)=>{let o=[],a=null,l=null,s=e.sort((e,t)=>i(e,t,n));for(let e of s)r(e,t,n)?(l=e,a||(a=e)):(l&&o.push([a,l]),l=null,a=null);a&&o.push([a,null]);let u=[];for(let[e,t]of o)e===t?u.push(e):t||e!==s[0]?t?e===s[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");let c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},583(e,t,n){"use strict";let r=n(7476),i=n(1565),{ANY:o}=i,a=n(7229),l=n(7851),s=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let i=!1;e:for(let r of e.set){for(let e of t.set){let t=d(r,e,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0},u=[new i(">=0.0.0-0")],c=[new i(">=0.0.0")],d=(e,t,n)=>{let r,i,s,d,m,h,g;if(e===t)return!0;if(1===e.length&&e[0].semver===o)if(1===t.length&&t[0].semver===o)return!0;else e=n.includePrerelease?u:c;if(1===t.length&&t[0].semver===o)if(n.includePrerelease)return!0;else t=c;let y=new Set;for(let t of e)">"===t.operator||">="===t.operator?r=f(r,t,n):"<"===t.operator||"<="===t.operator?i=p(i,t,n):y.add(t.semver);if(y.size>1)return null;if(r&&i&&((s=l(r.semver,i.semver,n))>0||0===s&&(">="!==r.operator||"<="!==i.operator)))return null;for(let e of y){if(r&&!a(e,String(r),n)||i&&!a(e,String(i),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let v=!!i&&!n.includePrerelease&&!!i.semver.prerelease.length&&i.semver,b=!!r&&!n.includePrerelease&&!!r.semver.prerelease.length&&r.semver;for(let e of(v&&1===v.prerelease.length&&"<"===i.operator&&0===v.prerelease[0]&&(v=!1),t)){if(g=g||">"===e.operator||">="===e.operator,h=h||"<"===e.operator||"<="===e.operator,r){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if((d=f(r,e,n))===e&&d!==r)return!1}else if(">="===r.operator&&!a(r.semver,String(e),n))return!1}if(i){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),"<"===e.operator||"<="===e.operator){if((m=p(i,e,n))===e&&m!==i)return!1}else if("<="===i.operator&&!a(i.semver,String(e),n))return!1}if(!e.operator&&(i||r)&&0!==s)return!1}return(!r||!h||!!i||0===s)&&(!i||!g||!!r||0===s)&&!b&&!v&&!0},f=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},p=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=s},6364(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "))},7403(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},8052(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var i=r(n(5937));function o(e,t){var n=null;if(!e||"string"!=typeof e)return n;var r=(0,i.default)(e),o="function"==typeof t;return r.forEach(function(e){if("declaration"===e.type){var r=e.property,i=e.value;o?t(r,i,e):i&&((n=n||{})[r]=i)}}),n}}}]);
|