forms-reactive
Version:
Reactive Form Web Component
37 lines • 32.3 kB
JavaScript
function t(t){return typeof t==="function"}let e=false;const s={Promise:undefined,set useDeprecatedSynchronousErrorHandling(t){if(t){const t=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+t.stack)}else if(e){console.log("RxJS: Back to a better error behavior. Thank you. <3")}e=t},get useDeprecatedSynchronousErrorHandling(){return e}};function i(t){setTimeout((()=>{throw t}),0)}const r={closed:true,next(t){},error(t){if(s.useDeprecatedSynchronousErrorHandling){throw t}else{i(t)}},complete(){}};const n=(()=>Array.isArray||(t=>t&&typeof t.length==="number"))();function h(t){return t!==null&&typeof t==="object"}const u=(()=>{function t(t){Error.call(this);this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map(((t,e)=>`${e+1}) ${t.toString()}`)).join("\n ")}`:"";this.name="UnsubscriptionError";this.errors=t;return this}t.prototype=Object.create(Error.prototype);return t})();const o=u;class l{constructor(t){this.closed=false;this._parentOrParents=null;this._subscriptions=null;if(t){this._ctorUnsubscribe=true;this._unsubscribe=t}}unsubscribe(){let e;if(this.closed){return}let{_parentOrParents:s,_ctorUnsubscribe:i,_unsubscribe:r,_subscriptions:u}=this;this.closed=true;this._parentOrParents=null;this._subscriptions=null;if(s instanceof l){s.remove(this)}else if(s!==null){for(let t=0;t<s.length;++t){const e=s[t];e.remove(this)}}if(t(r)){if(i){this._unsubscribe=undefined}try{r.call(this)}catch(t){e=t instanceof o?c(t.errors):[t]}}if(n(u)){let t=-1;let s=u.length;while(++t<s){const s=u[t];if(h(s)){try{s.unsubscribe()}catch(t){e=e||[];if(t instanceof o){e=e.concat(c(t.errors))}else{e.push(t)}}}}}if(e){throw new o(e)}}add(t){let e=t;if(!t){return l.EMPTY}switch(typeof t){case"function":e=new l(t);case"object":if(e===this||e.closed||typeof e.unsubscribe!=="function"){return e}else if(this.closed){e.unsubscribe();return e}else if(!(e instanceof l)){const t=e;e=new l;e._subscriptions=[t]}break;default:{throw new Error("unrecognized teardown "+t+" added to Subscription.")}}let{_parentOrParents:s}=e;if(s===null){e._parentOrParents=this}else if(s instanceof l){if(s===this){return e}e._parentOrParents=[s,this]}else if(s.indexOf(this)===-1){s.push(this)}else{return e}const i=this._subscriptions;if(i===null){this._subscriptions=[e]}else{i.push(e)}return e}remove(t){const e=this._subscriptions;if(e){const s=e.indexOf(t);if(s!==-1){e.splice(s,1)}}}}l.EMPTY=function(t){t.closed=true;return t}(new l);function c(t){return t.reduce(((t,e)=>t.concat(e instanceof o?e.errors:e)),[])}const f=(()=>typeof Symbol==="function"?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random())();class a extends l{constructor(t,e,s){super();this.syncErrorValue=null;this.syncErrorThrown=false;this.syncErrorThrowable=false;this.isStopped=false;switch(arguments.length){case 0:this.destination=r;break;case 1:if(!t){this.destination=r;break}if(typeof t==="object"){if(t instanceof a){this.syncErrorThrowable=t.syncErrorThrowable;this.destination=t;t.add(this)}else{this.syncErrorThrowable=true;this.destination=new d(this,t)}break}default:this.syncErrorThrowable=true;this.destination=new d(this,t,e,s);break}}[f](){return this}static create(t,e,s){const i=new a(t,e,s);i.syncErrorThrowable=false;return i}next(t){if(!this.isStopped){this._next(t)}}error(t){if(!this.isStopped){this.isStopped=true;this._error(t)}}complete(){if(!this.isStopped){this.isStopped=true;this._complete()}}unsubscribe(){if(this.closed){return}this.isStopped=true;super.unsubscribe()}_next(t){this.destination.next(t)}_error(t){this.destination.error(t);this.unsubscribe()}_complete(){this.destination.complete();this.unsubscribe()}_unsubscribeAndRecycle(){const{_parentOrParents:t}=this;this._parentOrParents=null;this.unsubscribe();this.closed=false;this.isStopped=false;this._parentOrParents=t;return this}}class d extends a{constructor(e,s,i,n){super();this._parentSubscriber=e;let h;let u=this;if(t(s)){h=s}else if(s){h=s.next;i=s.error;n=s.complete;if(s!==r){u=Object.create(s);if(t(u.unsubscribe)){this.add(u.unsubscribe.bind(u))}u.unsubscribe=this.unsubscribe.bind(this)}}this._context=u;this._next=h;this._error=i;this._complete=n}next(t){if(!this.isStopped&&this._next){const{_parentSubscriber:e}=this;if(!s.useDeprecatedSynchronousErrorHandling||!e.syncErrorThrowable){this.__tryOrUnsub(this._next,t)}else if(this.__tryOrSetError(e,this._next,t)){this.unsubscribe()}}}error(t){if(!this.isStopped){const{_parentSubscriber:e}=this;const{useDeprecatedSynchronousErrorHandling:r}=s;if(this._error){if(!r||!e.syncErrorThrowable){this.__tryOrUnsub(this._error,t);this.unsubscribe()}else{this.__tryOrSetError(e,this._error,t);this.unsubscribe()}}else if(!e.syncErrorThrowable){this.unsubscribe();if(r){throw t}i(t)}else{if(r){e.syncErrorValue=t;e.syncErrorThrown=true}else{i(t)}this.unsubscribe()}}}complete(){if(!this.isStopped){const{_parentSubscriber:t}=this;if(this._complete){const e=()=>this._complete.call(this._context);if(!s.useDeprecatedSynchronousErrorHandling||!t.syncErrorThrowable){this.__tryOrUnsub(e);this.unsubscribe()}else{this.__tryOrSetError(t,e);this.unsubscribe()}}else{this.unsubscribe()}}}__tryOrUnsub(t,e){try{t.call(this._context,e)}catch(t){this.unsubscribe();if(s.useDeprecatedSynchronousErrorHandling){throw t}else{i(t)}}}__tryOrSetError(t,e,r){if(!s.useDeprecatedSynchronousErrorHandling){throw new Error("bad call")}try{e.call(this._context,r)}catch(e){if(s.useDeprecatedSynchronousErrorHandling){t.syncErrorValue=e;t.syncErrorThrown=true;return true}else{i(e);return true}}return false}_unsubscribe(){const{_parentSubscriber:t}=this;this._context=null;this._parentSubscriber=null;t.unsubscribe()}}function b(t){while(t){const{closed:e,destination:s,isStopped:i}=t;if(e||i){return false}else if(s&&s instanceof a){t=s}else{t=null}}return true}function y(t,e,s){if(t){if(t instanceof a){return t}if(t[f]){return t[f]()}}if(!t&&!e&&!s){return new a(r)}return new a(t,e,s)}const p=(()=>typeof Symbol==="function"&&Symbol.observable||"@@observable")();function w(t){return t}function m(t){if(t.length===0){return w}if(t.length===1){return t[0]}return function e(s){return t.reduce(((t,e)=>e(t)),s)}}class _{constructor(t){this._isScalar=false;if(t){this._subscribe=t}}lift(t){const e=new _;e.source=this;e.operator=t;return e}subscribe(t,e,i){const{operator:r}=this;const n=y(t,e,i);if(r){n.add(r.call(n,this.source))}else{n.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!n.syncErrorThrowable?this._subscribe(n):this._trySubscribe(n))}if(s.useDeprecatedSynchronousErrorHandling){if(n.syncErrorThrowable){n.syncErrorThrowable=false;if(n.syncErrorThrown){throw n.syncErrorValue}}}return n}_trySubscribe(t){try{return this._subscribe(t)}catch(e){if(s.useDeprecatedSynchronousErrorHandling){t.syncErrorThrown=true;t.syncErrorValue=e}if(b(t)){t.error(e)}else{console.warn(e)}}}forEach(t,e){e=g(e);return new e(((e,s)=>{let i;i=this.subscribe((e=>{try{t(e)}catch(t){s(t);if(i){i.unsubscribe()}}}),s,e)}))}_subscribe(t){const{source:e}=this;return e&&e.subscribe(t)}[p](){return this}pipe(...t){if(t.length===0){return this}return m(t)(this)}toPromise(t){t=g(t);return new t(((t,e)=>{let s;this.subscribe((t=>s=t),(t=>e(t)),(()=>t(s)))}))}}_.create=t=>new _(t);function g(t){if(!t){t=s.Promise||Promise}if(!t){throw new Error("no Promise impl found")}return t}const E=(()=>{function t(){Error.call(this);this.message="object unsubscribed";this.name="ObjectUnsubscribedError";return this}t.prototype=Object.create(Error.prototype);return t})();const S=E;class v extends l{constructor(t,e){super();this.subject=t;this.subscriber=e;this.closed=false}unsubscribe(){if(this.closed){return}this.closed=true;const t=this.subject;const e=t.observers;this.subject=null;if(!e||e.length===0||t.isStopped||t.closed){return}const s=e.indexOf(this.subscriber);if(s!==-1){e.splice(s,1)}}}class O extends a{constructor(t){super(t);this.destination=t}}class C extends _{constructor(){super();this.observers=[];this.closed=false;this.isStopped=false;this.hasError=false;this.thrownError=null}[f](){return new O(this)}lift(t){const e=new A(this,this);e.operator=t;return e}next(t){if(this.closed){throw new S}if(!this.isStopped){const{observers:e}=this;const s=e.length;const i=e.slice();for(let e=0;e<s;e++){i[e].next(t)}}}error(t){if(this.closed){throw new S}this.hasError=true;this.thrownError=t;this.isStopped=true;const{observers:e}=this;const s=e.length;const i=e.slice();for(let e=0;e<s;e++){i[e].error(t)}this.observers.length=0}complete(){if(this.closed){throw new S}this.isStopped=true;const{observers:t}=this;const e=t.length;const s=t.slice();for(let t=0;t<e;t++){s[t].complete()}this.observers.length=0}unsubscribe(){this.isStopped=true;this.closed=true;this.observers=null}_trySubscribe(t){if(this.closed){throw new S}else{return super._trySubscribe(t)}}_subscribe(t){if(this.closed){throw new S}else if(this.hasError){t.error(this.thrownError);return l.EMPTY}else if(this.isStopped){t.complete();return l.EMPTY}else{this.observers.push(t);return new v(this,t)}}asObservable(){const t=new _;t.source=this;return t}}C.create=(t,e)=>new A(t,e);class A extends C{constructor(t,e){super();this.destination=t;this.source=e}next(t){const{destination:e}=this;if(e&&e.next){e.next(t)}}error(t){const{destination:e}=this;if(e&&e.error){this.destination.error(t)}}complete(){const{destination:t}=this;if(t&&t.complete){this.destination.complete()}}_subscribe(t){const{source:e}=this;if(e){return this.source.subscribe(t)}else{return l.EMPTY}}}const j=t=>e=>{for(let s=0,i=t.length;s<i&&!e.closed;s++){e.next(t[s])}e.complete()};function x(t,e){return new _((s=>{const i=new l;let r=0;i.add(e.schedule((function(){if(r===t.length){s.complete();return}s.next(t[r++]);if(!s.closed){i.add(this.schedule())}})));return i}))}function V(t,e){return function s(i){if(typeof t!=="function"){throw new TypeError("argument is not a function. Are you looking for `mapTo()`?")}return i.lift(new k(t,e))}}class k{constructor(t,e){this.project=t;this.thisArg=e}call(t,e){return e.subscribe(new P(t,this.project,this.thisArg))}}class P extends a{constructor(t,e,s){super(t);this.project=e;this.count=0;this.thisArg=s||this}_next(t){let e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){this.destination.error(t);return}this.destination.next(e)}}const D=t=>e=>{t.then((t=>{if(!e.closed){e.next(t);e.complete()}}),(t=>e.error(t))).then(null,i);return e};function T(){if(typeof Symbol!=="function"||!Symbol.iterator){return"@@iterator"}return Symbol.iterator}const $=T();const I=t=>e=>{const s=t[$]();do{let t;try{t=s.next()}catch(t){e.error(t);return e}if(t.done){e.complete();break}e.next(t.value);if(e.closed){break}}while(true);if(typeof s.return==="function"){e.add((()=>{if(s.return){s.return()}}))}return e};const z=t=>e=>{const s=t[p]();if(typeof s.subscribe!=="function"){throw new TypeError("Provided object does not correctly implement Symbol.observable")}else{return s.subscribe(e)}};const L=t=>t&&typeof t.length==="number"&&typeof t!=="function";function M(t){return!!t&&typeof t.subscribe!=="function"&&typeof t.then==="function"}const R=t=>{if(!!t&&typeof t[p]==="function"){return z(t)}else if(L(t)){return j(t)}else if(M(t)){return D(t)}else if(!!t&&typeof t[$]==="function"){return I(t)}else{const e=h(t)?"an invalid object":`'${t}'`;const s=`You provided ${e} where a stream was expected.`+" You can provide an Observable, Promise, Array, or Iterable.";throw new TypeError(s)}};function U(t,e){return new _((s=>{const i=new l;i.add(e.schedule((()=>{const r=t[p]();i.add(r.subscribe({next(t){i.add(e.schedule((()=>s.next(t))))},error(t){i.add(e.schedule((()=>s.error(t))))},complete(){i.add(e.schedule((()=>s.complete())))}}))})));return i}))}function Z(t,e){return new _((s=>{const i=new l;i.add(e.schedule((()=>t.then((t=>{i.add(e.schedule((()=>{s.next(t);i.add(e.schedule((()=>s.complete())))})))}),(t=>{i.add(e.schedule((()=>s.error(t))))})))));return i}))}function q(t,e){if(!t){throw new Error("Iterable cannot be null")}return new _((s=>{const i=new l;let r;i.add((()=>{if(r&&typeof r.return==="function"){r.return()}}));i.add(e.schedule((()=>{r=t[$]();i.add(e.schedule((function(){if(s.closed){return}let t;let e;try{const s=r.next();t=s.value;e=s.done}catch(t){s.error(t);return}if(e){s.complete()}else{s.next(t);this.schedule()}})))})));return i}))}function H(t){return t&&typeof t[p]==="function"}function F(t){return t&&typeof t[$]==="function"}function N(t,e){if(t!=null){if(H(t)){return U(t,e)}else if(M(t)){return Z(t,e)}else if(L(t)){return x(t,e)}else if(F(t)||typeof t==="string"){return q(t,e)}}throw new TypeError((t!==null&&typeof t||t)+" is not observable")}function B(t,e){if(!e){if(t instanceof _){return t}return new _(R(t))}else{return N(t,e)}}function J(...t){if(t.length===1){const e=t[0];if(n(e)){return Y(e,null)}if(h(e)&&Object.getPrototypeOf(e)===Object.prototype){const t=Object.keys(e);return Y(t.map((t=>e[t])),t)}}if(typeof t[t.length-1]==="function"){const e=t.pop();t=t.length===1&&n(t[0])?t[0]:t;return Y(t,null).pipe(V((t=>e(...t))))}return Y(t,null)}function Y(t,e){return new _((s=>{const i=t.length;if(i===0){s.complete();return}const r=new Array(i);let n=0;let h=0;for(let u=0;u<i;u++){const o=B(t[u]);let l=false;s.add(o.subscribe({next:t=>{if(!l){l=true;h++}r[u]=t},error:t=>s.error(t),complete:()=>{n++;if(n===i||!l){if(h===i){s.next(e?e.reduce(((t,e,s)=>(t[e]=r[s],t)),{}):r)}s.complete()}}}))}}))}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function G(t){return t==null||t.length===0}function K(t){return t!=null&&typeof t.length==="number"}const Q=/^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;function W(t){return t!=null}function X(t){let e={};t.forEach((t=>{e=t!=null?Object.assign(Object.assign({},e),t):e}));return Object.keys(e).length===0?null:e}function tt(t,e){return e.map((e=>e(t)))}function et(t){return!t||!t.validate}function st(t){const e=t instanceof Promise?B(t):t;if(!(e instanceof _)){throw new Error("Expected validator to return Promise or Observable.")}return e}class it{static min(t){return e=>{if(G(e.value)||G(t)){return null}const s=parseFloat(e.value);return!Number.isNaN(s)&&s<t?{min:{min:t,actual:e.value}}:null}}static max(t){return e=>{if(G(e.value)||G(t)){return null}const s=parseFloat(e.value);return!Number.isNaN(s)&&s>t?{max:{max:t,actual:e.value}}:null}}static required(t){return G(t.value)?{required:true}:null}static requiredTrue(t){return t.value===true?null:{required:true}}static email(t){if(G(t.value)){return null}Q.lastIndex=0;return Q.test(t.value)?null:{email:true}}static minLength(t){return e=>{if(G(e.value)||!K(e.value)){return null}return e.value.length<t?{minlength:{requiredLength:t,actualLength:e.value.length}}:null}}static maxLength(t){return e=>K(e.value)&&e.value.length>t?{maxlength:{requiredLength:t,actualLength:e.value.length}}:null}static pattern(t){if(!t){return it.nullValidator}let e;let s;if(typeof t==="string"){s="";if(t.charAt(0)!=="^")s+="^";s+=t;if(t.charAt(t.length-1)!=="$")s+="$";e=new RegExp(s)}else{s=t.toString();e=t}return t=>{if(G(t.value)){return null}const{value:i}=t;e.lastIndex=0;return e.test(i)?null:{pattern:{requiredPattern:s,actualValue:i}}}}static nullValidator(t){return null}static compose(t){if(!t)return null;const e=t.filter(W);if(e.length===0)return null;return function(t){return X(tt(t,e))}}static composeAsync(t){if(!t)return null;const e=t.filter(W);if(e.length===0)return null;return t=>{const s=tt(t,e).map(st);return J(s).pipe(V(X))}}}function rt(t){return et(t)?t:e=>t.validate(e)}function nt(t){return t.map((t=>rt(t)))}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function ht(t){return t!=null?it.compose(nt(t)):null}function ut(t){return t!=null?it.composeAsync(nt(t)):null}var ot;(function(t){t["VALID"]="VALID";t["INVALID"]="INVALID";t["PENDING"]="PENDING";t["DISABLED"]="DISABLED"})(ot||(ot={}));
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function lt(t,e,s){let i=e;if(i==null){return null}if(!Array.isArray(i)){i=i.split(s)}if(Array.isArray(i)&&i.length===0)return null;let r=t;i.forEach((t=>{if(r instanceof wt){r=Object.prototype.hasOwnProperty.call(r.controls,t)?r.controls[t]:null}else if(r instanceof mt){r=r.at(t)||null}else{r=null}}));return r}function ct(t){return(bt(t)?t.validators:t)||null}function ft(t){return Array.isArray(t)?ht(t):rt(t)||null}function at(t,e){return(bt(e)?e.asyncValidators:t)||null}function dt(t){return Array.isArray(t)?ut(t):rt(t)||null}function bt(t){return t!=null&&!Array.isArray(t)&&typeof t==="object"}class yt{setCustomData(t,e){if(e){this._customData[t]=e}else{delete this._customData[t]}}getCustomData(t){return this._customData[t]}getHtmlElement(){return this._htmlElement}setHtmlElement(t){this._htmlElement=t}get validator(){return this._composedValidatorFn}set validator(t){this._composedValidatorFn=t;this._rawValidators=t}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(t){this._composedAsyncValidatorFn=t;this._rawAsyncValidators=t}get parent(){return this._parent}get valid(){return this.status===ot.VALID}get invalid(){return this.status===ot.INVALID}get pending(){return this.status===ot.PENDING}get disabled(){return this.status===ot.DISABLED}get enabled(){return this.status!==ot.DISABLED}get dirty(){return!this.pristine}get untouched(){return!this.touched}get updateOn(){if(this._updateOn){return this._updateOn}return this.parent?this.parent.updateOn:"change"}constructor(t,e){this._hasOwnPendingAsyncValidator=false;this._customData={};this.pristine=true;this.touched=false;this._onCollectionChange=()=>{};this._onDisabledChange=[];this._rawValidators=t;this._rawAsyncValidators=e;this._composedValidatorFn=ft(this._rawValidators);this._composedAsyncValidatorFn=dt(this._rawAsyncValidators)}getValidators(){return this._rawValidators}setValidators(t){this._rawValidators=t;this._composedValidatorFn=ft(t)}getAsyncValidators(){return this._rawAsyncValidators}setAsyncValidators(t){this._rawAsyncValidators=t;this._composedAsyncValidatorFn=dt(t)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(t={}){this.touched=true;if(this._parent&&!t.onlySelf){this._parent.markAsTouched(Object.assign(Object.assign({},t),{emitEvent:false}))}if(t.emitEvent){this.statusChanges.next(this.status)}}markAllAsTouched(){this.markAsTouched({onlySelf:true});this._forEachChild((t=>t.markAllAsTouched()))}markAsUntouched(t={}){this.touched=false;this._pendingTouched=false;this._forEachChild((t=>{t.markAsUntouched({onlySelf:true,emitEvent:false})}));if(this._parent&&!t.onlySelf){this._parent._updateTouched(t)}if(t.emitEvent){this.statusChanges.next(this.status)}}markAsDirty(t={}){this.pristine=false;if(this._parent&&!t.onlySelf){this._parent.markAsDirty(t)}}markAsPristine(t={}){this.pristine=true;this._pendingDirty=false;this._forEachChild((t=>{t.markAsPristine({onlySelf:true})}));if(this._parent&&!t.onlySelf){this._parent._updatePristine(t)}}markAsPending(t={}){this.status=ot.PENDING;if(t.emitEvent){this.statusChanges.next(this.status)}if(this._parent&&!t.onlySelf){this._parent.markAsPending(t)}}disable(t={}){const e=this._parentMarkedDirty(t.onlySelf);this.status=ot.DISABLED;this.errors=null;this._forEachChild((e=>{e.disable(Object.assign(Object.assign({},t),{onlySelf:true}))}));this._updateValue();if(t.emitEvent!==false){this.valueChanges.next(this.value);this.statusChanges.next(this.status)}this._updateAncestors(Object.assign(Object.assign({},t),{skipPristineCheck:e}));this._onDisabledChange.forEach((t=>t(true)))}enable(t={}){const e=this._parentMarkedDirty(t.onlySelf);this.status=ot.VALID;this._forEachChild((e=>{e.enable(Object.assign(Object.assign({},t),{onlySelf:true}))}));this.updateValueAndValidity({onlySelf:true,emitEvent:t.emitEvent});this._updateAncestors(Object.assign(Object.assign({},t),{skipPristineCheck:e}));this._onDisabledChange.forEach((t=>t(false)))}_updateAncestors(t){if(this._parent&&!t.onlySelf){this._parent.updateValueAndValidity(t);if(!t.skipPristineCheck){this._parent._updatePristine()}this._parent._updateTouched()}}setParent(t){this._parent=t}updateValueAndValidity(t={}){this._setInitialStatus();this._updateValue();if(this.enabled){this._cancelExistingSubscription();this.errors=this._runValidator();this.status=this._calculateStatus();if(this.status===ot.VALID||this.status===ot.PENDING){this._runAsyncValidator(t.emitEvent)}}if(t.emitEvent!==false){this.valueChanges.next(this.value);this.statusChanges.next(this.status)}if(this._parent&&!t.onlySelf){this._parent.updateValueAndValidity(t)}}_updateTreeValidity(t={emitEvent:true}){this._forEachChild((e=>e._updateTreeValidity(t)));this.updateValueAndValidity({onlySelf:true,emitEvent:t.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?ot.DISABLED:ot.VALID}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(t){if(this.asyncValidator){this.status=ot.PENDING;this._hasOwnPendingAsyncValidator=true;const e=st(this.asyncValidator(this));this._asyncValidationSubscription=e.subscribe((e=>{this._hasOwnPendingAsyncValidator=false;this.setErrors(e,{emitEvent:t})}))}}_cancelExistingSubscription(){if(this._asyncValidationSubscription){this._asyncValidationSubscription.unsubscribe();this._hasOwnPendingAsyncValidator=false}}setErrors(t,e={}){this.errors=t;this._updateControlsErrors(e.emitEvent!==false)}get(t){return lt(this,t,".")}getError(t,e){const s=e?this.get(e):this;return s&&s.errors?s.errors[t]:null}hasError(t,e){return!!this.getError(t,e)}get root(){let t=this;while(t._parent){t=t._parent}return t}_updateControlsErrors(t){this.status=this._calculateStatus();if(t){this.statusChanges.next(this.status)}if(this._parent){this._parent._updateControlsErrors(t)}}_initObservables(){this.valueChanges=new C;this.statusChanges=new C}_calculateStatus(){if(this._allControlsDisabled())return ot.DISABLED;if(this.errors)return ot.INVALID;if(this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(ot.PENDING)){return ot.PENDING}if(this._anyControlsHaveStatus(ot.INVALID))return ot.INVALID;return ot.VALID}_anyControlsHaveStatus(t){return this._anyControls((e=>e.status===t))}_anyControlsDirty(){return this._anyControls((t=>t.dirty))}_anyControlsTouched(){return this._anyControls((t=>t.touched))}_updatePristine(t={}){this.pristine=!this._anyControlsDirty();if(this._parent&&!t.onlySelf){this._parent._updatePristine(t)}}_updateTouched(t={}){this.touched=this._anyControlsTouched();if(this._parent&&!t.onlySelf){this._parent._updateTouched(t)}}_isBoxedValue(t){return typeof t==="object"&&t!==null&&Object.keys(t).length===2&&"value"in t&&"disabled"in t}_registerOnCollectionChange(t){this._onCollectionChange=t}_setUpdateStrategy(t){if(bt(t)&&t.updateOn!=null){this._updateOn=t.updateOn}}_parentMarkedDirty(t){const e=this._parent&&this._parent.dirty;return!t&&e&&!this._parent._anyControlsDirty()}}class pt extends yt{constructor(t=null,e=null,s=null){super(ct(e),at(s,e));this._onChange=[];this._applyFormState(t);this._initObservables();this._setUpdateStrategy(e);this.updateValueAndValidity({onlySelf:true,emitEvent:!!s})}setValue(t,e={}){this._pendingValue=t;this.value=t;try{const e=this.getHtmlElement();e.value=t}catch(t){}if(this._onChange.length&&e.emitModelToViewChange){this._onChange.forEach((t=>t(this.value,e.emitViewToModelChange)))}this.updateValueAndValidity(e)}patchValue(t,e={}){this.setValue(t,e)}reset(t=null,e={}){this._applyFormState(t);this.markAsPristine(e);this.markAsUntouched(e);this.setValue(this.value,e);this._pendingChange=false}_updateValue(){}_anyControls(t){return false}_allControlsDisabled(){return this.disabled}registerOnChange(t){this._onChange.push(t)}_clearChangeFns(){this._onChange=[];this._onDisabledChange=[];this._onCollectionChange=()=>{}}registerOnDisabledChange(t){this._onDisabledChange.push(t)}_forEachChild(t){}_syncPendingControls(){if(this.updateOn==="submit"){if(this._pendingDirty)this.markAsDirty();if(this._pendingTouched)this.markAsTouched();if(this._pendingChange){this.setValue(this._pendingValue,{onlySelf:true,emitModelToViewChange:false});return true}}return false}_applyFormState(t){if(this._isBoxedValue(t)){this._pendingValue=t.value;this.value=t.value;if(t.disabled){this.disable({onlySelf:true,emitEvent:false})}else{this.enable({onlySelf:true,emitEvent:false})}}else{this._pendingValue=t;this.value=t}}}class wt extends yt{constructor(t,e,s){super(ct(e),at(s,e));this.controls=t;this._initObservables();this._setUpdateStrategy(e);this._setUpControls();this.updateValueAndValidity({onlySelf:true,emitEvent:!!s})}registerControl(t,e){if(this.controls[t])return this.controls[t];this.controls[t]=e;e.setParent(this);e._registerOnCollectionChange(this._onCollectionChange);return e}addControl(t,e){this.registerControl(t,e);this.updateValueAndValidity();this._onCollectionChange()}removeControl(t){if(this.controls[t]){this.controls[t]._registerOnCollectionChange((()=>{}))}delete this.controls[t];this.updateValueAndValidity();this._onCollectionChange()}setControl(t,e){if(this.controls[t]){this.controls[t]._registerOnCollectionChange((()=>{}))}delete this.controls[t];if(e)this.registerControl(t,e);this.updateValueAndValidity();this._onCollectionChange()}contains(t){return Object.prototype.hasOwnProperty.call(this.controls,t)&&this.controls[t].enabled}setValue(t,e={}){this._checkAllValuesPresent(t);Object.keys(t).forEach((s=>{this._throwIfControlMissing(s);this.controls[s].setValue(t[s],{onlySelf:true,emitEvent:e.emitEvent})}));this.updateValueAndValidity(e)}patchValue(t,e={}){Object.keys(t).forEach((s=>{if(this.controls[s]){this.controls[s].patchValue(t[s],{onlySelf:true,emitEvent:e.emitEvent})}}));this.updateValueAndValidity(e)}reset(t={},e={}){this._forEachChild(((s,i)=>{s.reset(t[i],{onlySelf:true,emitEvent:e.emitEvent})}));this._updatePristine(e);this._updateTouched(e);this.updateValueAndValidity(e)}getRawValue(){return this._reduceChildren({},((t,e,s)=>{t[s]=e instanceof pt?e.value:e.getRawValue();return t}))}_syncPendingControls(){const t=this._reduceChildren(false,((t,e)=>e._syncPendingControls()?true:t));if(t)this.updateValueAndValidity({onlySelf:true});return t}_throwIfControlMissing(t){if(!Object.keys(this.controls).length){throw new Error(`\n There are no form controls registered with this group yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n `)}if(!this.controls[t]){throw new Error(`Cannot find form control with name: ${t}.`)}}_forEachChild(t){Object.keys(this.controls).forEach((e=>t(this.controls[e],e)))}_setUpControls(){this._forEachChild((t=>{t.setParent(this);t._registerOnCollectionChange(this._onCollectionChange)}))}_updateValue(){this.value=this._reduceValue()}_anyControls(t){const e=Object.keys(this.controls);return e.some((e=>{const s=this.controls[e];if(this.contains(e)&&t(s)){return true}return false}))}_reduceValue(){return this._reduceChildren({},((t,e,s)=>{if(e.enabled||this.disabled){t[s]=e.value}return t}))}_reduceChildren(t,e){let s=t;this._forEachChild(((t,i)=>{s=e(s,t,i)}));return s}_allControlsDisabled(){if(Object.keys(this.controls).some((t=>this.controls[t].enabled))){return false}return Object.keys(this.controls).length>0||this.disabled}_checkAllValuesPresent(t){this._forEachChild(((e,s)=>{if(t[s]===undefined){throw new Error(`Must supply a value for form control with name: '${s}'.`)}}))}}class mt extends yt{constructor(t,e,s){super(ct(e),at(s,e));this.controls=t;this._initObservables();this._setUpdateStrategy(e);this._setUpControls();this.updateValueAndValidity({onlySelf:true,emitEvent:!!s})}at(t){return this.controls[t]}push(t){this.controls.push(t);this._registerControl(t);this.updateValueAndValidity();this._onCollectionChange()}insert(t,e){this.controls.splice(t,0,e);this._registerControl(e);this.updateValueAndValidity()}removeAt(t){if(this.controls[t]){this.controls[t]._registerOnCollectionChange((()=>{}))}this.controls.splice(t,1);this.updateValueAndValidity()}setControl(t,e){if(this.controls[t]){this.controls[t]._registerOnCollectionChange((()=>{}))}this.controls.splice(t,1);if(e){this.controls.splice(t,0,e);this._registerControl(e)}this.updateValueAndValidity();this._onCollectionChange()}get length(){return this.controls.length}setValue(t,e={}){this._checkAllValuesPresent(t);t.forEach(((t,s)=>{this._throwIfControlMissing(s);this.at(s).setValue(t,{onlySelf:true,emitEvent:e.emitEvent})}));this.updateValueAndValidity(e)}patchValue(t,e={}){t.forEach(((t,s)=>{if(this.at(s)){this.at(s).patchValue(t,{onlySelf:true,emitEvent:e.emitEvent})}}));this.updateValueAndValidity(e)}reset(t=[],e={}){this._forEachChild(((s,i)=>{s.reset(t[i],{onlySelf:true,emitEvent:e.emitEvent})}));this._updatePristine(e);this._updateTouched(e);this.updateValueAndValidity(e)}getRawValue(){return this.controls.map((t=>t instanceof pt?t.value:t.getRawValue()))}clear(){if(this.controls.length<1)return;this._forEachChild((t=>t._registerOnCollectionChange((()=>{}))));this.controls.splice(0);this.updateValueAndValidity()}_syncPendingControls(){const t=this.controls.reduce(((t,e)=>e._syncPendingControls()?true:t),false);if(t)this.updateValueAndValidity({onlySelf:true});return t}_throwIfControlMissing(t){if(!this.controls.length){throw new Error(`\n There are no form controls registered with this array yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n `)}if(!this.at(t)){throw new Error(`Cannot find form control at index ${t}`)}}_forEachChild(t){this.controls.forEach(t)}_updateValue(){this.value=this.controls.filter((t=>t.enabled||this.disabled)).map((t=>t.value))}_anyControls(t){return this.controls.some((e=>e.enabled&&t(e)))}_setUpControls(){this._forEachChild((t=>this._registerControl(t)))}_checkAllValuesPresent(t){this._forEachChild(((e,s)=>{if(t[s]===undefined){throw new Error(`Must supply a value for form control at index: ${s}.`)}}))}_allControlsDisabled(){if(this.controls.some((t=>t.enabled))){return false}return this.controls.length>0||this.disabled}_registerControl(t){t.setParent(this);t._registerOnCollectionChange(this._onCollectionChange)}}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function _t(t){return t.asyncValidators!==undefined||t.validators!==undefined||t.updateOn!==undefined}class gt{group(t,e=null){const s=this._reduceControls(t);let i=null;let r=null;let n;if(e!=null){if(_t(e)){i=e.validators!=null?e.validators:null;r=e.asyncValidators!=null?e.asyncValidators:null;n=e.updateOn!=null?e.updateOn:undefined}else{i=e.validator!=null?e.validator:null;r=e.asyncValidator!=null?e.asyncValidator:null}}return new wt(s,{asyncValidators:r,updateOn:n,validators:i})}control(t,e,s){return new pt(t,e,s)}array(t,e,s){const i=t.map((t=>this._createControl(t)));return new mt(i,e,s)}_reduceControls(t){const e={};Object.keys(t).forEach((s=>{e[s]=this._createControl(t[s])}));return e}_createControl(t){if(t instanceof pt||t instanceof wt||t instanceof mt){return t}if(Array.isArray(t)){const e=t[0];const s=t.length>1?t[1]:null;const i=t.length>2?t[2]:null;return this.control(e,s,i)}return this.control(t)}}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/window.FormBuilder=gt;window.Validators=it;window.AbstractControl=yt;window.FormArray=mt;window.FormControl=pt;window.FormGroup=wt;export{yt as A,gt as F,ot as R,it as V,mt as a,pt as b,wt as c};
//# sourceMappingURL=p-2d9acbd6.js.map