UNPKG

@ohayojp/form

Version:
20 lines (18 loc) 99 kB
/** * @license ohayojp(cipchk@qq.com) v1.0.2 * (c) 2020 cipchk https://ohayojp.com/ * License: MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/platform"),require("@angular/core"),require("@angular/platform-browser"),require("@ohayojp/acl"),require("@ohayojp/theme"),require("@ohayojp/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/forms"),require("ng-zorro-antd/auto-complete"),require("ng-zorro-antd/button"),require("ng-zorro-antd/card"),require("ng-zorro-antd/cascader"),require("ng-zorro-antd/checkbox"),require("ng-zorro-antd/date-picker"),require("ng-zorro-antd/form"),require("ng-zorro-antd/grid"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/input"),require("ng-zorro-antd/input-number"),require("ng-zorro-antd/mention"),require("ng-zorro-antd/modal"),require("ng-zorro-antd/radio"),require("ng-zorro-antd/rate"),require("ng-zorro-antd/select"),require("ng-zorro-antd/slider"),require("ng-zorro-antd/switch"),require("ng-zorro-antd/tag"),require("ng-zorro-antd/time-picker"),require("ng-zorro-antd/tooltip"),require("ng-zorro-antd/transfer"),require("ng-zorro-antd/tree-select"),require("ng-zorro-antd/upload"),require("ng-zorro-antd/core/animation"),require("date-fns/format")):"function"==typeof define&&define.amd?define("@ohayojp/form",["exports","@angular/cdk/platform","@angular/core","@angular/platform-browser","@ohayojp/acl","@ohayojp/theme","@ohayojp/util","rxjs","rxjs/operators","@angular/common","@angular/forms","ng-zorro-antd/auto-complete","ng-zorro-antd/button","ng-zorro-antd/card","ng-zorro-antd/cascader","ng-zorro-antd/checkbox","ng-zorro-antd/date-picker","ng-zorro-antd/form","ng-zorro-antd/grid","ng-zorro-antd/icon","ng-zorro-antd/input","ng-zorro-antd/input-number","ng-zorro-antd/mention","ng-zorro-antd/modal","ng-zorro-antd/radio","ng-zorro-antd/rate","ng-zorro-antd/select","ng-zorro-antd/slider","ng-zorro-antd/switch","ng-zorro-antd/tag","ng-zorro-antd/time-picker","ng-zorro-antd/tooltip","ng-zorro-antd/transfer","ng-zorro-antd/tree-select","ng-zorro-antd/upload","ng-zorro-antd/core/animation","date-fns/format"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ohayojp=e.ohayojp||{},e.ohayojp.form={}),e.ng.cdk.platform,e.ng.core,e.ng.platformBrowser,e.ohayo.acl,e.ohayo.theme,e.ohayo.util,e.rxjs,e.rxjs.operators,e.ng.common,e.ng.forms,e["ng-zorro-antd/auto-complete"],e["ng-zorro-antd/button"],e["ng-zorro-antd/card"],e["ng-zorro-antd/cascader"],e["ng-zorro-antd/checkbox"],e["ng-zorro-antd/date-picker"],e["ng-zorro-antd/form"],e["ng-zorro-antd/grid"],e["ng-zorro-antd/icon"],e["ng-zorro-antd/input"],e["ng-zorro-antd/input-number"],e["ng-zorro-antd/mention"],e["ng-zorro-antd/modal"],e["ng-zorro-antd/radio"],e["ng-zorro-antd/rate"],e["ng-zorro-antd/select"],e["ng-zorro-antd/slider"],e["ng-zorro-antd/switch"],e["ng-zorro-antd/tag"],e["ng-zorro-antd/time-picker"],e["ng-zorro-antd/tooltip"],e["ng-zorro-antd/transfer"],e["ng-zorro-antd/tree-select"],e["ng-zorro-antd/upload"],e["ng-zorro-antd/core/animation"],e.format)}(this,(function(e,t,n,i,r,o,a,s,l,u,p,c,h,d,f,m,g,y,v,b,z,w,C,_,x,O,S,V,E,T,P,I,M,D,k,F,j){"use strict";function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=A(j),L={formatMap:{"date-time":{widget:"date",showTime:!0,format:"yyyy-MM-dd'T'HH:mm:ss.SSSxxx"},date:{widget:"date",format:"yyyy-MM-dd"},"full-date":{widget:"date",format:"yyyy-MM-dd"},time:{widget:"time",format:"HH:mm:ss.SSSxxx"},"full-time":{widget:"time"},week:{widget:"date",mode:"week",format:"yyyy-ww"},month:{widget:"date",mode:"month",format:"yyyy-MM"},uri:{widget:"upload"},email:{widget:"autocomplete",type:"email"},color:{widget:"string",type:"color"},"":{widget:"string"}},ingoreKeywords:["type","enum"],liveValidate:!0,autocomplete:null,firstVisual:!1,onlyVisual:!1,errors:{},ui:{},button:{submit_type:"primary",reset_type:"default"},uiDateStringFormat:"yyyy-MM-dd HH:mm:ss",uiDateNumberFormat:"T",uiTimeStringFormat:"HH:mm:ss",uiTimeNumberFormat:"T",uiEmailSuffixes:["qq.com","163.com","gmail.com","126.com","aliyun.com"]};function R(e){return e.merge("sf",L)} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var W=function(e,t){return(W=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function $(e,t){function n(){this.constructor=e}W(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function q(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function H(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;function B(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function U(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function G(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(U(arguments[t]));return e}Object.create;var K="/";function X(e){return null==e}function Y(e,t){return null==(e=a.toBoolean(e,!0))?t:e}function J(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e.debug&&console.warn.apply(console,G(t))}function Q(e,t){if(void 0===t&&(t={}),e.hasOwnProperty("$ref")){var n=function(e,t){var n,i,r=/^#\/definitions\/(.*)$/.exec(e);if(r&&r[1]){var o=r[1].split(K),a=t;try{for(var s=B(o),l=s.next();!l.done;l=s.next()){var u=l.value;if(u=u.replace(/~1/g,K).replace(/~0/g,"~"),!a.hasOwnProperty(u))throw new Error("Could not find a definition for "+e+".");a=a[u]}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return a}throw new Error("Could not find a definition for "+e+".")}(e.$ref,t),i=(e.$ref,function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["$ref"]));return Q(Object.assign(Object.assign({},n),i),t)}return e}function Z(e,t){var n=function(e,t){!function(e,t){if(!e.hasOwnProperty("if")||!e.hasOwnProperty("then"))return null;if(!e.if.properties)throw new Error("if: does not contain 'properties'");var n=Object.keys(e.properties),i=Object.keys(e.if.properties);ee(n,i),ee(n,e.then.required),e.required=e.required.concat(e.then.required);var r=e.hasOwnProperty("else");r&&(ee(n,e.else.required),e.required=e.required.concat(e.else.required));var o={},a={};i.forEach((function(t){var n=e.if.properties[t].enum;o[t]=n,r&&(a[t]=function(e){return!n.includes(e)})})),e.then.required.forEach((function(e){return t["$"+e].visibleIf=o})),r&&e.else.required.forEach((function(e){return t["$"+e].visibleIf=a}))}(e,t),Object.keys(e.properties).forEach((function(i){var r=e.properties[i],o="$"+i;r.items&&n(r.items,t[o].$items),r.properties&&n(r,t[o])}))};n(e,t)}function ee(e,t){t.forEach((function(t){if(!e.includes(t))throw new Error("if: properties does not contain '"+t+"'")}))}function te(e,t){if(!Array.isArray(t))return e;var n=function(e){return e.reduce((function(e,t){return e[t]=!0,e}),{})},i=function(e){return"property ["+e.join("', '")+"]"},r=n(e),o=n(t),a=t.filter((function(e){return"*"!==e&&!r[e]}));if(a.length)throw new Error("ui schema order list contains extraneous "+i(a));var s=e.filter((function(e){return!o[e]})),l=t.indexOf("*");if(-1===l){if(s.length)throw new Error("ui schema order list does not contain "+i(s));return t}if(l!==t.lastIndexOf("*"))throw new Error("ui schema order list contains more than one wildcard item");var u=G(t);return u.splice.apply(u,G([l,1],s)),u}function ne(e,t,n){return X(e)||!Array.isArray(e)||0===e.length?[]:("object"!=typeof e[0]&&(e=e.map((function(e){return{label:e,value:e}}))),t&&(Array.isArray(t)||(t=[t]),e.forEach((function(e){~t.indexOf(e.value)&&(e.checked=!0)}))),n&&e.forEach((function(e){return e.disabled=!0})),e)}function ie(e,t,n){return ne(a.deepCopy(e||[]),t,n)}function re(e,t,n,i){return"function"==typeof t.asyncData?t.asyncData(i).pipe(l.map((function(t){return ne(t,n,e.readOnly)}))):s.of(ie(e.enum,n,e.readOnly))}var oe=function(){function e(e,t,n,i,r,o,a){this._options=a,this._errors=null,this._valueChanges=new s.BehaviorSubject({path:null,pathValue:null,value:null}),this._errorsChanges=new s.BehaviorSubject(null),this._visible=!0,this._visibilityChanges=new s.BehaviorSubject(!0),this._objErrors={},this._value=null,this.schema=t,this.ui=n,this.schemaValidator=e.createValidatorFn(t,{ingoreKeywords:this.ui.ingoreKeywords,debug:n.debug}),this.formData=i||t.default,this._parent=r,this._root=r?r.root:this,this.path=o}return Object.defineProperty(e.prototype,"valueChanges",{get:function(){return this._valueChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errorsChanges",{get:function(){return this._errorsChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.schema.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errors",{get:function(){return this._errors},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valid",{get:function(){return null===this._errors||0===this._errors.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),e.prototype.updateValueAndValidity=function(e){e=Object.assign({onlySelf:!1,emitValidator:!0,emitValueEvent:!0,updatePath:"",updateValue:null},e),this._updateValue(),e.emitValueEvent&&(e.updatePath=e.updatePath||this.path,e.updateValue=e.updateValue||this.value,this.valueChanges.next({value:this.value,path:e.updatePath,pathValue:e.updateValue})),e.emitValidator&&!0===this.ui.liveValidate&&this._runValidation(),this.parent&&!e.onlySelf&&this.parent.updateValueAndValidity(Object.assign(Object.assign({},e),{emitValidator:!1}))},e.prototype.searchProperty=function(e){var t=this,n=null,i=null;if(e[0]===K)i=(n=this.findRoot()).getProperty(e.substr(1));else for(;null===i&&null!==t.parent;)t=n=t.parent,i=n.getProperty(e);return i},e.prototype.findRoot=function(){for(var e=this;null!==e.parent;)e=e.parent;return e},e.prototype.isEmptyData=function(e){if(X(e))return!0;switch(this.type){case"string":return 0===(""+e).length}return!1},e.prototype._runValidation=function(){var e,t=this,n=this.isEmptyData(this._value);e=n&&this.ui._required?[{keyword:"required"}]:n?[]:this.schemaValidator(this._value)||[];var i=this.ui.validator;if("function"==typeof i){var r=i(this.value,this,this.findRoot());return r instanceof s.Observable?void r.subscribe((function(n){t.setCustomErrors(e,n),t.widget.detectChanges()})):void this.setCustomErrors(e,r)}this._errors=e,this.setErrors(this._errors)},e.prototype.setCustomErrors=function(e,t){null!=t&&t.length>0&&t.forEach((function(e){if(!e.message)throw new Error("The custom validator must contain a 'message' attribute to viewed error text");e._custom=!0})),this._errors=this.mergeErrors(e,t),this.setErrors(this._errors)},e.prototype.mergeErrors=function(e,t){return t&&(Array.isArray(t)?e=e.concat.apply(e,G(t)):e.push(t)),e},e.prototype.setErrors=function(e,t){var n=this;if(void 0===t&&(t=!0),t&&e&&!this.ui.onlyVisual){var i=this.widget&&this.widget.l.error||{};e=e.map((function(e){var t=!0===e._custom&&e.message?e.message:(n.ui.errors||{})[e.keyword]||n._options.errors[e.keyword]||i[e.keyword]||"";return t&&"function"==typeof t&&(t=t(e)),t&&(~t.indexOf("{")&&(t=t.replace(/{([\.a-z0-9]+)}/g,(function(t,n){return e.params[n]||""}))),e.message=t),e}))}this._errors=e,this._errorsChanges.next(e),this._parent&&this._parent.setParentAndPlatErrors(e,this.path)},e.prototype.setParentAndPlatErrors=function(e,t){var n=this;this._objErrors[t]=e;var i=[];Object.keys(this._objErrors).forEach((function(e){var t=n.searchProperty(e);t&&!t.visible||i.push.apply(i,G(n._objErrors[e]))})),this.setErrors(i,!1)},e.prototype.setVisible=function(e){var t,n;this._visible=e,this._visibilityChanges.next(e),!0===(null===(n=null===(t=this.root.widget)||void 0===t?void 0:t.sfComp)||void 0===n?void 0:n._inited)&&this.resetValue(this.value,!0)},e.prototype._bindVisibility=function(){var e=this,t=this.ui.visibleIf;if("object"==typeof t&&0===Object.keys(t).length)this.setVisible(!1);else if(void 0!==t){var n=[],i=function(e){if(t.hasOwnProperty(e)){var i=r.searchProperty(e);if(i){var o=i.valueChanges.pipe(l.map((function(n){var i=t[e];return"function"==typeof i?i(n.value):-1!==i.indexOf("$ANY$")?n.value.length>0:-1!==i.indexOf(n.value)}))),a=i._visibilityChanges,u=s.combineLatest([o,a]).pipe(l.map((function(e){return e[0]&&e[1]})));n.push(u)}else console.warn("Can't find property "+e+" for visibility check of "+r.path)}},r=this;for(var o in t)i(o);s.combineLatest(n).pipe(l.map((function(e){return-1!==e.indexOf(!0)})),l.distinctUntilChanged()).subscribe((function(t){return e.setVisible(t)}))}},e}();var ae=function(e){function t(){var t=e.apply(this,G(arguments))||this;return t.properties=null,t}return $(t,e),t.prototype.getProperty=function(e){var n=e.indexOf(K),i=-1!==n?e.substr(0,n):e,r=this.properties[i];if(null!==r&&-1!==n&&r instanceof t){var o=e.substr(n+1);r=r.getProperty(o)}return r},t.prototype.forEachChild=function(e){for(var t in this.properties){if(this.properties.hasOwnProperty(t))e(this.properties[t],t)}},t.prototype.forEachChildRecursive=function(e){this.forEachChild((function(n){e(n),n instanceof t&&n.forEachChildRecursive(e)}))},t.prototype._bindVisibility=function(){e.prototype._bindVisibility.call(this),this._bindVisibilityRecursive()},t.prototype._bindVisibilityRecursive=function(){this.forEachChildRecursive((function(e){e._bindVisibility()}))},t.prototype.isRoot=function(){return this===this.root},t}(oe);var se=function(e){function t(t,n,i,r,o,a,s,l){var u=e.call(this,n,i,r,o,a,s,l)||this;return u.formPropertyFactory=t,u._propertiesId=[],u.createProperties(),u}return $(t,e),Object.defineProperty(t.prototype,"propertiesId",{get:function(){return this._propertiesId},enumerable:!1,configurable:!0}),t.prototype.createProperties=function(){var e,t=this;this.properties={},this._propertiesId=[];try{e=te(Object.keys(this.schema.properties),this.ui.order)}catch(e){console.error("Invalid "+(this.schema.title||"root")+" object field configuration:",e)}e.forEach((function(e){t.properties[e]=t.formPropertyFactory.createProperty(t.schema.properties[e],t.ui["$"+e],(t.formData||{})[e],t,e),t._propertiesId.push(e)}))},t.prototype.setValue=function(e,t){var n=this.properties;for(var i in e)e.hasOwnProperty(i)&&n[i]&&n[i].setValue(e[i],!0);this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t.prototype.resetValue=function(e,t){e=e||this.schema.default||{};var n=this.properties;for(var i in this.schema.properties)n[i].resetValue(e[i],!0);this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t.prototype._hasValue=function(){return null!=this.value&&!!Object.keys(this.value).length},t.prototype._updateValue=function(){var e={};this.forEachChild((function(t,n){t.visible&&t._hasValue()&&(e[n]=t.value)})),this._value=e},t}(ae);var le=function(e){function t(t,n,i,r,o,a,s,l){var u=e.call(this,n,i,r,o,a,s,l)||this;return u.formPropertyFactory=t,u.properties=[],u}return $(t,e),t.prototype.getProperty=function(e){var t=e.indexOf(K),n=+(-1!==t?e.substr(0,t):e),i=this.properties;if(!(isNaN(n)||n>=i.length)){var r=e.substr(t+1);return i[n].getProperty(r)}},t.prototype.setValue=function(e,t){this.properties=[],this.clearErrors(),this.resetProperties(e),this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t.prototype.resetValue=function(e,t){this._value=e||this.schema.default||[],this.setValue(this._value,t)},t.prototype._hasValue=function(){return!0},t.prototype._updateValue=function(){var e=this,t=[];this.forEachChild((function(n){var i;n.visible&&n._hasValue()&&t.push(Object.assign(Object.assign({},(null===(i=e.widget)||void 0===i?void 0:i.cleanValue)?null:n.formData),n.value))})),this._value=t},t.prototype.addProperty=function(e){var t=this.formPropertyFactory.createProperty(this.schema.items,this.ui.$items,e,this);return this.properties.push(t),t},t.prototype.resetProperties=function(e){var t,n;try{for(var i=B(e),r=i.next();!r.done;r=i.next()){var o=r.value;this.addProperty(o).resetValue(o,!0)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},t.prototype.clearErrors=function(e){(e||this)._objErrors={}},t.prototype.add=function(e){var t=this.addProperty(e);return t.resetValue(e,!1),t},t.prototype.remove=function(e){var t=this,n=this.properties;this.clearErrors(),n.splice(e,1),n.forEach((function(e,n){e.path=[e.parent.path,n].join(K),t.clearErrors(e),e instanceof se&&e.forEachChild((function(e){e.updateValueAndValidity()}))})),0===n.length&&this.updateValueAndValidity()},t}(ae);var ue=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.setValue=function(e,t){this._value=e,this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t.prototype.resetValue=function(e,t){null==e&&(e=void 0!==this.schema.default?this.schema.default:this.fallbackValue()),this._value=e,this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0}),this.widget&&this.widget.reset(e)},t.prototype._hasValue=function(){return this.fallbackValue()!==this.value},t.prototype._updateValue=function(){},t}(oe);var pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.fallbackValue=function(){return null},t}(ue),ce=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.fallbackValue=function(){return null},t.prototype.setValue=function(e,t){"string"==typeof e&&(e=e.length?e.indexOf(".")>-1?parseFloat(e):parseInt(e,10):void 0),this._value=e,this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t}(ue),he=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.fallbackValue=function(){return null},t.prototype.setValue=function(e,t){this._value=null==e?"":e,this.updateValueAndValidity({onlySelf:t,emitValueEvent:!0})},t}(ue),de=function(){function e(e,t){this.schemaValidatorFactory=e,this.options=R(t)}return e.prototype.createProperty=function(e,t,n,i,r){void 0===i&&(i=null);var o=null,a="";if(i)switch(a+=i.path,null!==i.parent&&(a+=K),i.type){case"object":a+=r;break;case"array":a+=i.properties.length;break;default:throw new Error("Instanciation of a FormProperty with an unknown parent type: "+i.type)}else a=K;if(e.$ref){var s=Q(e,i.root.schema.definitions);o=this.createProperty(s,t,n,i,a)}else switch((r&&-1!==i.schema.required.indexOf(r.split(K).pop())||!0===t.showRequired)&&(t._required=!0),null==e.title&&(e.title=r),"string"!==e.type&&"number"!==e.type||e.format||t.format?t._format=t.format:"date"===t.widget?t._format="string"===e.type?this.options.uiDateStringFormat:this.options.uiDateNumberFormat:"time"===t.widget&&(t._format="string"===e.type?this.options.uiTimeStringFormat:this.options.uiTimeNumberFormat),e.type){case"integer":case"number":o=new ce(this.schemaValidatorFactory,e,t,n,i,a,this.options);break;case"string":o=new he(this.schemaValidatorFactory,e,t,n,i,a,this.options);break;case"boolean":o=new pe(this.schemaValidatorFactory,e,t,n,i,a,this.options);break;case"object":o=new se(this,this.schemaValidatorFactory,e,t,n,i,a,this.options);break;case"array":o=new le(this,this.schemaValidatorFactory,e,t,n,i,a,this.options);break;default:throw new TypeError("Undefined type "+e.type)}return o instanceof ae&&this.initializeRoot(o),o},e.prototype.initializeRoot=function(e){e._bindVisibility()},e}();var fe=function(){function e(){this.onDestroy=new s.Subject}return e.prototype.destroy=function(){this.onDestroy.next(!0)},e}();var me=function(){};me.decorators=[{type:n.Injectable}];var ge=function(e){function t(t){var n=e.call(this)||this;return"object"==typeof document&&document?(n.options=R(t),n.ajv=new Ajv(Object.assign(Object.assign({},n.options.ajv),{errorDataPath:"property",allErrors:!0,jsonPointers:!0})),n.ajv.addFormat("data-url",/^data:([a-z]+\/[a-z0-9-+.]+)?;name=(.*);base64,(.*)$/),n.ajv.addFormat("color",/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/),n.ajv.addFormat("mobile",/^(0|\+?86|17951)?1[0-9]{10}$/),n.ajv.addFormat("id-card",/(^\d{15}$)|(^\d{17}([0-9]|X)$)/),n):n}return $(t,e),t.prototype.createValidatorFn=function(e,t){var n=this,i=G(this.options.ingoreKeywords,t.ingoreKeywords||[]);return function(r){try{n.ajv.validate(e,r)}catch(e){t.debug&&console.warn(e)}var o=n.ajv.errors;return n.options&&i&&o&&(o=o.filter((function(e){return-1===i.indexOf(e.keyword)}))),o}},t}(me);ge.decorators=[{type:n.Injectable}],ge.ctorParameters=function(){return[{type:a.OhayoConfigService,decorators:[{type:n.Inject,args:[a.OhayoConfigService]}]}]};var ye=function(){function e(){this._widgets={}}return Object.defineProperty(e.prototype,"widgets",{get:function(){return this._widgets},enumerable:!1,configurable:!0}),e.prototype.setDefault=function(e){this.defaultWidget=e},e.prototype.register=function(e,t){this._widgets[e]=t},e.prototype.has=function(e){return this._widgets.hasOwnProperty(e)},e.prototype.getType=function(e){return this.has(e)?this._widgets[e]:this.defaultWidget},e}();var ve=function(){function e(e,t){this.registry=e,this.resolver=t}return e.prototype.createWidget=function(e,t){this.registry.has(t)||console.warn('No widget for type "'+t+'"');var n=this.registry.getType(t),i=this.resolver.resolveComponentFactory(n);return e.createComponent(i)},e}();function be(e,t){return new de(e,t)}ve.decorators=[{type:n.Injectable}],ve.ctorParameters=function(){return[{type:ye},{type:n.ComponentFactoryResolver}]};var ze=function(){function e(e,t,i,r,o,a,u,p,c){var h=this;this.formPropertyFactory=e,this.terminator=t,this.dom=i,this.cdr=r,this.localeSrv=o,this.aclSrv=a,this.i18nSrv=u,this.platform=c,this.unsubscribe$=new s.Subject,this._renders=new Map,this._valid=!0,this._inited=!1,this.locale={},this.rootProperty=null,this.layout="horizontal",this.button={},this.liveValidate=!0,this.firstVisual=!0,this.onlyVisual=!1,this.compact=!1,this.loading=!1,this.disabled=!1,this.noColon=!1,this.cleanValue=!1,this.formValueChange=new n.EventEmitter,this.formChange=new n.EventEmitter,this.formSubmit=new n.EventEmitter,this.formReset=new n.EventEmitter,this.formError=new n.EventEmitter,this.options=R(p),this.liveValidate=this.options.liveValidate,this.firstVisual=this.options.firstVisual,this.autocomplete=this.options.autocomplete,this.localeSrv.change.pipe(l.takeUntil(this.unsubscribe$)).subscribe((function(){h.locale=h.localeSrv.getData("sf"),h._inited&&(h.validator({emitError:!1,onlyRoot:!1}),h.coverButtonProperty(),h.cdr.markForCheck())}));var d=[this.aclSrv?this.aclSrv.change:null,this.i18nSrv?this.i18nSrv.change:null].filter((function(e){return null!=e}));d.length>0&&s.merge.apply(void 0,G(d)).pipe(l.filter((function(){return h._inited})),l.takeUntil(this.unsubscribe$)).subscribe((function(){return h.refreshSchema()}))}return Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){switch(e){case"search":this.layout="inline",this.firstVisual=!1,this.liveValidate=!1,this._btn&&(this._btn.submit=this._btn.search);break;case"edit":this.layout="horizontal",this.firstVisual=!1,this.liveValidate=!0,this._btn&&(this._btn.submit=this._btn.edit)}this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valid",{get:function(){return this._valid},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._item},enumerable:!1,configurable:!0}),e.prototype.getProperty=function(e){return this.rootProperty.searchProperty(e)},e.prototype.getValue=function(e){return this.getProperty(e).value},e.prototype.setValue=function(e,t){var n=this.getProperty(e);if(!n)throw new Error("Invalid path: "+e);return n.resetValue(t,!1),this},e.prototype.onSubmit=function(e){e.preventDefault(),e.stopPropagation(),this.liveValidate||this.validator(),this.valid&&this.formSubmit.emit(this.value)},e.prototype.fanyi=function(e){return(this.i18nSrv?this.i18nSrv.fanyi(e):"")||e},e.prototype.inheritUI=function(e){var t=this;["optionalHelp"].filter((function(e){return!!t._defUi[e]})).forEach((function(n){return e[n]=Object.assign(Object.assign({},t._defUi[n]),e[n])}))},e.prototype.coverProperty=function(){var e=this,t="horizontal"===this.layout,n=a.deepCopy(this.schema),i=n.definitions,r=function(n,o,a,s,l){Array.isArray(n.required)||(n.required=[]),Object.keys(n.properties).forEach((function(o){var u="$"+o,p=Q(n.properties[o],i),c=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({widget:p.type},p.format&&e.options.formatMap[p.format]),"string"==typeof p.ui?{widget:p.ui}:null),!p.format&&!p.ui&&Array.isArray(p.enum)&&p.enum.length>0?{widget:"select"}:null),e._defUi),p.ui),a[u]);if(t?s.spanLabelFixed?c.spanLabelFixed||(c.spanLabelFixed=s.spanLabelFixed):(c.spanLabel||(c.spanLabel=void 0===s.spanLabel?5:s.spanLabel),c.spanControl||(c.spanControl=void 0===s.spanControl?19:s.spanControl),c.offsetControl||(c.offsetControl=void 0===s.offsetControl?null:s.offsetControl)):(c.spanLabel=null,c.spanControl=null,c.offsetControl=null),"inline"===e.layout&&delete c.grid,"horizontal"!==e.layout&&(c.spanLabelFixed=null),null!=c.spanLabelFixed&&c.spanLabelFixed>0&&(c.spanLabel=null,c.spanControl=null),"date"===c.widget&&null!=c.end){var h=n.properties[c.end];h?h.ui=Object.assign(Object.assign({},h.ui),{widget:c.widget,hidden:!0}):c.end=null}if(e.inheritUI(c),c.optionalHelp){"string"==typeof c.optionalHelp&&(c.optionalHelp={text:c.optionalHelp});var d=c.optionalHelp=Object.assign({text:"",icon:"question-circle",placement:"top",trigger:"hover",mouseEnterDelay:.15,mouseLeaveDelay:.1},c.optionalHelp);d.i18n&&(d.text=e.fanyi(d.i18n)),d.text||(c.optionalHelp=void 0)}if(c.i18n&&(p.title=e.fanyi(c.i18n)),c.descriptionI18n&&(p.description=e.fanyi(c.descriptionI18n)),p.description&&(p._description=e.dom.bypassSecurityTrustHtml(p.description)),c.hidden="boolean"==typeof c.hidden&&c.hidden,!1===c.hidden&&c.acl&&e.aclSrv&&!e.aclSrv.can(c.acl)&&(c.hidden=!0),l[u]=c,delete p.ui,!0===c.hidden){var f=n.required.indexOf(o);-1!==f&&n.required.splice(f,1)}if(p.items){var m=(a[u]||{}).$items||{};c.$items=Object.assign(Object.assign(Object.assign({},p.items.ui),m[u]),c.$items),r(p.items,p.items,m,c.$items,c.$items)}p.properties&&Object.keys(p.properties).length&&r(p,n,a[u]||{},c,c)}))};null==this.ui&&(this.ui={}),this._defUi=Object.assign(Object.assign(Object.assign({onlyVisual:this.options.onlyVisual,size:this.options.size,liveValidate:this.liveValidate,firstVisual:this.firstVisual},this.options.ui),n.ui),this.ui["*"]),!0===this.onlyVisual&&(this._defUi.onlyVisual=!0),"inline"===this.layout&&delete this._defUi.grid,this._ui=Object.assign({},this._defUi),r(n,n,this.ui,this.ui,this._ui),Z(n,this._ui),this._schema=n,J(this._ui,"cover schema & ui",this._ui,n)},e.prototype.coverButtonProperty=function(){this._btn=Object.assign(Object.assign(Object.assign({render:{size:"default"}},this.locale),this.options.button),this.button);var e=Object.keys(this._ui).find((function(e){return e.startsWith("$")})),t=this._btn.render;if("horizontal"===this.layout){var n=e?this._ui[e]:this._defUi;t.grid||(t.grid={offset:n.spanLabel,span:n.spanControl}),null==t.spanLabelFixed&&(t.spanLabelFixed=n.spanLabelFixed),!t.class&&"number"==typeof n.spanLabelFixed&&n.spanLabelFixed>0&&(t.class="text-center")}else t.grid={};this._mode&&(this.mode=this._mode),J(this._ui,"button property",this._btn)},e.prototype.ngOnInit=function(){this.platform.isBrowser&&(this._inited=!0,this.validator())},e.prototype.ngOnChanges=function(e){1!==Object.keys(e).length||!e.loading&&!e.disabled?this.refreshSchema():this.cdr.detectChanges()},e.prototype._addTpl=function(e,t){this._renders.has(e)?console.warn('Duplicate definition "'+e+'" custom widget'):(this._renders.set(e,t),this.attachCustomRender())},e.prototype.attachCustomRender=function(){var e=this;this._renders.forEach((function(t,n){var i=e.rootProperty.searchProperty(n);null!=i&&(i.ui._render=t)}))},e.prototype.validator=function(e){if(void 0===e&&(e={emitError:!0,onlyRoot:!0}),!this.platform.isBrowser)return this;var t=function(e){e._runValidation(),e instanceof ae&&e.properties&&(Array.isArray(e.properties)?e.properties.forEach((function(e){return t(e)})):Object.keys(e.properties).forEach((function(n){return t(e.properties[n])})))};e.onlyRoot?this.rootProperty._runValidation():t(this.rootProperty);var n=this.rootProperty.errors;return this._valid=!(n&&n.length),e.emitError&&!this._valid&&this.formError.emit(n),this.cdr.detectChanges(),this},e.prototype.refreshSchema=function(e,t){var n=this;if(!this.platform.isBrowser)return this;if(e&&(this.schema=e),t&&(this.ui=t),!this.schema||void 0===this.schema.properties)throw new Error("Invalid Schema");if(this.schema.ui&&"string"==typeof this.schema.ui)throw new Error("Don't support string with root ui property");this.schema.type="object",this._formData=Object.assign({},this.formData),this._inited&&this.terminator.destroy(),this.cleanRootSub(),this.coverProperty(),this.coverButtonProperty(),this.rootProperty=this.formPropertyFactory.createProperty(this._schema,this._ui,this.formData),this.attachCustomRender(),this.cdr.detectChanges(),this.reset();var i=!0;return this.rootProperty.valueChanges.subscribe((function(e){n._item=Object.assign(Object.assign({},n.cleanValue?null:n.formData),e.value),i?i=!1:(n.formChange.emit(n._item),n.formValueChange.emit({value:n._item,path:e.path,pathValue:e.pathValue}))})),this.rootProperty.errorsChanges.subscribe((function(e){n._valid=!(e&&e.length),n.formError.emit(e),n.cdr.detectChanges()})),this},e.prototype.reset=function(e){var t=this;return void 0===e&&(e=!1),this.platform.isBrowser?(this.rootProperty.resetValue(this.formData,!1),Promise.resolve().then((function(){return t.cdr.detectChanges()})),e&&this.formReset.emit(this.value),this):this},e.prototype.cleanRootSub=function(){this.rootProperty&&(this.rootProperty.errorsChanges.unsubscribe(),this.rootProperty.valueChanges.unsubscribe())},e.prototype.ngOnDestroy=function(){this.cleanRootSub(),this.terminator.destroy();var e=this.unsubscribe$;e.next(),e.complete()},e}();ze.decorators=[{type:n.Component,args:[{selector:"sf, [sf]",exportAs:"sf",template:'<ng-template #con>\n <ng-content></ng-content>\n</ng-template>\n<form nz-form [nzLayout]="layout" (submit)="onSubmit($event)" [attr.autocomplete]="autocomplete">\n <sf-item [formProperty]="rootProperty"></sf-item>\n <ng-container *ngIf="button !== \'none\'; else con">\n <nz-form-item [ngClass]="_btn.render!.class" class="sf-btns" [fixed-label]="_btn.render!.spanLabelFixed">\n <div\n nz-col\n class="ant-form-item-control"\n [nzSpan]="_btn.render!.grid!.span"\n [nzOffset]="_btn.render!.grid!.offset"\n [nzXs]="_btn.render!.grid!.xs"\n [nzSm]="_btn.render!.grid!.sm"\n [nzMd]="_btn.render!.grid!.md"\n [nzLg]="_btn.render!.grid!.lg"\n [nzXl]="_btn.render!.grid!.xl"\n [nzXXl]="_btn.render!.grid!.xxl"\n >\n <div class="ant-form-item-control-input">\n <div class="ant-form-item-control-input-content">\n <ng-container *ngIf="button; else con">\n <button\n type="submit"\n nz-button\n data-type="submit"\n [nzType]="_btn.submit_type"\n [nzSize]="_btn.render!.size"\n [nzLoading]="loading"\n [disabled]="liveValidate && !valid"\n >\n <i\n *ngIf="_btn.submit_icon"\n nz-icon\n [nzType]="_btn.submit_icon.type"\n [nzTheme]="_btn.submit_icon.theme"\n [nzTwotoneColor]="_btn.submit_icon.twoToneColor"\n [nzIconfont]="_btn.submit_icon.iconfont"\n ></i>\n {{ _btn.submit }}\n </button>\n <button\n *ngIf="_btn.reset"\n type="button"\n nz-button\n data-type="reset"\n [nzType]="_btn.reset_type"\n [nzSize]="_btn.render!.size"\n [disabled]="loading"\n (click)="reset(true)"\n >\n <i\n *ngIf="_btn.reset_icon"\n nz-icon\n [nzType]="_btn.reset_icon.type"\n [nzTheme]="_btn.reset_icon.theme"\n [nzTwotoneColor]="_btn.reset_icon.twoToneColor"\n [nzIconfont]="_btn.reset_icon.iconfont"\n ></i>\n {{ _btn.reset }}\n </button>\n </ng-container>\n </div>\n </div>\n </div>\n </nz-form-item>\n </ng-container>\n</form>\n',providers:[ve,{provide:de,useFactory:be,deps:[me,a.OhayoConfigService]},fe],host:{"[class.sf]":"true","[class.sf__inline]":"layout === 'inline'","[class.sf__horizontal]":"layout === 'horizontal'","[class.sf__search]":"mode === 'search'","[class.sf__edit]":"mode === 'edit'","[class.sf__no-error]":"onlyVisual","[class.sf__no-colon]":"noColon","[class.sf__compact]":"compact"},preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None}]}],ze.ctorParameters=function(){return[{type:de},{type:fe},{type:i.DomSanitizer},{type:n.ChangeDetectorRef},{type:o.OhayoLocaleService},{type:r.ACLService,decorators:[{type:n.Optional}]},{type:void 0,decorators:[{type:n.Optional},{type:n.Inject,args:[o.OHAYO_I18N_TOKEN]}]},{type:a.OhayoConfigService},{type:t.Platform}]},ze.propDecorators={layout:[{type:n.Input}],schema:[{type:n.Input}],ui:[{type:n.Input}],formData:[{type:n.Input}],button:[{type:n.Input}],liveValidate:[{type:n.Input}],autocomplete:[{type:n.Input}],firstVisual:[{type:n.Input}],onlyVisual:[{type:n.Input}],compact:[{type:n.Input}],mode:[{type:n.Input}],loading:[{type:n.Input}],disabled:[{type:n.Input}],noColon:[{type:n.Input}],cleanValue:[{type:n.Input}],formValueChange:[{type:n.Output}],formChange:[{type:n.Output}],formSubmit:[{type:n.Output}],formReset:[{type:n.Output}],formError:[{type:n.Output}]},q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"liveValidate",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"firstVisual",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"onlyVisual",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"compact",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"loading",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"disabled",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"noColon",void 0),q([a.InputBoolean(),H("design:type",Object)],ze.prototype,"cleanValue",void 0);var we=0,Ce=function(){function e(e,t){this.widgetFactory=e,this.terminator=t,this.unsubscribe$=new s.Subject,this.widget=null}return e.prototype.onWidgetInstanciated=function(e){this.widget=e;var t="_sf-"+we++,n=this.formProperty.ui;this.widget.formProperty=this.formProperty,this.widget.schema=this.formProperty.schema,this.widget.ui=n,this.widget.id=t,this.widget.firstVisual=n.firstVisual,this.formProperty.widget=e},e.prototype.ngOnInit=function(){var e=this;this.terminator.onDestroy.subscribe((function(){return e.ngOnDestroy()}))},e.prototype.ngOnChanges=function(){this.ref=this.widgetFactory.createWidget(this.container,this.formProperty.ui.widget||this.formProperty.schema.type),this.onWidgetInstanciated(this.ref.instance)},e.prototype.ngOnDestroy=function(){var e=this.unsubscribe$;e.next(),e.complete(),this.ref.destroy()},e}();Ce.decorators=[{type:n.Component,args:[{selector:"sf-item",exportAs:"sfItem",host:{"[class.sf__item]":"true"},template:" <ng-template #target></ng-template> ",preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None}]}],Ce.ctorParameters=function(){return[{type:ve},{type:fe}]},Ce.propDecorators={formProperty:[{type:n.Input}],container:[{type:n.ViewChild,args:["target",{read:n.ViewContainerRef,static:!0}]}]};var _e=function(){function e(e,t){this.render=t,this._inited=!1,this.el=e.nativeElement}return e.prototype.init=function(){if(this._inited&&null!=this.num&&!(this.num<=0)){var e=this.el.querySelector(".ant-row")||this.el;this.render.addClass(e,"sf__fixed");var t=e.querySelector(".ant-form-item-label"),n=e.querySelector(".ant-form-item-control"),i=this.num+"px";t?(this.render.setStyle(t,"flex","0 0 "+i),this.render.setStyle(n,"max-width","calc(100% - "+i+")")):this.render.setStyle(n,"margin-left",i)}},e.prototype.ngAfterViewInit=function(){this._inited=!0,this.init()},e.prototype.ngOnChanges=function(){this._inited&&this.init()},e}();_e.decorators=[{type:n.Directive,args:[{selector:"[fixed-label]"}]}],_e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.Renderer2}]},_e.propDecorators={num:[{type:n.Input,args:["fixed-label"]}]},q([a.InputNumber(),H("design:type",Number)],_e.prototype,"num",void 0);var xe=function(){function e(){this.title=null}return Object.defineProperty(e.prototype,"t",{get:function(){return null===this.title?this.schema.title:this.title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oh",{get:function(){return this.ui.optionalHelp},enumerable:!1,configurable:!0}),e}();xe.decorators=[{type:n.Component,args:[{selector:"sf-item-wrap",template:'<nz-form-item [style.width.px]="ui.width" [class.ant-form-item-has-error]="showError" [class.ant-form-item-with-help]="showError">\n <nz-col *ngIf="showTitle" [nzSpan]="ui.spanLabel" class="ant-form-item-label">\n <label *ngIf="t" [attr.for]="id" [class.ant-form-item-required]="ui._required">\n <span class="sf__label-text">{{ t }}</span>\n <span *ngIf="ui.optional || oh" class="sf__optional">\n {{ ui.optional }}\n <i\n *ngIf="oh"\n nz-tooltip\n [nzTooltipTitle]="oh.text"\n [nzTooltipPlacement]="oh.placement"\n [nzTooltipTrigger]="oh.trigger"\n [nzTooltipColor]="oh.bgColor"\n [nzTooltipOverlayClassName]="oh.overlayClassName"\n [nzTooltipOverlayStyle]="oh.overlayStyle"\n [nzTooltipMouseEnterDelay]="oh.mouseEnterDelay"\n [nzTooltipMouseLeaveDelay]="oh.mouseLeaveDelay"\n nz-icon\n [nzType]="oh.icon"\n ></i>\n </span>\n </label>\n </nz-col>\n <nz-col class="ant-form-item-control" [nzSpan]="ui.spanControl" [nzOffset]="ui.offsetControl">\n <div class="ant-form-item-control-input">\n <div class="ant-form-item-control-input-content">\n <ng-content></ng-content>\n </div>\n </div>\n <div *ngIf="!ui.onlyVisual && showError" class="ant-form-item-explain ant-form-item-explain-error">\n <div @helpMotion>{{ error }}</div>\n </div>\n <div *ngIf="schema.description" class="ant-form-item-extra" [innerHTML]="schema._description"></div>\n </nz-col>\n</nz-form-item>\n',animations:[F.helpMotion],preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None}]}],xe.propDecorators={id:[{type:n.Input}],schema:[{type:n.Input}],ui:[{type:n.Input}],showError:[{type:n.Input}],error:[{type:n.Input}],showTitle:[{type:n.Input}],title:[{type:n.Input}]};var Oe=function(){function e(e,t){this.templateRef=e,this.table=t}return e.prototype.ngOnInit=function(){this.table._addTpl(this.path.startsWith(K)?this.path:K+this.path,this.templateRef)},e}();Oe.decorators=[{type:n.Directive,args:[{selector:"[sf-template]"}]}],Oe.ctorParameters=function(){return[{type:n.TemplateRef},{type:ze}]},Oe.propDecorators={path:[{type:n.Input,args:["sf-template"]}]};var Se=function(){function e(e,t,n,i){this.cd=e,this.injector=t,this.sfItemComp=n,this.sfComp=i,this.showError=!1,this.id="",this.firstVisual=!1}return Object.defineProperty(e.prototype,"cls",{get:function(){return this.ui.class||""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return!(!0!==this.schema.readOnly&&!this.sfComp.disabled)||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"l",{get:function(){return this.formProperty.root.widget.sfComp.locale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oh",{get:function(){return this.ui.optionalHelp},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dom",{get:function(){return this.injector.get(i.DomSanitizer)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cleanValue",{get:function(){var e;return null===(e=this.sfComp)||void 0===e?void 0:e.cleanValue},enumerable:!1,configurable:!0}),e.prototype.ngAfterViewInit=function(){var e=this;this.formProperty.errorsChanges.pipe(l.takeUntil(this.sfItemComp.unsubscribe$)).subscribe((function(t){null!=t&&(J(e.ui,"errorsChanges",e.formProperty.path,t),e.firstVisual&&(e.showError=t.length>0,e.error=e.showError?t[0].message:"",e.cd.detectChanges()),e.firstVisual=!0)})),this.afterViewInit()},e.prototype.setValue=function(e){this.formProperty.setValue(e,!1),J(this.ui,"valueChanges",this.formProperty.path,this.formProperty)},Object.defineProperty(e.prototype,"value",{get:function(){return this.formProperty.value},enumerable:!1,configurable:!0}),e.prototype.detectChanges=function(e){void 0===e&&(e=!1),e?this.cd.markForCheck():this.formProperty.root.widget.cd.markForCheck()},e}();Se.decorators=[{type:n.Directive}],Se.ctorParameters=function(){return[{type:n.ChangeDetectorRef,decorators:[{type:n.Inject,args:[n.ChangeDetectorRef]}]},{type:n.Injector,decorators:[{type:n.Inject,args:[n.Injector]}]},{type:Ce,decorators:[{type:n.Inject,args:[Ce]}]},{type:ze,decorators:[{type:n.Inject,args:[ze]}]}]},Se.propDecorators={cls:[{type:n.HostBinding,args:["class"]}]};var Ve=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.reset=function(e){},t.prototype.afterViewInit=function(){},t}(Se);Ve.decorators=[{type:n.Directive}];var Ee=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.reset=function(e){},t.prototype.afterViewInit=function(){},t}(Se);Ee.decorators=[{type:n.Directive}];var Te=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.reset=function(e){},t.prototype.afterViewInit=function(){},t.prototype.ngAfterViewInit=function(){var e=this;this.formProperty.errorsChanges.pipe(l.takeUntil(this.sfItemComp.unsubscribe$)).subscribe((function(){return e.cd.detectChanges()}))},t}(Se);Te.decorators=[{type:n.Directive}];var Pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $(t,e),t.prototype.reset=function(e){},t.prototype.afterViewInit=function(){},t.prototype.ngAfterViewInit=function(){var e=this;this.formProperty.errorsChanges.pipe(l.takeUntil(this.sfItemComp.unsubscribe$)).subscribe((function(){return e.cd.detectChanges()}))},t}(Se);Pe.decorators=[{type:n.Directive}];var Ie=function(e){function t(){var t=e.apply(this,G(arguments))||this;return t.arraySpan=8,t}return $(t,e),Object.defineProperty(t.prototype,"addDisabled",{get:function(){return this.disabled||null!=this.schema.maxItems&&this.formProperty.properties.length>=this.schema.maxItems},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"showRemove",{get:function(){return!this.disabled&&!!this.removeTitle},enumerable:!1,configurable:!0}),t.prototype.ngOnInit=function(){var e=this.ui,t=e.grid,n=e.addTitle,i=e.addType,r=e.removable,o=e.removeTitle;t&&t.arraySpan&&(this.arraySpan=t.arraySpan),this.addTitle=this.dom.bypassSecurityTrustHtml(n||this.l.addText),this.addType=i||"dashed",this.removeTitle=!1===r?null:o||this.l.removeText},t.prototype.addItem=function(){var e=this.formProperty.add({});this.ui.add&&this.ui.add(e)},t.prototype.removeItem=function(e){this.formProperty.remove(e),this.ui.remove&&this.ui.remove(e)},t}(Te);Ie.decorators=[{type:n.Component,args:[{selector:"sf-array",template:'<nz-form-item [class.ant-form-item-with-help]="showError">\n <nz-col *ngIf="schema.title" [nzSpan]="ui.spanLabel" class="ant-form-item-label">\n <label>\n {{ schema.title }}\n <span class="sf__optional">\n {{ ui.optional }}\n <i\n *ngIf="oh"\n nz-tooltip\n [nzTooltipTitle]="oh.text"\n [nzTooltipPlacement]="oh.placement"\n [nzTooltipTrigger]="oh.trigger"\n [nzTooltipOverlayClassName]="oh.overlayClassName"\n [nzTooltipOverlayStyle]="oh.overlayStyle"\n [nzTooltipMouseEnterDelay]="oh.mouseEnterDelay"\n [nzTooltipMouseLeaveDelay]="oh.mouseLeaveDelay"\n nz-icon\n [nzType]="oh.icon"\n ></i>\n </span>\n </label>\n <div class="sf__array-add">\n <button type="button" nz-button [nzType]="addType" [disabled]="addDisabled" (click)="addItem()" [innerHTML]="addTitle"></button>\n </div>\n </nz-col>\n <nz-col class="ant-form-item-control-wrapper" [nzSpan]="ui.spanControl" [nzOffset]="ui.offsetControl">\n <div class="ant-form-item-control" [class.has-error]="showError">\n <div nz-row class="sf__array-container">\n <ng-container *ngFor="let i of formProperty.properties; let idx=index">\n <div nz-col *ngIf="i.visible && !i.ui.hidden" [nzSpan]="arraySpan" [attr.data-index]="idx" class="sf__array-item">\n <nz-card>\n <sf-item [formProperty]="i"></sf-item>\n <span *ngIf="showRemove" class="sf__array-remove" (click)="removeItem(idx)" [attr.title]="removeTitle">\n <i nz-icon nzType="delete"></i>\n </span>\n </nz-card>\n </div>\n </ng-container>\n </div>\n <div *ngIf="!ui.onlyVisual && showError" class="ant-form-explain">{{error}}</div>\n <div *ngIf="schema.description" [innerHTML]="schema._description" class="ant-form-extra"></div>\n </div>\n </nz-col>\n</nz-form-item>\n',host:{"[class.sf__array]":"true"},preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None}]}];var Me=function(e){function t(){var t=e.apply(this,G(arguments))||this;return t.i={},t.typing="",t.isAsync=!1,t.fixData=[],t}return $(t,e),t.prototype.updateValue=function(e){this.typing=e.nzLabel;var t=e.nzValue;this.setValue(t.value),this.ui.change&&this.ui.change(e,t)},t.prototype._setValue=function(e){var t=e.toString();"string"!=typeof e&&(t=e.value),this.setValue(t)},t.prototype.afterViewInit=function(){var e=this,t=this.ui,n=t.backfill,i=t.defaultActiveFirstOption,r=t.nzWidth,o=t.filterOption,a=t.asyncData;this.i={backfill:Y(n,!1),defaultActiveFirstOption:Y(i,!0),width:r||void 0};var s=null==o||o;"boolean"==typeof s&&(s=function(e,t){return t.label.toLowerCase().indexOf((e||"").toLowerCase())>-1}),this.filterOption=s,this.isAsync=!!a;var u=+(this.ui.debounceTime||0),p=Math.max(0,this.isAsync?Math.max(50,u):u);this.list=this.ngModel.valueChanges.pipe(l.debounceTime(p),l.startWith(""),l.mergeMap((function(t){return e.isAsync?a(t):e.filterData(t)})),l.map((function(t){return ne(t,null,e.schema.readOnly)})))},t.prototype.reset=function(e){if(this.typing=this.value,!this.isAsync)switch(this.ui.type){case"email":this.fixData=ie(this.schema.enum||this.formProperty.options.uiEmailSuffixes,null,this.schema.readOnly);break;default:this.fixData=ie(this.schema.enum,e,this.schema.readOnly)}},t.prototype.filterData=function(e){var t=this;switch(this.ui.type){case"email":return this.addEmailSuffix(e);default:return s.of(this.fixData.filter((function(n){return t.filterOption(e,n)})))}},t.prototype.addEmail