/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../core/accessorSupport/decorators/property","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/subclass","../intl/substitute","../widgets/Widget","../widgets/support/widgetUtils","../widgets/support/decorators/messageBundle","../widgets/support/jsxFactory"],(function(e,t,s,r,o,i,n,u,a,l,p,d){"use strict";const c={base:"esri-identity-form",group:"esri-identity-form__group",label:"esri-identity-form__label",footer:"esri-identity-form__footer",esriInput:"esri-input",esriButton:"esri-button",esriButtonSecondary:"esri-button--secondary"},_="ArcGIS Online";let h=function(t){function s(e,s){var r;return(r=t.call(this,e,s)||this)._usernameInputNode=null,r._passwordInputNode=null,r.messages=null,r.signingIn=!1,r.server=null,r.resource=null,r.error=null,r.oAuthPrompt=!1,r}e._inheritsLoose(s,t);var r=s.prototype;return r.render=function(){const{error:e,server:t,resource:s,signingIn:r,oAuthPrompt:o,messages:i}=this,n=d.tsx("div",{class:c.group},u.substitute(o?i.oAuthInfo:i.info,{server:/\.arcgis\.com/i.test(t)?_:t,resource:`(${s||i.lblItem})`})),a=o?null:d.tsx("div",{class:c.group,key:"username"},d.tsx("label",{class:c.label},i.lblUser,d.tsx("input",{value:"",required:!0,autocomplete:"off",spellcheck:!1,type:"text",bind:this,afterCreate:l.storeNode,"data-node-ref":"_usernameInputNode",class:c.esriInput}))),p=o?null:d.tsx("div",{class:c.group,key:"password"},d.tsx("label",{class:c.label},i.lblPwd,d.tsx("input",{value:"",required:!0,type:"password",bind:this,afterCreate:l.storeNode,"data-node-ref":"_passwordInputNode",class:c.esriInput}))),h=d.tsx("div",{class:this.classes(c.group,c.footer)},d.tsx("input",{type:"submit",disabled:!!r,value:r?i.lblSigning:i.lblOk,class:c.esriButton}),d.tsx("input",{type:"button",value:i.lblCancel,bind:this,onclick:this._cancel,class:this.classes(c.esriButton,c.esriButtonSecondary)})),y=e?d.tsx("div",null,e.details&&e.details.httpStatus?i.invalidUser:i.noAuthService):null;return d.tsx("form",{class:c.base,bind:this,onsubmit:this._submit},n,y,a,p,h)},r._cancel=function(){this._set("signingIn",!1),this._usernameInputNode&&(this._usernameInputNode.value=""),this._passwordInputNode&&(this._passwordInputNode.value=""),this.emit("cancel")},r._submit=function(e){e.preventDefault(),this._set("signingIn",!0);const t=this.oAuthPrompt?{}:{username:this._usernameInputNode&&this._usernameInputNode.value,password:this._passwordInputNode&&this._passwordInputNode.value};this.emit("submit",t)},s}(a);t.__decorate([s.property(),p.messageBundle("esri/identity/t9n/identity")],h.prototype,"messages",void 0),t.__decorate([s.property()],h.prototype,"signingIn",void 0),t.__decorate([s.property()],h.prototype,"server",void 0),t.__decorate([s.property()],h.prototype,"resource",void 0),t.__decorate([s.property()],h.prototype,"error",void 0),t.__decorate([s.property()],h.prototype,"oAuthPrompt",void 0),h=t.__decorate([n.subclass("esri.identity.IdentityForm")],h);return h}));
