/*! For license information please see license-admin-token.f988d10ebfaedc79df82.js.LICENSE.txt */
(()=>{"use strict";var e,t={"./_js/base/endpoints.js":(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SIGN_IN_ENDPOINT=t.GRAPHQL_PAYMENTS_API_URL=t.GRAPHQL_API_URL=t.BASE_API_URL=void 0;const a="https://graphql-dev.sketch.cloud/api/graphql",s="https://payments.dev.sketch.com/payments/graphql",n="https://api.staging.sketch.com/1/",i={dev:n,development:n,staging:n,production:"https://api.prod.sketch.com/1/"},o={dev:a,development:a,staging:"https://graphql-staging.sketch.cloud/api/graphql",production:"https://graphql.sketch.cloud/api/graphql"},r={dev:s,development:s,staging:"https://payments.staging.sketch.com/payments/graphql",production:"https://payments.prod.sketch.com/payments/graphql"},l=t.GRAPHQL_API_URL=o.production;t.GRAPHQL_PAYMENTS_API_URL=r.production,t.BASE_API_URL=i.production,t.SIGN_IN_ENDPOINT=l.replace("/api/graphql","/oauth/token")}},a={};function s(e){var n=a[e];if(void 0!==n)return n.exports;var i=a[e]={exports:{}};return t[e](i,i.exports,s),i.exports}e=s("./_js/base/endpoints.js"),$(document).ready((function(){$("#license-manager-token-form").validate({errorClass:"invalid",errorElement:"div",rules:{"license-email":{required:!0,email:!0}},messages:{"license-email":{required:"",email:""}},onfocusout:function(e){this.element(e)},submitHandler:function(){$("#submit").addClass("is-waiting"),$("#license-email").attr("disabled","disabled");var t={email:$("#license-email").val()};$.ajax({type:"POST",url:`${e.BASE_API_URL}licensemanager/token/`,data:t,dataType:"json",encode:!0}).done((function(e){if(0==e.data.matches){$("#license-manager-token-form").hide();var a=$(".main-content h1.title").html(),s=$(".main-content p.description").html();$(".main-content-wrapper h1.title").text("License not found"),$(".main-content-wrapper p.description").text("We couldn’t find a license associated with that email address. Please make sure you have entered your details correctly."),$(".main-content-wrapper").append('<p class="description main-content__description styled-text">Depending on which version of Sketch you’re using, you can check the email address attached to your license by opening the app and clicking on <code>Sketch > Preferences</code> and then clicking on ”Account” or via <code>Sketch > About & Registration</code> in the menu bar.</p>'),$(".main-content-wrapper").append('<p class="actions-wrapper"><button class="button full revert">Try Again</button>'),$(".revert").on("click",(function(){$(".main-content-wrapper h1.title").html(a),$(".main-content-wrapper p.description ~ p").remove(),$(".main-content-wrapper p.description").html(s),$(".main-content-wrapper #license-email").val(""),$("#submit").removeClass("is-waiting"),$("#license-email").removeAttr("disabled"),$("#license-manager-token-form").show(),$(".two-column-layout").removeClass("error")})),$(".two-column-layout").addClass("error")}else 1==e.data.matches&&($("#submit").removeClass("is-waiting").addClass("is-successful"),$(".button__label").css("visibility","hidden"),console.log($(".two-column-layout")),$(".two-column-layout").addClass("success"),$(".submit").children("small").remove(),$(".submit").append('<small class="styled-text">We’ve sent an email to <strong>'+t.email+"</strong> with your access code.</small>"));0==e.status&&($("#submit").removeClass("is-waiting").addClass("error"),$(".submit").children("small").remove(),$(".submit").append("<small>Your email address is not valid. Please try again.</small>"),setTimeout((function(){$("#submit").removeClass("is-waiting error"),$("#license-email").removeAttr("disabled"),$(".submit").children("small").remove()}),3e3))})).fail((function(e,t,a){$("#submit").removeClass("is-waiting").addClass("error"),setTimeout((function(){$("#submit").removeClass("is-waiting error"),$("#license-email").removeAttr("disabled")}),3e3),$(".submit").children("small").remove(),$(".submit").append("<small>An error occurred. Please try again.</small>"),console.log("textStatus: ",t,"errorThrown: ",a)}))}})}))})();
//# sourceMappingURL=license-admin-token.f988d10ebfaedc79df82.js.map