vendor: 4,897 bytes, lines 1-3
1import{a as ht}from"./chunk-HOE3GQNG.js";import{a as z}from"./chunk-SSXJCVYS.js";import{d as ft,f as M}from"./chunk-APIKARSP.js";import{b as Se}from"./chunk-E2HJQWYB.js";import{a as ut}from"./chunk-GEBLCV3C.js";import"./chunk-TSOBK4WK.js";import{Eb as x,Fb as C,Gb as Te,Hb as _e,Ib as xe,Jb as V,Jc as Y,Kb as Ce,Lb as we,Mb as se,Nb as L,Ob as R,Pb as qe,Tb as Ee,Ub as $e,Va as ct,Y as D,Yb as Ae,Zb as y,_a as b,a as F,b as at,ca as lt,g as w,ha as P,ic as dt,kc as O,lc as pt,mc as X,oa as $,ob as ye,pa as j,q as be,r as q,uc as Ne,z as ne}from"./chunk-KWV3WIUO.js";var mt=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",jt=mt+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",Ut="["+mt+"]["+jt+"]*",Bt=new RegExp("^"+Ut+"$");function gt(r,e){let t=[],i=e.exec(r);for(;i;){let n=[];n.startIndex=e.lastIndex-i[0].length;let s=i.length;for(let a=0;a<s;a++)n.push(i[a]);t.push(n),i=e.exec(r)}return t}var je=function(r){let e=Bt.exec(r);return!(e===null||typeof e>"u")};function bt(r){return typeof r<"u"}var oe=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],ve=["__proto__","constructor","prototype"];var Gt={allowBooleanAttributes:!1,unpairedTags:[]};function xt(r,e){e=Object.assign({},Gt,e);let t=[],i=!1,n=!1;r[0]==="\uFEFF"&&(r=r.substr(1));for(let s=0;s<r.length;s++)if(r[s]==="<"&&r[s+1]==="?"){if(s+=2,s=yt(r,s),s.err)return s}else if(r[s]==="<"){let a=s;if(s++,r[s]==="!"){s=Tt(r,s);continue}else{let o=!1;r[s]==="/"&&(o=!0,s++);let l="";for(;s<r.length&&r[s]!==">"&&r[s]!==" "&&r[s]!==" "&&r[s]!==` 2`&&r[s]!=="\r";s++)l+=r[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!Kt(l)){let p;return l.trim().length===0?p="Invalid space after '<'.":p="Tag '"+l+"' is an invalid name.",T("InvalidTag",p,A(r,s))}let d=Xt(r,s);if(d===!1)return T("InvalidAttr","Attributes for '"+l+"' have open quote.",A(r,s));let c=d.value;if(s=d.index,c[c.length-1]==="/"){let p=s-c.length;c=c.substring(0,c.length-1);let u=_t(c,e);if(u===!0)i=!0;else return T(u.err.code,u.err.msg,A(r,p+u.err.line))}else if(o)if(d.tagClosed){if(c.trim().length>0)return T("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",A(r,a));if(t.length===0)return T("InvalidTag","Closing tag '"+l+"' has not been opened.",A(r,a));{let p=t.pop();if(l!==p.tagName){let u=A(r,p.tagStartPos);return T("InvalidTag","Expected closing tag '"+p.tagName+"' (opened in line "+u.line+", col "+u.col+") instead of closing tag '"+l+"'.",A(r,a))}t.length==0&&(n=!0)}}else return T("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",A(r,s));else{let p=_t(c,e);if(p!==!0)return T(p.err.code,p.err.msg,A(r,s-c.length+p.err.line));if(n===!0)return T("InvalidXml","Multiple possible root nodes found.",A(r,s));e.unpairedTags.indexOf(l)!==-1||t.push({tagName:l,tagStartPos:a}),i=!0}for(s++;s<r.length;s++)if(r[s]==="<")if(r[s+1]==="!"){s++,s=Tt(r,s);continue}else if(r[s+1]==="?"){if(s=yt(r,++s),s.err)return s}else break;else if(r[s]==="&"){let p=Wt(r,s);if(p==-1)return T("InvalidChar","char '&' is not expected.",A(r,s));s=p}else if(n===!0&&!W(r[s]))return T("InvalidXml","Extra text at the end",A(r,s));r[s]==="<"&&s--}}else{if(W(r[s]))continue;return T("InvalidChar","char '"+r[s]+"' is not expected.",A(r,s))}if(i){if(t.length==1)return T("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",A(r,t[0].tagStartPos));if(t.length>0)return T("InvalidXml","Invalid '"+JSON.stringify(t.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return T("InvalidXml","Start tag expected.",1);return!0}function W(r){return r===" "||r===" "||r===` 3`||r==="\r"}function yt(r,e){let t=e;for(;e<r.length;e++)if(r[e]=="?"||r[e]==" "){let i=r.substr(t,e-t);if(e>5&&i==="xml")return T("InvalidXml","XML declaration allowed only at the start of the document.",A(r,e));if(r[e]=="?"&&r[e+1]==">"){e++;break}else continue}return e}function Tt(r,e){if(r.length>e+5&&r[e+1]==="-"&&r[e+2]==="-"){for(e+=3;e<r.length;e++)if(r[e]==="-"&&r[e+1]==="-"&&r[e+2]===">"){e+=2;break}}else if(r.length>e+8&&r[e+1]==="D"&&r[e+2]==="O"&&r[e+3]==="C"&&r[e+4]==="T"&&r[e+5]==="Y"&&r[e+6]==="P"&&r[e+7]==="E"){let t=1;for(e+=8;e<r.length;e++)if(r[e]==="<")t++;else if(r[e]===">"&&(t--,t===0))break}else if(r.length>e+9&&r[e+1]==="["&&r[e+2]==="C"&&r[e+3]==="D"&&r[e+4]==="A"&&r[e+5]==="T"&&r[e+6]==="A"&&r[e+7]==="["){for(e+=8;e<r.length;e++)if(r[e]==="]"&&r[e+1]==="]"&&r[e+2]===">"){e+=2;break}}return e}var Ht='"',Dt="'";function Xt(r,e){let t="",i="",n=!1;for(;e<r.length;e++){if(r[e]===Ht||r[e]===Dt)i===""?i=r[e]:i!==r[e]||(i="");else if(r[e]===">"&&i===""){n=!0;break}t+=r[e]}return i!==""?!1:{value:t,index:e,tagClosed:n}}function Yt(r){let e=[],t=r.length,i=0;for(;i<t;){let n=i;for(;i<t&&W(r[i]);)i++;
3if(i>=t)break;if(r[i]==="="){i=n+1;continue}let s=r.slice(n,i),a=i;for(;i<t&&!W(r[i])&&r[i]!=="=";)i++;let o=r.slice(a,i),l,d=i;for(;d<t&&W(r[d]);)d++;d<t&&r[d]==="="&&(l=r.slice(i,d+1),i=d+1);let c,p,u=i;for(;u<t&&W(r[u]);)u++;if(u<t&&(r[u]==='"'||r[u]==="'")){let h=u+1,m=r.indexOf(r[u],h);m!==-1&&(c=r[u],p=r.slice(h,m),i=m+1)}let f={startIndex:n};f[1]=s,f[2]=o,f[3]=l,f[4]=c!==void 0?!0:void 0,f[5]=c,f[6]=p,e.push(f)}return e}function _t(r,e){let t=Yt(r),i={};for(let n=0;n<t.length;n++){if(t[n][1].length===0)return T("InvalidAttr","Attribute '"+t[n][2]+"' has no space in starting.",ae(t[n]));if(t[n][3]!==void 0&&t[n][4]===void 0)return T("InvalidAttr","Attribute '"+t[n][2]+"' is without value.",ae(t[n]));if(t[n][3]===void 0&&!e.allowBooleanAttributes)return T("InvalidAttr","boolean attribute '"+t[n][2]+"' is not allowed.",ae(t[n]));let s=t[n][2];if(!Qt(s))return T("InvalidAttr","Attribute '"+s+"' is an invalid name.",ae(t[n]));if(!Object.prototype.hasOwnProperty.call(i,s))i[s]=1;else return T("InvalidAttr","Attribute '"+s+"' is repeated.",ae(t[n]))}return!0}function zt(r,e){let t=/\d/;for(r[e]==="x"&&(e++,t=/[\da-fA-F]/);e<r.length;e++){if(r[e]===";")return e;if(!r[e].match(t))break}return-1}function Wt(r,e){if(e++,r[e]===";")return-1;if(r[e]==="#")return e++,zt(r,e);let t=0;for(;e<r.length;e++,t++)if(!(r[e].match(/\w/)&&t<20)){if(r[e]===";")break;return-1}return e}function T(r,e,t){return{err:{code:r,msg:e,line:t.line||t,col:t.col}}}function Qt(r){return je(r)}function Kt(r){return je(r)}function A(r,e){let t=r.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function ae(r){return r.startIndex+r[1].length}var Ue={cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",euro:"\u20AC",dollar:"$",fnof:"\u0192",inr:"\u20B9",af:"\u060B",birr:"\u1265\u122D",peso:"\u20B1",rub:"\u20BD",won:"\u20A9",yuan:"\xA5",cedil:"\xB8"};var le={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},Be={nbsp:"\xA0",copy:"\xA9",reg:"\xAE",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xAB",raquo:"\xBB",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",bull:"\u2022",para:"\xB6",sect:"\xA7",deg:"\xB0",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE"};var Q=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),Jt=new Set("!?\\\\/[]$%{}^&*()<>|+");function Ct(r){if(r[0]==="#")throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${r}"`);for(let e of r)if(Jt.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${r}"`);return r}function ce(...r){let e=Object.create(null);for(let t of r)if(t)for(let i of Object.keys(t)){let n=t[i];if(typeof n=="string")e[i]=n;else if(n&&typeof n=="object"&&n.val!==void 0){let s=n.val;typeof s=="string"&&(e[i]=s)}}return e}var U="external",Fe="base",Ge="all";function Zt(r){return!r||r===U?new Set([U]):r===Ge?new Set([Ge]):r===Fe?new Set([Fe]):Array.isArray(r)?new Set(r):new Set([U])}var S=Object.freeze({allow:0,leave:1,remove:2,throw:3}),er=new Set([9,10,13]);function tr(r){if(!r)return{xmlVersion:1,onLevel:S.allow,nullLevel:S.remove};let e=r.xmlVersion===1.1?1.1:1,t=S[r.onNCR]??S.allow,i=S[r.nullNCR]??S.remove,n=Math.max(i,S.remove);return{xmlVersion:e,onLevel:t,nullLevel:n}}var de=class{constructor(e={}){this._limit=e.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof e.postCheck=="function"?e.postCheck:i=>i,this._limitTiers=Zt(this._limit.applyLimitsTo??U),this._numericAllowed=e.numericAllowed??!0,this._baseMap=ce(le,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(e.remove&&Array.isArray(e.remove)?e.remove:[]),this._leaveSet=new Set(e.leave&&Array.isArray(e.leave)?e.leave:[]);let t=tr(e.ncr);this._ncrXmlVersion=t.xmlVersion,this._ncrOnLevel=t.onLevel,this._ncrNullLevel=t.nullLevel,this._onExternalEntity=typeof e.onExternalEntity=="function"?e.onExternalEntity:null,this._onInputEntity=typeof e.onInputEntity=="function"?e.onInputEntity:null}_applyRegistrationHook(e,t,i,n){if(!e)return!0;let s=e(t,i);if(s===Q.BLOCK)return!1;if(s===Q.THROW)throw new Error(`[EntityDecoder] Registration of ${n} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(let n of Object.keys(e))Ct(n);if(!this._onExternalEntity){this._externalMap=ce(e);return}let t=ce(e),i=Object.create(null);for(let[n,s]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,n,s,"external")&&(i[n]=s);this._externalMap=i}addExternalEntity(e,t){Ct(e),typeof t=="string"&&t.indexOf("&")===-1&&this._applyRegistrationHook(this._onExternalEntity,e,t,"external")&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=ce(e);return}let t=ce(e),i=Object.create(null);for(let[n,s]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,n,s,"input")&&(i[n]=s);this._inputMap=i}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(e){this._ncrXmlVersion=e===1.1?1.1:1}decode(e){if(typeof e!="string"||e.length===0||e.indexOf("&")===-1)return e;let t=e,i=[],n=e.length,s=0,a=0,o=this._maxTotalExpansions>0,l=this._maxExpandedLength>0,d=o||l;for(;a<n;){if(e.charCodeAt(a)!==38){a++;continue}let p=a+1;for(;p<n&&e.charCodeAt(p)!==59&&p-a<=32;)p++;if(p>=n||e.charCodeAt(p)!==59){a++;continue}let u=e.slice(a+1,p);if(u.length===0){a++;continue}let f,h;if(this._removeSet.has(u))f="",h===void 0&&(h=U);else if(this._leaveSet.has(u)){a++;continue}else if(u.charCodeAt(0)===35){let m=this._resolveNCR(u);if(m===void 0){a++;continue}f=m,h=Fe}else{let m=this._resolveName(u);f=m?.value,h=m?.tier}if(f===void 0){a++;continue}if(a>s&&i.push(e.slice(s,a)),i.push(f),s=p+1,a=s,d&&this._tierCounts(h)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);
3if(l){let m=f.length-(u.length+2);if(m>0&&(this._expandedLength+=m,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}s<n&&i.push(e.slice(s));let c=i.length===0?e:i.join("");return this._postCheck(c,t)}_tierCounts(e){return this._limitTiers.has(Ge)?!0:this._limitTiers.has(e)}_resolveName(e){if(e in this._inputMap)return{value:this._inputMap[e],tier:U};if(e in this._externalMap)return{value:this._externalMap[e],tier:U};if(e in this._baseMap)return{value:this._baseMap[e],tier:Fe}}_classifyNCR(e){return e===0?this._ncrNullLevel:e>=55296&&e<=57343||this._ncrXmlVersion===1&&e>=1&&e<=31&&!er.has(e)?S.remove:-1}_applyNCRAction(e,t,i){switch(e){case S.allow:return String.fromCodePoint(i);case S.remove:return"";case S.leave:return;case S.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${t}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(e){let t=e.charCodeAt(1),i;if(t===120||t===88?i=parseInt(e.slice(2),16):i=parseInt(e.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;let n=this._classifyNCR(i);if(!this._numericAllowed&&n<S.remove)return;let s=n===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,n);return this._applyNCRAction(s,e,i)}};var wt=r=>oe.includes(r)?"__"+r:r,rr={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(r,e){return e},attributeValueProcessor:function(r,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(r,e,t){return r},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:wt};function ir(r,e){if(typeof r!="string")return;let t=r.toLowerCase();if(oe.some(i=>t===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);if(ve.some(i=>t===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Et(r,e){return typeof r=="boolean"?{enabled:r,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:typeof r=="object"&&r!==null?{enabled:r.enabled!==!1,maxEntitySize:Math.max(1,r.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,r.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,r.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,r.maxExpandedLength??1e5),maxEntityCount:Math.max(1,r.maxEntityCount??1e3),allowedTags:r.allowedTags??null,tagFilter:r.tagFilter??null,appliesTo:r.appliesTo??"all"}:Et(!0)}var At=function(r){let e=Object.assign({},rr,r),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(let{value:i,name:n}of t)i&&ir(i,n);return e.onDangerousProperty===null&&(e.onDangerousProperty=wt),e.processEntities=Et(e.processEntities,e.htmlEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(i=>typeof i=="string"&&i.startsWith("*.")?".."+i.substring(2):i)),e};var B;typeof Symbol!="function"?B="@@xmlMetadata":B=Symbol("XML Node Metadata");var I=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),this.addStartIndex(t)}addStartIndex(e){e!==void 0&&(this.child[this.child.length-1][B]={startIndex:e})}addEndIndex(e){let t=this.child[this.child.length-1];t!==void 0&&t[B]!==void 0&&t[B].endIndex===void 0&&(t[B].endIndex=e)}static getMetaDataSymbol(){return B}};var Nt=":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",nr=Nt+"\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040",St=":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}",sr=St+"\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040",He=(r,e,t="")=>{let i=r.replace(":",""),n=e.replace(":",""),s=`[${i}][${n}]*`;return{name:new RegExp(`^[${r}][${e}]*$`,t),ncName:new RegExp(`^${s}$`,t),qName:new RegExp(`^${s}(?::${s})?$`,t),nmToken:new RegExp(`^[${e}
3]+$`,t),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,t)}},or=He(Nt,nr),ar=He(St,sr,"u"),vt=":A-Za-z_",lr=vt+"\\-\\.\\d",cr=He(vt,lr),dr=(r="1.0",e=!1)=>e?cr:r==="1.1"?ar:or;var De=(r,{xmlVersion:e="1.0",asciiOnly:t=!1}={})=>dr(e,t).qName.test(r);var Le=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){let i=Object.create(null),n=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let s=1,a=!1,o=!1,l=null,d="";for(;t<e.length;t++){if(l!==null){e[t]===l&&(l=null),d+=e[t];continue}if(!a&&!o&&(e[t]==='"'||e[t]==="'")){l=e[t],d+=e[t];continue}if(e[t]==="<"&&!o){if(a&&G(e,"!ENTITY",t)){t+=7;let c,p;if([c,p,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),p.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[c]=p,n++}}else if(a&&G(e,"!ELEMENT",t)){t+=8;let{index:c}=this.readElementExp(e,t+1);t=c}else if(a&&G(e,"!ATTLIST",t))t+=8;else if(a&&G(e,"!NOTATION",t)){t+=9;let{index:c}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=c}else if(G(e,"!--",t))o=!0;else throw new Error("Invalid DOCTYPE");s++,d=""}else if(e[t]===">"){if(o?e[t-1]==="-"&&e[t-2]==="-"&&(o=!1,s--):s--,s===0)break}else e[t]==="["?a=!0:d+=e[t]}if(l!==null||s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:i,i:t}}readEntityExp(e,t){t=v(e,t);let i=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let n=e.substring(i,t);if(pe(n,{xmlVersion:this.xmlVersion}),t=v(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let s="";if([t,s]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[n,s,t]}
3readNotationExp(e,t){t=v(e,t);let i=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let n=e.substring(i,t);!this.suppressValidationErr&&pe(n,{xmlVersion:this.xmlVersion}),t=v(e,t);let s=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&s!=="SYSTEM"&&s!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);t+=s.length,t=v(e,t);let a=null,o=null;if(s==="PUBLIC")[t,a]=this.readIdentifierVal(e,t,"publicIdentifier"),t=v(e,t),(e[t]==='"'||e[t]==="'")&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(s==="SYSTEM"&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,i){let n="",s=e[t];if(s!=='"'&&s!=="'")throw new Error(`Expected quoted string, found "${s}"`);t++;let a=t;for(;t<e.length&&e[t]!==s;)t++;if(n=e.substring(a,t),e[t]!==s)throw new Error(`Unterminated ${i} value`);return t++,[t,n]}readElementExp(e,t){t=v(e,t);let i=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let n=e.substring(i,t);if(!this.suppressValidationErr&&!De(n,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${n}"`);t=v(e,t);let s="";if(e[t]==="E"&&G(e,"MPTY",t))t+=4;else if(e[t]==="A"&&G(e,"NY",t))t+=2;else if(e[t]==="("){t++;let a=t;for(;t<e.length&&e[t]!==")";)t++;if(s=e.substring(a,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:n,contentModel:s.trim(),index:t}}readAttlistExp(e,t){t=v(e,t);let i=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let n=e.substring(i,t);for(pe(n,{xmlVersion:this.xmlVersion}),t=v(e,t),i=t;t<e.length&&!/\s/.test(e[t]);)t++;let s=e.substring(i,t);if(!pe(s,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${s}"`);t=v(e,t);let a="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(a="NOTATION",t+=8,t=v(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let l=[];for(;t<e.length&&e[t]!==")";){let d=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let c=e.substring(d,t);if(c=c.trim(),!pe(c,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${c}"`);l.push(c),e[t]==="|"&&(t++,t=v(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,a+=" ("+l.join("|")+")"}else{let l=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;a+=e.substring(l,t);let d=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!d.includes(a.toUpperCase()))throw new Error(`Invalid attribute type: "${a}"`)}t=v(e,t);let o="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(o="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(o="#IMPLIED",t+=7):[t,o]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:n,attributeName:s,attributeType:a,defaultValue:o,index:t}}};var v=(r,e)=>{for(;e<r.length&&/\s/.test(r[e]);)e++;return e};function G(r,e,t){for(let i=0;i<e.length;i++)if(e[i]!==r[t+i+1])return!1;return!0}function pe(r,e){if(De(r,{xmlVersion:e}))return r;throw new Error(`Invalid entity name ${r}`)}var pr=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],Ie=255,ke=new Map,Ft=65535,Lt=1632,K=Lt,ur=Ft-Lt+1,Oe=new Uint8Array(ur).fill(Ie);for(let r of pr)for(let e=0;e<10;e++){let t=r+e;t<=Ft?Oe[t-K]=e:ke.set(t,e)}var It=48,kt=57,Ot=45,Re=new Set([8722,65293,65123]);function fr(r){if(typeof r!="string")return r;let e=r.length;if(e===0)return r;let t=-1;for(let n=0;n<e;n++){let s=r.charCodeAt(n);if(!(s>
3=It&&s<=kt||s===Ot)){if(s<K){if(Re.has(s)){t=n;break}continue}if(s>=55296&&s<=56319){if(n+1<e){let a=r.charCodeAt(n+1);if(a>=56320&&a<=57343){let o=65536+(s-55296<<10)+(a-56320);if(ke.has(o)){t=n;break}}}continue}if(Oe[s-K]!==Ie||Re.has(s)){t=n;break}}}if(t===-1)return r;let i=[];t>0&&i.push(r.slice(0,t));for(let n=t;n<e;n++){let s=r.charCodeAt(n);if(s>=It&&s<=kt||s===Ot){i.push(r[n]);continue}if(s<K){i.push(Re.has(s)?"-":r[n]);continue}if(s>=55296&&s<=56319){if(n+1<e){let o=r.charCodeAt(n+1);if(o>=56320&&o<=57343){let l=65536+(s-55296<<10)+(o-56320),d=ke.get(l);if(d!==void 0){i.push(String.fromCharCode(d+48)),n++;continue}}}i.push(r[n]);continue}if(Re.has(s)){i.push("-");continue}let a=Oe[s-K];i.push(a!==Ie?String.fromCharCode(a+48):r[n])}return i.join("")}var Rt=fr;var hr=/^[-+]?0x[a-fA-F0-9]+$/,mr=/^0b[01]+$/,gr=/^0o[0-7]+$/,br=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,yr={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function Ye(r,e={}){if(e=Object.assign({},yr,e),!r||typeof r!="string")return r;let t=r.trim();if(t.length===0)return r;if(e.skipLike!==void 0&&e.skipLike.test(t))return r;if(t==="0"||e.unicode&&(t=Rt(t),t==="0"))return 0;if(e.hex&&hr.test(t))return Xe(t,16);if(e.binary&&mr.test(t))return Xe(t,2);if(e.octal&&gr.test(t))return Xe(t,8);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return _r(r,t,e);{let i=br.exec(t);if(i){let n=i[1]||"",s=i[2],a=xr(i[3]),o=n?r[s.length+1]===".":r[s.length]===".";if(!e.leadingZeros&&(s.length>1||s.length===1&&!o))return r;{let l=Number(t),d=String(l);if(l===0)return l;if(d.search(/[eE]/)!==-1)return e.eNotation?l:r;if(t.indexOf(".")!==-1)return d==="0"||d===a||d===`${n}${a}`?l:r;let c=s?a:t;return s?c===d||n+c===d?l:r:c===d||c===n+d?l:r}}else return r}}else return Cr(r,Number(t),e)}var Tr=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function _r(r,e,t){if(!t.eNotation)return r;let i=e.match(Tr);if(i){let n=i[1]||"",s=i[3].indexOf("e")===-1?"E":"e",a=i[2],o=n?r[a.length+1]===s:r[a.length]===s;return a.length>1&&o?r:a.length===1&&(i[3].startsWith(`.${s}`)||i[3][0]===s)?Number(e):a.length>0?t.leadingZeros&&!o?(e=(i[1]||"")+i[3],Number(e)):r:Number(e)}else return r}function xr(r){if(r&&r.indexOf(".")!==-1){let e=r.length;for(;e>0&&r.charCodeAt(e-1)===48;)e--;return r=r.slice(0,e),r==="."?r="0":r[0]==="."?r="0"+r:r[r.length-1]==="."&&(r=r.substring(0,r.length-1)),r}return r}function Xe(r,e){let t=r.trim();if((e===2||e===8)&&(r=t.substring(2)),parseInt)return parseInt(r,e);if(Number.parseInt)return Number.parseInt(r,e);if(window&&window.parseInt)return window.parseInt(r,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Cr(r,e,t){let i=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return i?"Infinity":"-Infinity";default:return r}}function ze(r){return typeof r=="function"?r:Array.isArray(r)?e=>{for(let t of r)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}var J=class{constructor(e,t={},i){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this.data=i,this._hasDeepWildcard=this.segments.some(n=>n.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(n=>n.attrName!==void 0),this._hasPositionSelector=this.segments.some(n=>n.position!==void 0)}_parse(e){let t=[],i=0,n="";for(;i<e.length;)e[i]===this.separator?i+1<e.length&&e[i+1]===this.separator?(n.trim()&&(t.push(this._parseSegment(n.trim())),n=""),t.push({type:"deep-wildcard"}),i+=2):(n.trim()&&t.push(this._parseSegment(n.trim())),n="",i++):(n+=e[i],i++);return n.trim()&&t.push(this._parseSegment(n.trim())),t}_parseSegment(e){let t={type:"tag"},i=null,n=e,s=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(n=s[1]+s[3],s[2])){let c=s[2].slice(1,-1);c&&(i=c)}let a,o=n;if(n.includes("::")){let c=n.indexOf("::");if(a=n.substring(0,c).trim(),o=n.substring(c+2).trim(),!a)throw new Error(`Invalid namespace in pattern: ${e}`)}let l,d=null;if(o.includes(":")){let c=o.lastIndexOf(":"),p=o.substring(0,c).trim(),u=o.substring(c+1).trim();["first","last","odd","even"].includes(u)||/^nth\(\d+\)$/.test(u)?(l=p,d=u):l=o}else l=o;if(!l)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=l,a&&(t.namespace=a),i)if(i.includes("=")){let c=i.indexOf("=");t.attrName=i.substring(0,c).trim(),t.attrValue=i.substring(c+1).trim()}else t.attrName=i.trim();if(d){let c=d.match(/^nth\((\d+)\)$/);c?(t.position="nth",t.positionValue=parseInt(c[1],10)):t.position=d}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var ue=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){let s=e.segments[e.segments.length-1];if(s&&s.type!=="deep-wildcard"&&s.tag!=="*"){let a=s.tag;this._deepByTerminalTag.has(a)||this._deepByTerminalTag.set(a,[]),this._deepByTerminalTag.get(a).push(e)}else this._deepWildcards.push(e);return this}let t=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n==="*")this._wildcardByDepth.has(t)||this._wildcardByDepth.set(t,[]),this._wildcardByDepth.get(t).push(e);else{let s=`${t}:${n}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(e)}return this}addAll(e){for(let t of e)this.add(t);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let t=e.getDepth(),i=e.getCurrentTag(),n=`${t}:${i}`,s=this._byDepthAndTag.get(n);if(s){for(let l=0;l<s.length;l++)if(e.matches(s[l]))return s[l]}let a=this._wildcardByDepth.get(t);if(a){for(let l=0;l<a.length;l++)if(e.matches(a[l]))return a[l]}let o=this._deepByTerminalTag.get(i);if(o){for(let l=0;l<o.length;l++)if(e.matches(o[l]))return o[l]}for(let l=0;l<this._deepWildcards.length;l++)if(e.matches(this._deepWildcards[l]))return this._deepWildcards[l];return null}};var We=class{constructor(e){this._matcher=e}get separator(){return this._matcher.separator}getCurrentTag(){let e=this._matcher.path;return e.length>0?e[e.length-1].tag:void 0}getCurrentNamespace(){let e=this._matcher.path;return e.length>0?e[e.length-1].namespace:void 0}getAttrValue(e){let t=this._matcher.path;if(t.length!==0)return t[t.length-1].values?.[e]}hasAttr(e){let t=this._matcher.path;if(t.length===0)return!1;let i=t[t.length-1];return i.values!==void 0&&e in i.values}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}getPosition(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].position??0}getCounter(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(e,t=!0){return this._matcher.toString(e,t)}toArray(){return this._matcher.path.map(e=>e.tag)}matches(e){return this._matcher.matches(e)}matchesAny(e){return e.matchesAny(this._matcher)}},fe=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new We(this),this._keptAttrs=[]}push(e,t=null,i=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let s=this.path.length,a=this.siblingStacks[s];a||(a={counts:new Map,total:0},this.siblingStacks[s]=a);let o=i?`${i}:${e}`:e,l=a.counts.get(o)||0,d=a.total;a.counts.set(o,l+1),a.total++;let c={tag:e,position:d,counter:l};i!=null&&(c.namespace=i),t!=null&&(c.values=t),this.path.push(c);let p=this.path.length,u=n!==null?n.keep:null;if(u!=null&&u.length>0&&t)for(let f=0;f<u.length;f++){let h=u[f];t[h]!==void 0&&this._keptAttrs.push({depth:p,name:h,value:t[h]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);let t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getAnyParentAttr(e){let t=this._keptAttrs;for(let i=t.length-1;i>=0;i--)if(t[i].name===e)return t[i].value}hasAnyParentAttr(e){let t=this._keptAttrs;for(let i=t.length-1;i>=0;i--)if(t[i].name===e)return!0;return!1}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let i=e||this.separator;if(i===this.separator&&t===!0){if(this._pathStringCache!==null)return this._pathStringCache;let s=this.path.map(a=>a.namespace?`${a.namespace}:${a.tag}`:a.tag).join(i);return this._pathStringCache=s,s}return this.path.map(s=>t&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(i)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++)if(!this._matchSegment(e[t],this.path[t],t===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,i=e.length-1;for(;i>=0&&t>=0;){let n=e[i];if(n.type==="deep-wildcard"){if(i--,i<0)return!0;let s=e[i],a=!1;for(let o=t;o>=0;o--)if(this._matchSegment(s,this.path[o],o===this.path.length-1)){t=o-1,i--,a=!0;break}if(!a)return!1}else{if(!this._matchSegment(n,this.path[t],t===this.path.length-1))return!1;t--,i--}}return i<0}_matchSegment(e,t,i){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace||e.attrName!==void 0&&(!i||!t.values||!(e.attrName in t.values)||e.attrValue!==void 0&&String(t.values[e.attrName])!==String(e.attrValue)))return!1;if(e.position!==void 0){if(!i)return!1;let n=t.counter??0;if(e.position==="first"&&n!==0)return!1;if(e.position==="odd"&&n%2!==1)return!1;if(e.position==="even"&&n%2!==0)return!1;if(e.position==="nth"&&n!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}
3snapshot(){return{path:this.path.map(e=>F({},e)),siblingStacks:this.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),keptAttrs:this._keptAttrs.map(e=>F({},e))}}restore(e){this._pathStringCache=null,this.path=e.path.map(t=>F({},t)),this.siblingStacks=e.siblingStacks.map(t=>t&&{counts:new Map(t.counts),total:t.total}),this._keptAttrs=(e.keptAttrs||[]).map(t=>F({},t))}readOnly(){return this._view}};var wr=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI \u2014 can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI \u2014 can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. <script or <script)",pattern:/(?:�*3[Cc];?|�*60;?|<)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial \u2014 catches common j or j for "j")',pattern:/(?:�*6[Aa];?|�*106;?)\s*(?:�*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() \u2014 IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= \u2014 can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" \u2014 can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes \u2014 embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag \u2014 can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],Z=wr;var Er=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content \u2014 can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword \u2014 used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword \u2014 used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration \u2014 defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection \u2014 can redefine namespaces to confuse parsers",pattern:/\bxmlns(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"<!-- comment injection \u2014 can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--> closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],ee=Er;var Ar=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: \u2014 classic SVG XSS via <a> or <use>
3",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG \u2014 can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" \u2014 can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." \u2014 sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= \u2014 filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}
3(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],Qe=Ar;var Nr=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ \u2014 unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT \u2014 most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO \u2014 data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM \u2014 data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET \u2014 data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ \u2014 MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function \u2014 used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA \u2014 reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],he=Nr;var Sr=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ \u2014 climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ \u2014 climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 \u2014 truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} \u2014 can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/}
3,{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r \u2014 can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? \u2014 can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags \u2014 can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],Ke=Sr;var vr=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ \u2014 catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) \u2014 guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ \u2014 ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern \u2014 triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} \u2014 repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} \u2014 denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches \u2014 polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],Je=vr;var k=`["'\\s]*:`,Fr=[{id:"nosql-where-operator",description:"$where \u2014 executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${k}`,"i")},{id:"nosql-ne-operator",description:'$ne \u2014 "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${k}`,"i")},{id:"nosql-gt-operator",description:'$gt \u2014 "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${k}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte \u2014 "less than" bypass variants',pattern:new RegExp(`\\$lte?${k}`,"i")},{id:"nosql-regex-operator",description:"$regex \u2014 can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${k}`,"i")},{id:"nosql-or-operator",description:"$or \u2014 logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${k}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and \u2014 logical AND operator injection",pattern:new RegExp(`\\$and${k}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor \u2014 logical NOR operator injection",pattern:new RegExp(`\\$nor${k}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists \u2014 can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${k}`,"i")},{id:"nosql-in-operator",description:"$in \u2014 matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${k}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr \u2014 allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${k}`,"i")},{id:"nosql-function-operator",description:"$function \u2014 executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${k}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator \u2014 custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${k}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ \u2014 prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype \u2014 alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] \u2014 bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],Ze=Fr;var Lr=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A \u2014 decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} \u2014 data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} \u2014 Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} \u2014 Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} \u2014 JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> \u2014 Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 \u2014 can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ \u2014 can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}],et=Lr;var Ir=[{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],kr=[...he,...Ir],tt=kr;Z.label="HTML";ee.label="XML";Qe.label="SVG";he.label="SQL";tt.label="SQL-STRICT";Ke.label="SHELL";Je.label="REDOS";Ze.label="NOSQL";et.label="LOG";var vn=Object.freeze({HTML:Z,XML:ee,SVG:Qe,SQL:he,"SQL-STRICT":tt,SHELL:Ke,REDOS:Je,NOSQL:Ze,LOG:et});function Or(r){if(typeof r!="string")throw new TypeError(`is-unsafe: first argument must be a string, got ${typeof r}`)}function Rr(r){if(!(r instanceof RegExp)){if(Array.isArray(r)){if(r.length===0)throw new TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(r[0])){for(let e of r)if(!Array.isArray(e)||e.length===0)throw new TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}return}throw new TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof r}`)}}function Mr(r){return r instanceof RegExp?{lists:null,regex:r}:Array.isArray(r[0])?{lists:r,regex:null}:{lists:[r],regex:null}}function Pr(r,e){let t=e.label??"CUSTOM";for(let i of e)if(i.pattern.test(r))return{context:t,id:i.id,description:i.description,pattern:i.pattern};return null}function Mt(r,e){Or(r),Rr(e);let{lists:t,regex:i}=Mr(e);if(i)return i.test(r);for(let n of t)if(Pr(r,n)!==null)return!0;return!1}function Vr(r,e){if(!r)return{};let t=e.attributesGroupName?r[e.attributesGroupName]:r;if(!t)return{};let i={};for(let n in t)if(n.startsWith(e.attributeNamePrefix)){let s=n.substring(e.attributeNamePrefix.length);i[s]=t[n]}else i[n]=t[n];return i}function qr(r){if(!r||typeof r!="string")return;let e=r.indexOf(":");if(e!==-1&&e>0){let t=r.substring(0,e);if(t!=="xmlns")return t}}var Me=class{constructor(e,t){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Gr,this.parseTextData=$r,this.resolveNameSpace=jr,this.buildAttributesMap=Br,this.isItStopNode=Yr,this.replaceEntitiesValue=Dr,this.readStopNodeData=Qr,this.saveTextToParentTag=Xr,this.addChild=Hr,this.ignoreAttributesFn=ze(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let i=F({},le);this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities=="object"?i=this.options.htmlEntities:this.options.htmlEntities===!0&&(i=F(F({},Be),Ue)),this.entityDecoder=new de({namedEntities:F(F({},i),t),numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(s,a)=>Mt(a,[Z,ee])?Q.BLOCK:Q.ALLOW})),this.matcher=new fe,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ue;let n=this.options.stopNodes;if(n&&n.length>0){for(let s=0;s<n.length;s++){let a=n[s];
3typeof a=="string"?this.stopNodeExpressionsSet.add(new J(a)):a instanceof J&&this.stopNodeExpressionsSet.add(a)}this.stopNodeExpressionsSet.seal()}}};function $r(r,e,t,i,n,s,a){let o=this.options;if(r!==void 0&&(o.trimValues&&!i&&(r=r.trim()),r.length>0)){a||(r=this.replaceEntitiesValue(r,e,t));let l=o.jPath?t.toString():t,d=o.tagValueProcessor(e,r,l,n,s);return d==null?r:typeof d!=typeof r||d!==r?d:o.trimValues||r.trim()===r?nt(r,o.parseTagValue,o.numberParseOptions):r}}function jr(r){if(this.options.removeNSPrefix){let e=r.split(":"),t=r.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(r=t+e[1])}return r}var Ur=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Br(r,e,t,i=!1){let n=this.options;if(i===!0||n.ignoreAttributes!==!0&&typeof r=="string"){let s=gt(r,Ur),a=s.length,o={},l=new Array(a),d=!1,c={};for(let f=0;f<a;f++){let h=this.resolveNameSpace(s[f][1]),m=s[f][4];if(h.length&&m!==void 0){let g=m;n.trimValues&&(g=g.trim()),g=this.replaceEntitiesValue(g,t,this.readonlyMatcher),l[f]=g,c[h]=g,d=!0}}d&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(c);let p=n.jPath?e.toString():this.readonlyMatcher,u=!1;for(let f=0;f<a;f++){let h=this.resolveNameSpace(s[f][1]);if(this.ignoreAttributesFn(h,p))continue;let m=n.attributeNamePrefix+h;if(h.length)if(n.transformAttributeName&&(m=n.transformAttributeName(m)),m=Pt(m,n),s[f][4]!==void 0){let g=l[f],_=n.attributeValueProcessor(h,g,p);_==null?o[m]=g:typeof _!=typeof g||_!==g?o[m]=_:o[m]=nt(g,n.parseAttributeValue,n.numberParseOptions),u=!0}else n.allowBooleanAttributes&&(o[m]=!0,u=!0)}if(!u)return;if(n.attributesGroupName&&!n.preserveOrder){let f={};return f[n.attributesGroupName]=o,f}return o}}var Gr=function(r){r=r.replace(/\r\n?/g,` 4`);let e=new I("!xml"),t=e,i="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let n=this.options,s=new Le(n.processEntities),a=r.length;for(let o=0;o<a;o++)if(r[o]==="<"){let d=r.charCodeAt(o+1);if(d===47){let c=te(r,">",o,"Closing Tag is not closed."),p=r.substring(o+2,c).trim();if(n.removeNSPrefix){let f=p.indexOf(":");f!==-1&&(p=p.substr(f+1))}p=rt(n.transformTagName,p,"",n).tagName,t&&(i=this.saveTextToParentTag(i,t,this.readonlyMatcher));let u=this.matcher.getCurrentTag();if(p&&n.unpairedTagsSet.has(p))throw new Error(`Unpaired tag can not be used as closing tag: </${p}>`);u&&n.unpairedTagsSet.has(u)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop()||e,n.captureMetaData&&t&&t.addEndIndex(c+1),i="",o=c}else if(d===63){let c=it(r,o,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");i=this.saveTextToParentTag(i,t,this.readonlyMatcher);let p=this.buildAttributesMap(c.tagExp,this.matcher,c.tagName,!0);if(p){let u=p[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(u)||1),s.setXmlVersion(Number(u)||1)}if(!(n.ignoreDeclaration&&c.tagName==="?xml"||n.ignorePiTags)){let u=new I(c.tagName);u.add(n.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&n.ignoreAttributes!==!0&&(u[":@"]=p),this.addChild(t,u,this.readonlyMatcher,o),n.captureMetaData&&t.addEndIndex(c.closeIndex+2)}o=c.closeIndex+1}else if(d===33&&r.charCodeAt(o+2)===45&&r.charCodeAt(o+3)===45){let c=te(r,"-->",o+4,"Comment is not closed.");if(n.commentPropName){let p=r.substring(o+4,c-2);i=this.saveTextToParentTag(i,t,this.readonlyMatcher),t.add(n.commentPropName,[{[n.textNodeName]:p}])}o=c}else if(d===33&&r.charCodeAt(o+2)===68){if(this.doctypefound)throw new Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;let c=s.readDocType(r,o);this.entityDecoder.addInputEntities(c.entities),o=c.i}else if(d===33&&r.charCodeAt(o+2)===91){let c=te(r,"]]>",o,"CDATA is not closed.")-2,p=r.substring(o+9,c);i=this.saveTextToParentTag(i,t,this.readonlyMatcher);let u=this.parseTextData(p,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);u==null&&(u=""),n.cdataPropName?t.add(n.cdataPropName,[{[n.textNodeName]:p}]):t.add(n.textNodeName,u),o=c+2}else{let c=it(r,o,n.removeNSPrefix);if(!c){let N=r.substring(Math.max(0,o-50),Math.min(a,o+50));throw new Error(`readTagExp returned undefined at position ${o}. Context: "${N}"`)}let p=c.tagName,u=c.rawTagName,f=c.tagExp,h=c.attrExpPresent,m=c.closeIndex;if({tagName:p,tagExp:f}=rt(n.transformTagName,p,f,n),n.strictReservedNames&&(p===n.commentPropName||p===n.cdataPropName||p===n.textNodeName||p===n.attributesGroupName))throw new Error(`Invalid tag name: ${p}`);t&&i&&t.tagname!=="!xml"&&(i=this.saveTextToParentTag(i,t,this.readonlyMatcher,!1));let g=t;g&&n.unpairedTagsSet.has(g.tagname)&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let _=!1;f.length>0&&f.lastIndexOf("/")===f.length-1&&(_=!0,p[p.length-1]==="/"?(p=p.substr(0,p.length-1),f=p):f=f.substr(0,f.length-1),h=p!==f);let E=null,H={},me;
4me=qr(u),p!==e.tagname&&this.matcher.push(p,{},me),p!==f&&h&&(E=this.buildAttributesMap(f,this.matcher,p),E&&(H=Vr(E,n))),p!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let ge=o;if(this.isCurrentNodeStopNode){let N="";if(_)o=c.closeIndex;else if(n.unpairedTagsSet.has(p))o=c.closeIndex;else{let Ve=this.readStopNodeData(r,u,m+1);if(!Ve)throw new Error(`Unexpected end of ${u}`);o=Ve.i,N=Ve.tagContent}let Pe=new I(p);E&&(Pe[":@"]=E),Pe.add(n.textNodeName,N),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,Pe,this.readonlyMatcher,ge),n.captureMetaData&&t.addEndIndex(o+1)}else{if(_){({tagName:p,tagExp:f}=rt(n.transformTagName,p,f,n));let N=new I(p);E&&(N[":@"]=E),this.addChild(t,N,this.readonlyMatcher,ge),n.captureMetaData&&t.addEndIndex(m+1),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(n.unpairedTagsSet.has(p)){let N=new I(p);E&&(N[":@"]=E),this.addChild(t,N,this.readonlyMatcher,ge),n.captureMetaData&&t.addEndIndex(c.closeIndex+1),this.matcher.pop(),this.isCurrentNodeStopNode=!1,o=c.closeIndex;continue}else{let N=new I(p);if(this.tagsNodeStack.length>n.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(N[":@"]=E),this.addChild(t,N,this.readonlyMatcher,ge),t=N}i="",o=m}}}else i+=r[o];return e.child};function Hr(r,e,t,i){this.options.captureMetaData||(i=void 0);let n=this.options.jPath?t.toString():t,s=this.options.updateTag(e.tagname,n,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),r.addChild(e,i))}function Dr(r,e,t){let i=this.options.processEntities;if(!i||!i.enabled)return r;if(i.allowedTags){let n=this.options.jPath?t.toString():t;if(!(Array.isArray(i.allowedTags)?i.allowedTags.includes(e):i.allowedTags(e,n)))return r}if(i.tagFilter){let n=this.options.jPath?t.toString():t;if(!i.tagFilter(e,n))return r}return this.entityDecoder.decode(r)}function Xr(r,e,t,i){return r&&(i===void 0&&(i=e.child.length===0),r=this.parseTextData(r,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,i),r!==void 0&&r!==""&&e.add(this.options.textNodeName,r),r=""),r}function Yr(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function zr(r,e,t=">"){let i=0,n=r.length,s=t.charCodeAt(0),a=t.length>1?t.charCodeAt(1):-1,o="",l=e;for(let d=e;d<n;d++){let c=r.charCodeAt(d);if(i)c===i&&(i=0);else if(c===34||c===39)i=c;else if(c===s)if(a!==-1){if(r.charCodeAt(d+1)===a)return o+=r.substring(l,d),{data:o,index:d}}else return o+=r.substring(l,d),{data:o,index:d};else c===9&&!i&&(o+=r.substring(l,d)+" ",l=d+1)}}function te(r,e,t,i){let n=r.indexOf(e,t);if(n===-1)throw new Error(i);return n+e.length-1}function Wr(r,e,t,i){let n=r.indexOf(e,t);if(n===-1)throw new Error(i);return n}function it(r,e,t,i=">"){let n=zr(r,e+1,i);if(!n)return;let s=n.data,a=n.index,o=s.search(/\s/),l=s,d=!0;o!==-1&&(l=s.substring(0,o),s=s.substring(o+1).trimStart());let c=l;if(t){let p=l.indexOf(":");p!==-1&&(l=l.substr(p+1),d=l!==n.data.substr(p+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:d,rawTagName:c}}function Qr(r,e,t){let i=t,n=1,s=r.length;for(;t<s;t++)if(r[t]==="<"){let a=r.charCodeAt(t+1);if(a===47){let o=Wr(r,">",t,`${e} is not closed`);if(r.substring(t+2,o).trim()===e&&(n--,n===0))return{tagContent:r.substring(i,t),i:o};t=o}else if(a===63)t=te(r,"?>",t+1,"StopNode is not closed.");else if(a===33&&r.charCodeAt(t+2)===45&&r.charCodeAt(t+3)===45)t=te(r,"-->",t+3,"StopNode is not closed.");else if(a===33&&r.charCodeAt(t+2)===91)t=te(r,"]]>",t,"StopNode is not closed.")-2;else{let o=it(r,t,!1);o&&((o&&o.tagName)===e&&o.tagExp[o.tagExp.length-1]!=="/"&&n++,t=o.closeIndex)}}}function nt(r,e,t){if(e&&typeof r=="string"){let i=r.trim();return i==="true"?!0:i==="false"?!1:Ye(r,t)}else return bt(r)?r:""}function rt(r,e,t,i){if(r){let n=r(e);t===e&&(t=n),e=n}return e=Pt(e,i),{tagName:e,tagExp:t}}function Pt(r,e){if(ve.includes(r))throw new Error(`[SECURITY] Invalid name: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);return oe.includes(r)?e.onDangerousProperty(r):r}var st=I.getMetaDataSymbol();function Kr(r,e){if(!r||typeof r!="object")return{};if(!e)return r;let t={};for(let i in r)if(i.startsWith(e)){let n=i.substring(e.length);t[n]=r[i]}else t[i]=r[i];return t}function ot(r,e,t,i){return Vt(r,e,t,i)}function Vt(r,e,t,i){let n,s={};for(let a=0;a<r.length;a++){let o=r[a],l=Jr(o);if(l!==void 0&&l!==e.textNodeName){let d=Kr(o[":@"]||{},e.attributeNamePrefix);t.push(l,d)}if(l===e.textNodeName)n===void 0?n=o[l]:n+=""+o[l];else{if(l===void 0)continue;if(o[l]){let d=Vt(o[l],e,t,i),c=ei(d,e);if(Object.keys(d).length===0&&e.alwaysCreateTextNode&&(d[e.textNodeName]=""),o[":@"]?Zr(d,o[":@"],i,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),o[st]!==void 0&&typeof d=="object"&&d!==null&&(d[st]=o[st]),s[l]!==void 0&&Object.prototype.hasOwnProperty.call(s,l))Array.isArray(s[l])||(s[l]=[s[l]]),s[l].push(d);else{let p=e.jPath?i.toString():i;e.isArray(l,p,c)?s[l]=[d]:s[l]=d}l!==void 0&&l!==e.textNodeName&&t.pop()}}}return typeof n=="string"?n.length>0&&(s[e.textNodeName]=n):n!==void 0&&(s[e.textNodeName]=n),s}function Jr(r){let e=Object.keys(r);for(let t=0;t<e.length;t++){let i=e[t];if(i!==":@")return i}}function Zr(r,e,t,i){if(e){let n=Object.keys(e),s=n.length;for(let a=0;a<s;a++){let o=n[a],l=o.startsWith(i.attributeNamePrefix)?o.substring(i.attributeNamePrefix.length):o,d=i.jPath?t.toString()+"."+l:t;i.isArray(o,d,!0,!0)?r[o]=[e[o]]:r[o]=e[o]}}}function ei(r,e){let{textNodeName:t}=e,i=Object.keys(r).length;return!!(i===0||i===1&&(r[t]||typeof r[t]=="boolean"||r[t]===0))}var re=class{constructor(e){this.externalEntities={},this.options=At(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});let s=xt(e,t);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let i=new Me(this.options,this.externalEntities),n=i.parseXml(e);return this.options.preserveOrder||n===void 0?n:ot(n,this.options,i.matcher,i.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return I.getMetaDataSymbol()}};var ie=(()=>{let e=class e{constructor(){this.httpClient=P(ut),this.templateCreated=new q(null),this.isTemplateReady=new q(!1),this.openApiCalls=new q([]),this.buildProgress=new q([]),this.formTemplateConditionGroups={},this.loadedTableMetadata={},this.loadedSubGrid={},this.loadedLookup={},this.errorMessage=new q(null),this.quickformTemplate=new q([]),this.templateTypes=[],this.subTableFormsToBeCreated=[],this.subTableFormsReady=[],this.subgridFields=[],this.optionFields=[],this.ngUnsubscribe=new be,this.isTemplateReady.pipe(D(this.ngUnsubscribe)).subscribe(i=>{if(i){let n=this.templateTypes.filter(s=>!!this.formTemplate[s]);if(console.log("templatesReady",this.formTemplate,this.templateTypes,n),n.length===this.templateTypes.length){if(this.addConditions(),this.getFieldForMetaData(),console.log("templatesReady - check templates to be created",this.subTableFormsToBeCreated,this.subTableFormsReady),this.subTableFormsToBeCreated.length){console.log("templatesReady - create template",this.subTableFormsToBeCreated[0].type),this.templateType=this.subTableFormsToBeCreated[0].type,this.createTemplate(this.subTableFormsToBeCreated[0].type,this.subTableFormsToBeCreated[0].subFormId,this.subTableFormsToBeCreated[0].metaTable,this.subTableFormsToBeCreated[0].field.relationshipName),this.subTableFormsReady.push(this.subTableFormsToBeCreated.shift());return}if(!this.subTableFormsToBeCreated.length){let s=this.formTemplate[this.templateTypes[0]],a=[];if(this.subTableFormsReady.length){this.subTableFormsReady.forEach(l=>{console.log("subTableForm",l),l.metadata.Attributes?.cs_fieldname&&l.metadata.Attributes?.cs_fieldvalue&&(console.log("map locked field",l.metadata,l.type),this.formTemplate[l.type].steps.forEach(d=>{d.sections.forEach(c=>{c.fields.forEach(p=>{p.fieldName==l.metadata.Attributes.cs_fieldname&&(p.value=l.metadata.Attributes.cs_fieldvalue)})})}))}),s.mainTableName=s.steps[0].tableName;let o=[];s.steps.forEach(l=>{console.log("main template",l.id);let d=!1;this.subTableFormsReady.forEach(c=>
4{if(console.log("loop sub tables",c.stepId),l.id===c.stepId)if(c.metadata?.Attributes?.cs_subgridaction=="717640000")l.sections.forEach(p=>{p.fields.forEach(u=>{u.type==="SubGridType"&&u.fieldName===c.metadata?.Attributes?.cs_regardingid&&(u.subFields=this.formTemplate[c.type].steps[0].sections[0].fields,c.metadata?.Attributes.cs_subgridlimit&&(console.log("setting subgrid limit",c.metadata?.Attributes.cs_subgridlimit),u.maxItems=c.metadata?.Attributes.cs_subgridlimit))})});else{console.log("concat steps here - "+l.id+" - "+c.type,JSON.parse(JSON.stringify(this.formTemplate[c.type].steps))),o=o.concat(this.formTemplate[c.type].steps),d=!0;let p=this.formTemplate[c.type].steps[0],u=a.find(f=>f.tableName==p.tableName);this.formTemplate[c.type].steps.length&&!u&&a.push({tableName:p.tableName,relationshipName:p.relationshipName})}}),d||(console.log("regular step - "+l.id),o.push(l))}),s.steps=o,s.subTables=a}this.ngUnsubscribe.next(void 0),this.ngUnsubscribe.complete(),console.log("main template",s),this.saveTemplate(s)}}}}),this.openApiCalls.pipe(D(this.ngUnsubscribe)).subscribe(i=>{!i.length&&this.formTemplate&&!this.subgridFields.length&&!this.optionFields&&this.isTemplateReady.next(!0)})}setFund(i){this.fund=i}setSubForm(i){this.subForm=i}createFundTemplate(i,n,s){return w(this,null,function*(){if(this.templateType=n,this.fund){this.createTemplate(n);return}this.pushToBuildProgress("Getting fund"),yield this.getFund(i,s),this.markProgressStageAsCompleted("Getting fund"),this.createTemplate(n)})}createProgrammeTemplate(i,n){this.templateType=n,this.pushToBuildProgress("Getting Programme"),this.httpClient.get(`forms/get-dynamics-programme/${i}`).subscribe(s=>{this.fund=s.data,console.log("fund",this.fund),this.markProgressStageAsCompleted("Getting Programme"),this.createTemplate(n)},s=>{this.setErrorMessage(s)})}createTemplate(i,n,s,a){return w(this,null,function*(){this.formTemplate||(this.formTemplate={});let o,l=this.fund.dynamics_id;switch(this.buildProgress.next([]),this.templateType||(this.templateType=i),this.templateTypes.push(i),console.log("FUND BEFORE CREATING TEMPLATE",this.fund,i,n,this.subForm),this.pushToBuildProgress(`Getting ${i} form`),i){case"application":s="cs_application",o=this.fund.cs_frontendformid;break;case"questionnaire":s="feedback",o=this.fund.cs_feedbackformid;break;case"annual-plan":s="cs_annualplan",o=this.fund.cs_frontendformid;break;case"annual-report":s="cs_annualreport",o=this.fund.cs_frontendformid;break;case"interim-report":s="cs_report",o=this.fund.cs_interimreportid;break;case"end-of-project-report":s="cs_report",o=this.fund.cs_eopreportid,l=this.subForm?this.subForm.Attributes.cs_fmsformid:this.fund.dynamics_id;break;case M.ANNUAL_PLAN_REPORT:s="cs__annualplan",o=n,l=this.subForm.Attributes.cs_fmsformid;break;case M.FAIR_WORK_PRO_FORMA_REPORT:s="cs_fairworkproforma",o=n,l=this.subForm.Attributes.cs_fmsformid;break;case M.ANNUAL_STATS_SURVEY_REPORT:s="cs_annualstatisticalsurvey",o=n,l=this.subForm.Attributes.cs_fmsformid;break}if(i.indexOf("subform-")!==-1&&(o=n,l=this.subForm.Attributes.cs_fmsformid,s=i==="subform-3"?"cs_fmsattributemetadata":"cs_application"),i.indexOf("subtable-form")!==-1&&(i=this.templateType,o=n,l=this.subForm?this.subForm.Attributes.cs_fmsformid:this.fund.cs_frontendformid),!s){this.errorMessage.next("<p>Form type not supported</p>");return}if(!o){this.errorMessage.next("<p>Form ID not found</p>");return}yield this.getBusinessFlows(o),yield this.getAttributesMetaData(l),this.formatFund(o,i,s,a)})}formatFund(i,n,s,a){return w(this,null,function*(){let o,l;if(s=String(s).toLowerCase(),l=yield this.getTableMetadata(s),console.log("table metadata",s,l),!!l)try{o=(yield ne(this.httpClient.get(`forms/get-fund-form/${i}`))).data,this.markProgressStageAsCompleted(`Getting ${n} form`),this.pushToBuildProgress("Building form template"),this.subgridFields=[],this.optionFields=[],this.formTemplate[this.templateType]=yield this.formatTemplate(o,l,this.fund,n,s,a),this.subgridFields.forEach(c=>this.completeSubGrid(c)),this.optionFields.forEach(c=>this.addOptionsToField(this.templateType,c.options,c.fieldName)),this.subgridFields=[],this.optionFields=[],this.markProgressStageAsCompleted("Building form template"),this.openApiCalls.getValue().length||this.isTemplateReady.next(!0)}catch(d){this.setErrorMessage(d)}})}getTableMetadata(i){return w(this,null,function*(){if(console.log("getTableMetadata",this.loadedTableMetadata,this.loadedTableMetadata[i]),this.loadedTableMetadata[i])return this.loadedTableMetadata[i];this.pushToBuildProgress(`Getting ${i} table meta data`);try{let n=yield ne(this.httpClient.get(`forms/get-table-meta-data/${i}`));return this.markProgressStageAsCompleted(`Getting ${i} table meta data`),console.log("response",n),this.loadedTableMetadata[i]=n.data,n.data}catch(n){this.setErrorMessage(n)}})}getSubGrid(i,n){return w(this,null,function*(){if(console.log("getSubGrid",this.loadedSubGrid,this.loadedSubGrid[i]),this.loadedSubGrid[i])return this.loadedSubGrid[i];this.pushToBuildProgress(`Getting "${n}" sub grid`);try{let s=yield ne(this.httpClient.get(`forms/get-sub-grid/${i}`));return this.markProgressStageAsCompleted(`Getting "${n}" sub grid`),console.log("response",s),this.loadedSubGrid[i]=s.data,s.data}catch(s){this.setErrorMessage(s)}})}getLookup(i){return w(this,null,function*(){if(console.log("getLookup",this.loadedLookup,this.loadedLookup[i]),this.loadedLookup[i])return this.loadedLookup[i];this.pushToBuildProgress(`Getting "${i}" lookup`);try{let n=yield ne(this.httpClient.get(`forms/get-lookup/${i}`));return this.markProgressStageAsCompleted(`Getting "${i}" lookup`),console.log("response",n),this.loadedLookup[i]=n.data,n.data}catch(n){this.setErrorMessage(n)}})}getBusinessFlows(i){return w(this,null,function*(){return new Promise((n,s)=>{this.pushToBuildProgress("Getting business flows"),this.httpClient.get(`forms/get-business-flow/${i}`).subscribe(a=>{this.markProgressStageAsCompleted("Getting business flows"),this.pushToBuildProgress("Formatting business flows");for(let o of a.data.value)if(o.statecode==1){let l=o.xaml,c=new re({ignoreAttributes:!1}).parse(l);console.log("json",z.normalizeNewlines(c)),this.formatBusinessFlow(z.normalizeNewlines(c),o.workflowid)}this.markProgressStageAsCompleted("Formatting business flows"),n()},a=>
4{this.setErrorMessage(a),s()})})})}getAttributesMetaData(i){return w(this,null,function*(){if(this.attributesMetaData)return this.attributesMetaData;this.pushToBuildProgress("Getting attributes meta data");try{let n=yield this.httpClient.get(`forms/get-attributes-metadata/${this.fund.department}/${i}`).toPromise();return this.markProgressStageAsCompleted("Getting attributes meta data"),console.log("ATTRIBUTES META DATA",n),this.attributesMetaData=n.data.Entities,this.attributesMetaData}catch(n){throw this.setErrorMessage(n),n}})}getFund(i,n){return w(this,null,function*(){try{let s=`forms/get-dynamics-fund/${i}/${n}`,a=yield this.httpClient.get(s).toPromise();return this.fund=a.data,console.log("fund",this.fund),this.fund}catch(s){this.setErrorMessage(s)}return null})}getSubForms(i){return w(this,null,function*(){try{this.pushToBuildProgress("Getting sub forms");let n=`forms/get-sub-forms/${this.fund.department}/${i}`,s=yield this.httpClient.get(n).toPromise();return this.markProgressStageAsCompleted("Getting sub forms"),console.log("Sub forms",s),s.data.Entities}catch(n){this.setErrorMessage(n)}return null})}pushToBuildProgress(i){this.buildProgress.next(this.buildProgress.getValue().concat([{progressStage:i,isCompleted:!1}]))}markProgressStageAsCompleted(i){let n=[...this.buildProgress.value];for(let s of n)s.progressStage==i&&(s.isCompleted=!0);this.buildProgress.next(n)}pushToOpenApiCalls(i,n){this.openApiCalls.next(this.openApiCalls.getValue().concat([{type:i,id:n}]))}closeApiCall(i,n){this.openApiCalls.next(this.openApiCalls.value.filter(s=>s.type!=i||s.id!=n))}saveTemplate(i){this.pushToBuildProgress("Saving template");let n=[{fund_id:i.fund_id,fund_name:i.fund_name,type:i.type,department:this.fund.fund_name?"fund":"programme"}];this.subForm&&(n[0].valid_from=this.subForm.Attributes.cs_startdate,n[0].valid_to=this.subForm.Attributes.cs_enddate,i.subFormName=this.subForm.FormattedValues.cs_formcategory,i.description=this.subForm.Attributes.cs_description,i.q1_valid_from=this.subForm.Attributes.cs_q1startdate,i.q1_valid_to=this.subForm.Attributes.cs_q1enddate,i.q2_valid_from=this.subForm.Attributes.cs_q2startdate,i.q2_valid_to=this.subForm.Attributes.cs_q2enddate,i.q3_valid_from=this.subForm.Attributes.cs_q3startdate,i.q3_valid_to=this.subForm.Attributes.cs_q3enddate,i.q4_valid_from=this.subForm.Attributes.cs_q4startdate,i.q4_valid_to=this.subForm.Attributes.cs_q4enddate),(i.type==="annual-plan"||i.type==="annual-report")&&(n[0].department="rfo"),n[0].template=JSON.stringify(i),this.httpClient.post("forms/save-template",n).subscribe(s=>{this.markProgressStageAsCompleted("Saving template"),this.templateCreated.next(s.message)},s=>{this.setErrorMessage(s)})}formatTemplate(i,n,s,a,o,l){return w(this,null,function*(){let d={fund_id:s.id,fund_name:s.fund_name,type:a,steps:[]};if(i.tabs.tab instanceof Array)for(let c of i.tabs.tab){let p=yield this.formatStep(a,c,n,o,l);p&&d.steps.push(p)}else{let c=i.tabs.tab,p=yield this.formatStep(a,c,n,o,l);p&&d.steps.push(p)}return d})}formatStep(i,n,s,a,o){return w(this,null,function*(){if(n["@attributes"].visible!="false"){let l={id:n["@attributes"].name,stepName:this.replaceTemplateVariables(n.labels.label["@attributes"].description),isHidden:!1,sections:[],tableName:i==="subform-3"?"cs_application":a,relationshipName:o},d=yield this.getStepSections(i,n,s);return d.length?(l.sections=d,l):null}return null})}getStepSections(i,n,s){return w(this,null,function*(){let a=[],o=[];if(n.columns.column instanceof Array)for(let l of n.columns.column)a.push(l);else a.push(n.columns.column);for(let l of a)if(console.log("section",l),l.sections.section instanceof Array)for(let d of l.sections.section){if(d["@attributes"].visible==="false")continue;let c={id:d["@attributes"].name,sectionName:z.getBooleanValue(d["@attributes"].showlabel)?this.replaceTemplateVariables(d.labels.label["@attributes"].description):null,fields:yield this.getStepFields(i,d,s)};o.push(c)}else if(l.sections.section){let d={id:l.sections.section["@attributes"].name,sectionName:z.getBooleanValue(l.sections.section["@attributes"].showlabel)?this.replaceTemplateVariables(l.sections.section.labels.label["@attributes"].description):null,fields:yield this.get
4StepFields(i,l.sections.section,s)};o.push(d)}return o})}getStepFields(i,n,s){return w(this,null,function*(){let a=[],o=[],l=[];if(n.rows.row instanceof Array)for(let d of n.rows.row)a.push(d);else a.push(n.rows.row);for(let d of a)if(d.cell instanceof Array)for(let c of d.cell)o.push(c);else o.push(d.cell);for(let d of o)if(d instanceof Array){for(let c of d)if(c&&c.control&&c["@attributes"].visible!="false"){let p=yield this.mapField(i,c,s);console.log("field",c,p),"fieldName"in p&&l.push(p)}}else if(d&&d.control&&d["@attributes"].visible!="false"){let c=yield this.mapField(i,d,s);console.log("field",d,c),d["@attributes"].locklevel=="1"&&(c.type=ht.LOCKED,c.required=!1,console.log("LOCKED field",c)),"fieldName"in c&&l.push(c)}return l})}mapField(i,n,s){return w(this,null,function*(){console.log("mapField",n,s);let a=s?.Attributes[n.control["@attributes"].datafieldname],o={};if(a&&n.control["@attributes"].datafieldname){if(a.AttributeTypeName.Value!="OwnerType"||a.AttributeTypeName.Value!="DateTimeType"){if(o.fieldName=n.control["@attributes"].datafieldname,n.labels?o.label=n.labels.label["@attributes"].description:o.label=a?.DisplayName?.LocalizedLabels["1033"]?.Label||`Label not found - ${n.control["@attributes"].datafieldname}`,o.label=this.replaceTemplateVariables(o.label),o.type=a.AttributeTypeName.Value,String(o.fieldName).toLowerCase().endsWith("table")&&(o.type="Table"),o.fieldName.startsWith("cs_fileupload")||o.fieldName.startsWith("cs_sharepointupload")||o.fieldName.startsWith("cs_thirdlightupload")?o.type="UploadType":(String(o.fieldName).toLowerCase().startsWith("cs_multipleupload")||String(o.fieldName).toLowerCase().startsWith("cs_multiplesharepointupload")||String(o.fieldName).toLowerCase().startsWith("cs_multiplethirdlightupload"))&&(o.type="MultipleUploadType"),o.fieldName.includes("percentageof")&&(o.type="PercentOf"),o.maxLength=a.MaxLength,o.required=!0,o.conditions=[],o.details=[],o.fieldName.includes("postcode")||o.fieldName.includes("postalcode")?o.pattern="Postcode":o.fieldName.includes("accountnumber")?o.pattern="AccountNumber":o.fieldName.includes("sortcode")?o.pattern="SortCode":o.pattern=a.Format,a.Description.UserLocalizedLabel?.Label&&o.details.push({title:"More Details",description:this.replaceTemplateVariables(a.Description.UserLocalizedLabel.Label)}),a.AttributeTypeName.Value=="LookupType"){let c=[];if(n.control.parameters?.QuickForms){o.type="QuickView",o.conditions=[],o.tableName="QuickView",o.fieldName=n.control["@attributes"].datafieldname,o.relationshipName=n.control.parameters.RelationshipName,o.conditions=[],console.log("it has a quickforms"),console.log("quickforms metadata",a);let p=this.getQuickFormId(n.control.parameters.QuickForms);this.pushToOpenApiCalls("Getting quick form meta data",p);try{console.log("get quickform",p);let u=yield this.httpClient.get(`forms/get-quick-form/${p}`).toPromise();this.quickform=u.data,console.log("quickform",this.quickform);let f=yield this.getTableMetadata("cs_application");console.log("quickform metadata",f),o.subFields=[],o.label=this.replaceTemplateVariables(this.quickform.tabs.tab.labels.label["@attributes"].description);for(let h of this.quickform.tabs.tab.columns.column.sections.section.rows.row){h.control={},h.control["@attributes"]={datafieldname:h.cell.control["@attributes"].datafieldname},console.log("gets subfields",h);let m=yield this.mapField(i,h,f);m.required=f.Attributes[m.fieldName].RequiredLevel.Value=="ApplicationRequired",console.log("subfield",m,h,f),m.type!="UniqueidentifierType"&&o.subFields.push(m)}this.closeApiCall("Getting quick form meta data",p)}catch(u){console.log(u),this.setErrorMessage(u);return}}else{this.pushToOpenApiCalls("lookup",n.control["@attributes"].id),this.pushToOpenApiCalls("metaData",n.control["@attributes"].id);try{let u=(yield this.getLookup(a.Targets[0])).Entities,f=yield this.getTableMetadata(a.Targets[0]);for(let h of u)c.push({value:h.Id,label:this.replaceTemplateVariables(h.Attributes[f.PrimaryNameAttribute])||`No label - attr ${f.PrimaryNameAttribute}`});
4o.tableName=a.Targets[0],this.optionFields.push({fieldName:o.fieldName,options:c}),this.closeApiCall("metaData",n.control["@attributes"].id),this.closeApiCall("lookup",n.control["@attributes"].id)}catch(p){console.log(p),this.setErrorMessage(p);return}}}if(o.type=="MultiSelectPicklistType"||o.type=="PicklistType"){let c=[];if(a.OptionSet.Options instanceof Array)for(let p of a.OptionSet.Options)c.push({value:p.Value,label:this.replaceTemplateVariables(p.Label.UserLocalizedLabel.Label)});else for(let p in a.OptionSet.Options)c.push({value:p,label:this.replaceTemplateVariables(a.OptionSet.Options[p].Label.UserLocalizedLabel.Label)});o.options=c}let l=this.fund.cs_artforms?this.fund.cs_artforms.split(","):[];["cs_artformoptionset","cs_artformmultioptionset"].indexOf(String(o.fieldName).toLowerCase())!==-1&&this.fund.cs_artforms&&l.length&&o.options&&Array.isArray(o.options)&&(o.options=o.options.filter(c=>l.indexOf(String(c.value))!==-1))}}else if(n.control.parameters){o.type="SubGridType",o.conditions=[],o.tableName=n.control.parameters.TargetEntityType,o.fieldName=n.control["@attributes"].id,o.relationshipName=n.control.parameters.RelationshipName,o.conditions=[],console.log("view id",n);let l=n.control.parameters.ViewId.substring(1,n.control.parameters.ViewId.length-1);this.pushToOpenApiCalls("sub grid",l),this.pushToOpenApiCalls("meta data",l),console.log("field.control",n.control);try{let d=yield this.getSubGrid(l,n.control.parameters.TargetEntityType);this.closeApiCall("sub grid",l);let c=yield this.getTableMetadata(o.tableName);o.subFields=[],o.label=this.replaceTemplateVariables(c.DisplayCollectionName.UserLocalizedLabel.Label),console.log("subgrid",d);for(let p of d.entity.attribute){if(p["@attributes"].name==="cs_applicationlookup")continue;p.control={},p.control["@attributes"]={datafieldname:p["@attributes"].name};let u=yield this.mapField(i,p,c);u.required=c.Attributes[u.fieldName].RequiredLevel.Value=="ApplicationRequired",u.type!="UniqueidentifierType"&&o.subFields.push(u)}if(this.subgridFields.push(o),this.closeApiCall("meta data",l),d.conditions){for(let p of d.conditions.value)if(p.statecode===1){let u=p.xaml,h=new re({ignoreAttributes:!1}).parse(u);this.formatBusinessFlow(z.normalizeNewlines(h),p.workflowid,!0)}}}catch(d){console.log(d),this.setErrorMessage(d);return}}return o})}completeSubGrid(i){for(let n of this.formTemplate[this.templateType].steps)for(let s of n.sections)for(let a of s.fields)a.fieldName==i.fieldName&&(a=i)}addOptionsToField(i,n,s){console.log("addOptionsToField",this.formTemplate,this.templateType,i);for(let a of this.formTemplate[i].steps)for(let o of a.sections)for(let l of o.fields)if(l.type==="SubGridType"&&l.subFields)for(let d of l.subFields)d.fieldName===s&&(d.options=n);else l.fieldName===s&&(l.options=n)}formatBusinessFlow(i,n,s){let a=[],o=i.Activity["mxswa:Workflow"],l=o["mxswa:ActivityReference"]["mxswa:ActivityReference.Properties"]["sco:Collection"][0].Variable;console.log("CONDITION BRANCHES",l);let d=[],c=[],p=[],u=o["mxswa:ActivityReference"]["mxswa:ActivityReference.Properties"]["sco:Collection"].slice(1);console.log("CONDITIONS",u);let f=[];for(let g of u)f.push(g["mxswa:ActivityReference"]),d=this.getEntities(g);for(let g of f[0])g["mxswa:ActivityReference.Properties"]?c.push(this.formatConditionResult(g)):p.push(this.formatConditionOperator(g));console.log("operators",p);let h=p[p.length-1].logicalOperator,m=p.filter(g=>g.operator).map(g=>{let _=g.parameters;if(console.log("formattedOperators",g),_&&_.includes(",")){let E=_.split(", ");_=[],p.forEach(H=>{console.log("operator",H);let me=H.resultConditionBranch.replace("[","").replace("]","");E.includes(me)&&H.parameters&&_.push(H.parameters?.split(", ")[1].replace(/\"/g,""))})}else _&&_.indexOf("Condition")>-1&&(_=p.find(E=>E.resultConditionBranch===`[${_}]`)?.parameters);return at(F({},g),{parameters:_})});this.createConditionGroups(d,m,c,h)}createConditionGroups(i,n,s,a,o){let l={logicalOperator:a,conditions:[],results:[],isOrgConditionGroup:!1,isSubGrid:o};s.forEach(d=>{d.forEach(c=>{l.results.push(c)})}
4),n.forEach(d=>{let c=i.find(u=>d.operatorConditionBranch===u.conditionBranch);(c.fieldToCheckValueName=="cs_individualororganisationoptionset"||c.fieldToCheckValueName=="cs_organisationlegaltypeoptionsetsingle")&&(l.isOrgConditionGroup=!0);let p={fieldToCheckValueName:c.fieldToCheckValueName,comparator:d.operator,logicalOperator:d.logicalOperator};d.parameters instanceof Array?p.parameters=d.parameters:(p.parameters=d.parameters?.split(", ")[1].replace(/\"/g,""),p.parameters?.includes(",")&&(p.parameters=p.parameters.replace(/,/,""))),l.conditions.push(p)}),this.formTemplateConditionGroups[this.templateType]||(this.formTemplateConditionGroups[this.templateType]=[]),this.formTemplateConditionGroups[this.templateType].push(l),this.markProgressStageAsCompleted("Formatting business flows"),console.log("this.formTemplateConditionGroups",this.formTemplateConditionGroups)}getEntities(i){let n=[];if(i["mxswa:GetEntityProperty"]instanceof Array)for(let s of i["mxswa:GetEntityProperty"])n.push({fieldToCheckValueName:s["@_Attribute"],conditionBranch:s["@_Value"]});else console.log("condition",i),n.push({fieldToCheckValueName:i["mxswa:GetEntityProperty"]["@_Attribute"],conditionBranch:i["mxswa:GetEntityProperty"]["@_Value"]});return n}formatConditionResult(i){let n=[],s=i["mxswa:ActivityReference.Properties"]["mxswa:ActivityReference"]["mxswa:ActivityReference.Properties"]["sco:Collection"][1].Sequence;return s instanceof Array||(s=[s]),s.forEach(a=>{let o={};if(o.conditionBranch=i["mxswa:ActivityReference.Arguments"].InArgument["#text"],"mcwc:SetVisibility"in a)o.resultType="set visibility",o.value=a["mcwc:SetVisibility"]["@_IsVisible"],o.affectedField=a["@_DisplayName"]?.includes("Subgrid_")?a["@_DisplayName"].split(": ")[1]:a["mcwc:SetVisibility"]["@_ControlId"];else if("mcwc:SetFieldRequiredLevel"in a)o.resultType="set required",o.affectedField=a["mcwc:SetFieldRequiredLevel"]["@_ControlId"],o.value=a["mcwc:SetFieldRequiredLevel"]["@_RequiredLevel"];else if("mcwc:SetMessage"in a)if(o.affectedField=a["mcwc:SetMessage"]["@_ControlId"],a["mcwc:SetMessage"]["@_Level"]=="RECOMMENDATION"){let l=a["mcwc:SetMessage"]["mcwc:SetMessage.Activities"];if(l){o.resultType="set text";let d=l["mxswa:ActivityReference"]["mxswa:ActivityReference.Properties"]["sco:Collection"];for(let c of d)"mcwo:StepLabel"in c&&(o.details={title:a["mcwc:SetMessage"]["mcwc:SetMessage.StepLabels"]["mcwo:StepLabel"]["@_Description"],description:this.replaceTemplateVariables(c["mcwo:StepLabel"]["@_Description"])})}console.log("set text",o)}else o.resultType="set error",o.value=a["mcwc:SetMessage"]["mcwc:SetMessage.StepLabels"]["mcwo:StepLabel"]["@_Description"];else if("mcwc:SetAttributeValue"in a||"mcwc:SetDefaultValue"in a)if(o.resultType="mcwc:SetDefaultValue"in a?"set default":"set value",o.affectedField=a["mxswa:SetEntityProperty"]["@_Attribute"],a["mxswa:ActivityReference"]){let l=a["mxswa:ActivityReference"]["mxswa:ActivityReference.Arguments"].InArgument[1]["#text"];console.log("dynamicsValue",l),l.match(new RegExp(', "(.*)", '))?o.value=l.match(new RegExp(', "(.*)", '))[1]:l.match(new RegExp(', "(.*)"'))&&(o.value=l.match(new RegExp(', "(.*)"'))[1])}else o.value=null;else"mcwc:SetDisplayMode"in a&&(o.resultType="hide step",o.affectedField=a["mcwc:SetDisplayMode"]["@_ControlId"],o.value=a["@_DisplayName"].split(": ")[1]);n.push(o)}),n}formatConditionOperator(i){let n,s,a,o;return i["mxswa:ActivityReference.Arguments"].InArgument.forEach(d=>{console.log("item",d),d["@_x:Key"]==="Operand"?n=d["#text"]:d["@_x:Key"]==="ConditionOperator"?a=d["#text"]:d["@_x:Key"]==="Parameters"?s=d["#text"].indexOf("New Object()")>-1?d["#text"].match(/New Object\(\) \{\ (.*?)\ \}/i)[1]:d["#text"]:d["@_x:Key"]==="LogicalOperator"&&(o=d["#text"],console.log("LOGICAL OPERATOR",o))}),{operator:a,parameters:s,logicalOperator:o,operatorConditionBranch:n,resultConditionBranch:i["mxswa:ActivityReference.Arguments"].OutArgument["#text"]}}setErrorMessage(i){console.log("error",i),i?.status!==500?this.errorMessage.next(i?.error?.message?i?.error?.message:"form genie done gone and broke. contact form genie genie"):this.errorMessage.next("<p>Internal server error please refresh and try again</p>")}
4replaceTemplateVariables(i){if(!i)return i;let n=i;return n=n.replace(/{{fund_guidance}}/g,this.fund.guidance_url),n=n.replace(/{{ fund_guidance }}/g,this.fund.guidance_url),n}getQuickFormId(i){if(!i)return i;let n=/<QuickFormId entityname="[^"]+">([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})<\/QuickFormId>/,s=i.match(n);if(s)return s[1]}addConditions(){if(this.formTemplate[this.templateType].orgConditions=[],!!this.formTemplateConditionGroups[this.templateType])for(let i of this.formTemplateConditionGroups[this.templateType])if(i.isOrgConditionGroup)this.formTemplate[this.templateType].orgConditions.push(i);else for(let n of i.conditions)for(let s of this.formTemplate[this.templateType].steps)for(let a of s.sections)n.fieldToCheckValueName&&(i.isSubGrid?a.fields.forEach(o=>{o.type==="SubGridType"&&o.subFields.find(d=>d.fieldName===n.fieldToCheckValueName)?.conditions.push(i)}):a.fields.find(l=>l.fieldName===n.fieldToCheckValueName)?.conditions.push(i))}getFieldForMetaData(){let i=this.templateType.includes("subform-")||this.templateType.includes("subtable-form-")||this.templateType==M.ANNUAL_PLAN_REPORT?"application":this.templateType;for(let n of this.attributesMetaData)if(n.Attributes.cs_regardingid){for(let s of this.formTemplate[this.templateType].steps)for(let a of s.sections)for(let o of a.fields)if(o.type=="SubGridType"&&o.fieldName.toLowerCase()!=n.Attributes.cs_regardingid.toLowerCase()){if(o.subFields){for(let l of o.subFields)if(l.fieldName.toLowerCase()===n.Attributes.cs_regardingid.toLowerCase()){(!n.Attributes.cs_sectionid||n.Attributes.cs_sectionid==a.id)&&String(n.Attributes.cs_tableid).toLowerCase()==String(o.tableName).toLowerCase()&&i==this.attributeFormType(n.Attributes.cs_formtypeoptionset)&&this.addAttribute(n,l);break}}}else if(o.fieldName.toLowerCase()===n.Attributes.cs_regardingid.toLowerCase()){console.log("getFieldForMetaData",o.fieldName.toLowerCase(),n.Attributes.cs_sectionid,a.id,n.Attributes.cs_tableid,i==this.attributeFormType(n.Attributes.cs_formtypeoptionset),i,this.attributeFormType(n.Attributes.cs_formtypeoptionset),n.Attributes,this.templateType,n.Attributes.cs_formtypeoptionset),(!n.Attributes.cs_sectionid||n.Attributes.cs_sectionid==a.id)&&(!n.Attributes.cs_tableid||n.Attributes.cs_tableid&&n.Attributes.cs_subformmetadatayn)&&i==this.attributeFormType(n.Attributes.cs_formtypeoptionset)?(console.log("getFieldForMetaData - ADD ATTRIBUTE",n,o),this.addAttribute(n,o)):n.Attributes.cs_tableid&&n.Attributes.cs_subformid&&this.templateTypes.length===1&&(console.log("getFieldForMetaData - Form Genie v3",n,o),this.subTableFormsToBeCreated.push({field:o,stepId:s.id,type:`subtable-form-${s.id}`,subFormId:n.Attributes.cs_subformid,metaTable:n.Attributes.cs_tableid,metadata:n}));break}}}addAttribute(i,n){i.Attributes.cs_characterlimit&&(n.maxLength=i.Attributes.cs_characterlimit),i.Attributes.cs_uploadfiletypes&&(n.uploadFileTypes=i.Attributes.cs_uploadfiletypes),i.Attributes.cs_subgridlimit&&(n.maxItems=i.Attributes.cs_subgridlimit),i.Attributes.cs_uploadlimit&&(n.maxItems=i.Attributes.cs_uploadlimit),i.Attributes.cs_requiredoroptional!=null&&(n.required=i.Attributes.cs_requiredoroptional),i.Attributes.cs_moredetails&&(n.details?n.details.find(a=>a.description===i.Attributes.cs_moredetails)||n.details.push({title:"More Details",description:this.replaceTemplateVariables(i.Attributes.cs_moredetails)}):n.details=[{title:"More Details",description:this.replaceTemplateVariables(i.Attributes.cs_moredetails)}])}attributeFormType(i){let n=ft.find(s=>s.value==i);return n?n.label:null}};e.\u0275fac=function(n){return new(n||e)},e.\u0275prov=lt({token:e,factory:e.\u0275fac});let r=e;return r})();function ti(r,e){if(r&1&&(L(0,"h1"),O(1),R()),r&2){let t=y();b(),X("Create ",t.name)}}function ri(r,e){if(r&1&&(L(0,"h1"),O(1),R()),r&2){let t=y();b(),X("Building ",t.name)}}function ii(r,e){if(r&1&&(L(0,"h1"),O(1),R()),r&2){let t=y();b(),pt(t.templateCreated)}}function ni(r,e){r&1&&qe(0,"i",8)}function si(r,e){if(r&1&&(L(0,"p"),O(1),x(2,ni,1,0,"i",8),R()),r&2){let t=e.$implicit;dt("complete",t.isCompleted),b(),X(" ",t.progressStage," "),b(),C(t.isCompleted?2:-1)}}
4function oi(r,e){r&1&&(L(0,"p"),O(1,"Loading..."),R())}function ai(r,e){if(r&1&&(_e(0,si,3,4,"p",7,Te),x(2,oi,2,0,"p")),r&2){let t=y();xe(t.buildProgress),b(2),C(t.isLoading?2:-1)}}function li(r,e){if(r&1&&qe(0,"div",3),r&2){let t=y();$e("innerHTML",t.errorMessage,ct)}}function ci(r,e){if(r&1){let t=Ee();L(0,"button",9),Ae("click",function(){$(t);let n=y();return j(n.createTemplate())})("keyup.enter",function(){$(t);let n=y();return j(n.createTemplate())}),L(1,"span",10),O(2),R()()}if(r&2){let t=y();b(2),X("",t.name," Generated")}}function di(r,e){if(r&1){let t=Ee();L(0,"button",11),Ae("click",function(){$(t);let n=y();return j(n.createTemplate())})("keyup.enter",function(){$(t);let n=y();return j(n.createTemplate())}),L(1,"span",10),O(2),R()()}if(r&2){let t=y();$e("disabled",t.isLoading),b(2),X("Create ",t.name)}}function pi(r,e){if(r&1){let t=Ee();L(0,"button",12),Ae("click",function(){$(t);let n=y();return j(n.createTemplate())})("keyup.enter",function(){$(t);let n=y();return j(n.createTemplate())}),L(1,"span",10),O(2,"Retry"),R()()}}var $t=(()=>{let e=class e{constructor(){this.route=P(Se),this.formTemplateService=P(ie),this.ngUnsubscribe=new be,this.label=Y(void 0),this.type=Y(void 0),this.department=Y(void 0),this.fund=Y(void 0),this.subForm=Y(void 0)}ngOnInit(){this.name=this.label()||this.type().replace(/-/g," ").replace(/(^\w|\s\w)/g,i=>i.toUpperCase()),this.formTemplateService.templateCreated.subscribe(i=>{this.templateCreated=i,this.isLoading=!1}),this.formTemplateService.errorMessage.pipe(D(this.ngUnsubscribe)).subscribe(i=>{i&&(this.errorMessage=i)}),this.route.queryParams.pipe(D(this.ngUnsubscribe)).subscribe(i=>{this.fundUrl=i.url}),this.formTemplateService.buildProgress.subscribe(i=>{this.buildProgress=i}),this.formTemplateService.setFund(this.fund())}ngOnDestroy(){this.ngUnsubscribe.next(void 0),this.ngUnsubscribe.complete()}createTemplate(){this.isLoading=!0,this.attempted=!0;let i=this.department(),n=this.subForm();switch(i){case"programme":this.formTemplateService.createProgrammeTemplate(this.fundUrl,this.type());break;case"multiform":this.formTemplateService.setSubForm(n),this.formTemplateService.createTemplate(this.t
4ype(),n.Attributes.cs_formid);break;default:this.formTemplateService.createFundTemplate(this.fundUrl,this.type(),i)}}};e.\u0275fac=function(n){return new(n||e)},e.\u0275cmp=ye({type:e,selectors:[["app-create-template"]],inputs:{label:[1,"label"],type:[1,"type"],department:[1,"department"],fund:[1,"fund"],subForm:[1,"subForm"]},features:[Ne([ie])],decls:11,vars:8,consts:[[1,"container","form-container"],[1,"row"],[1,"col-sm-12"],[3,"innerHTML"],["type","submit","disabled","",1,"ds_button","ds_button--primary"],["type","button",1,"ds_button","ds_button--primary",3,"disabled"],["type","submit",1,"ds_button","ds_button--primary"],[3,"complete"],[1,"fa","fa-check-circle"],["type","submit","disabled","",1,"ds_button","ds_button--primary",3,"click","keyup.enter"],[1,"link-text"],["type","button",1,"ds_button","ds_button--primary",3,"click","keyup.enter","disabled"],["type","submit",1,"ds_button","ds_button--primary",3,"click","keyup.enter"]],template:function(n,s){n&1&&(L(0,"div",0)(1,"div",1)(2,"div",2),x(3,ti,2,1,"h1"),x(4,ri,2,1,"h1"),x(5,ii,2,1,"h1"),x(6,ai,3,1),x(7,li,1,1,"div",3),x(8,ci,3,1,"button",4),x(9,di,3,2,"button",5),x(10,pi,3,0,"button",6),R()()()),n&2&&(b(3),C(!s.isLoading&&!s.templateCreated?3:-1),b(),C(s.isLoading?4:-1),b(),C(!s.isLoading&&s.templateCreated?5:-1),b(),C(s.errorMessage?-1:6),b(),C(s.errorMessage?7:-1),b(),C(!s.isLoading&&s.templateCreated?8:-1),b(),C(!s.attempted&&!s.templateCreated?9:-1),b(),C(s.attempted&&!s.isLoading&&!s.templateCreated||s.errorMessage?10:-1))},styles:[".container[_ngcontent-%COMP%]{margin-top:50px;margin-bottom:50px}.complete[_ngcontent-%COMP%]{color:green}"]});let r=e;return r})();function ui(r,e){if(r&1&&se(0,"app-create-template",0),r&2){let t=y(2);V("department",t.department)}}function fi(r,e){if(r&1&&se(0,"app-create-template",1)(1,"app-create-template",2)(2,"app-create-template",3),r&2){let t=y(2);V("department",t.department),b(),V("department",t.department),b(),V("department",t.department)}}function hi(r,e){if(r&1&&se(0,"app-create-template",4)(1,"app-create-template",5),r&2){let t=y(2);V("department",t.department),b(),V("department",t.department)}}function mi(r,e){r&1&&(Ce(0,"p"),O(1,"Loading fund and form details..."),we())}function gi(r,e){r&1&&(Ce(0,"p"),O(1,"No forms found."),we())}function bi(r,e){if(r&1&&se(0,"app-create-template",9),r&2){let t=e.$implicit,i=y(4);V("department",i.department)("label",t.FormattedValues.cs_formcategory)("type",i.getFormType(t))("fund",i.fund)("subForm",t)}}function yi(r,e){if(r&1&&_e(0,bi,1,5,"app-create-template",9,Te),r&2){let t=y(3);xe(t.subForms)}}function Ti(r,e){if(r&1&&(Ce(0,"div",6)(1,"div",7)(2,"div",8),x(3,mi,2,0,"p"),x(4,gi,2,0,"p"),we()()(),x(5,yi,2,0)),r&2){let t=y(2);b(3),C(t.subForms?-1:3),b(),C(t.subForms&&!t.subForms.length?4:-1),b(),C(t.subForms?5:-1)}}function _i(r,e){if(r&1&&(x(0,ui,1,1,"app-create-template",0),x(1,fi,3,3),x(2,hi,2,2),x(3,Ti,6,3)),r&2){let t=y();C(t.department!="rfo"&&t.department!="multiform"?0:-1),b(),C(t.department=="fund"?1:-1),b(),C(t.department=="rfo"?2:-1),b(),C(t.department=="multiform"?3:-1)}}var Es=(()=>{let e=class e{constructor(){this.route=P(Se),this.formTemplateService=P(ie)}ngOnInit(){this.department=this.route.snapshot.params.department,this.fundUrl=this.route.snapshot.queryParams.url,this.department==="multiform"&&this.fetchMultiformData()}fetchMultiformData(){return w(this,null,function*(){this.fund=yield this.formTemplateService.getFund(this.fundUrl,this.department),this.subForms=yield this.formTemplateService.getSubForms(this.fund.dynamics_id),console.log("sub forms",this.subForms)})}getFormType(i){return i.FormattedValues.cs_formcategory.toUpperCase().indexOf("ANNUAL PLAN")!=-1?M.ANNUAL_PLAN_REPORT:i.FormattedValues.cs_formcategory.toUpperCase().indexOf("FAIR WORK PRO FORMA")!=-1?M.FAIR_WORK_PRO_FORMA_REPORT:i.FormattedValues.cs_formcategory.toUpperCase().indexOf("END OF PROJECT")!=-1?M.END_OF_PROJECT_MONITORING_REPORT:i.FormattedValues.cs_formcategory.toUpperCase().indexOf("ANNUAL STATISTICAL SURVEY")!=-1?M.ANNUAL_STATS_SURVEY_REPORT:"subform-"+i.Attributes.cs_formindex}};e.\u0275fac=function(n){return new(n||e)},e.\u0275cmp=ye({type:e,selectors:[["app-create-form"]],features:[Ne([ie])],decls:1,vars:1,consts:[["type","application",3,"department"],["type","questionnaire",3,"department"],["type","interim-report",3,"department"],["type","end-of-project-report",3,"department"],["type","annual-plan",3,"department"],["type","annual-report",3,"department"],[1,"container"],[1,"row"],[1,"col-12"],[3,"department","label","type","fund","subForm"]],template:function(n,s){n&1&&x(0,_i,4,4),n&2&&C(s.department?0:-1)},dependencies:[$t],encapsulation:2});let r=e;return r})();export{Es as CreateFormComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.