!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","../../Validation","../../forms/utils","../../TemplateUtils"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=e("tslib"),c=e("../../Validation"),v=e("../../forms/utils"),b=i.__importStar(e("../../TemplateUtils")),e=(r.prototype._getAttributeValue=function(t,e,i){if(void 0!==(r=e[t]))return r;if(i&&0!==i.length){var r,i=i.filter(function(e){return t===e.alias})[0];return r=i&&i.name?e[i.name]:r}},r.prototype._isLabelFieldName=function(e,t,i){t=(0<t.length?t[0].attributes:{})||{};return void 0!==this._getAttributeValue(e,t,i)},r.prototype._getTokenValues=function(e,t,i){for(var r={},a=0,o=e;a<o.length;a++){var n,l=o[a].token;r.hasOwnProperty(l)||(n=this._getAttributeValue(l,t,i),n=b.getTokenValueString(l,n),r[l]=v.text.escapeTextForMarkdown(n))}return r},r.prototype.execute=function(e){var t=e.features||[],i=e.fields||[],r=e.labelFieldName||void 0;c.validation.string("labelFieldName",r);for(var a=e.valueFieldName||void 0,o={},n=this._isLabelFieldName(r,t,i),l=n?[]:b.findTokenInstances(r),u=0;u<t.length;++u){var s=t[u],f=s.attributes||{},d={},m=void 0;m=n?this._getAttributeValue(r,f,i):(p=this._getTokenValues(l,f,i),b.replacePlaceholders(r,l,p));var p=this._getAttributeValue(a,f,i),f=void 0,f=v.text.isMarkdown(m)?m:String(m);d.label=f,d.value=p,d.value||(d.value={refValueType:"data",type:"feature",data:s}),o[d.index=u]=d}return{items:o}},r.action="gcx:wf:forms::GetFormElementItemsFromFeatures",r.suite="gcx:wf:builtin",r);function r(){}t.GetFormElementItemsFromFeatures=e});