/**************************************************************************
 *                                                                        *
 *  Copyright 2014 Adobe Systems Incorporated                             *
 *  All Rights Reserved.                                                  *
 *                                                                        *
 * NOTICE:  All information contained herein is, and remains the property *
 * of Adobe Systems Incorporated and its suppliers, if any.               *
 * The intellectual and technical concepts contained herein are           *
 * proprietary to Adobe Systems Incorporated and its suppliers and may be *
 * covered by U.S. and Foreign Patents, patents in process, and are       *
 * protected by trade secret or copyright law.                            *
 * Dissemination of this information or reproduction of this material     *
 * strictly forbidden unless prior written permission is obtained from    *
 * Adobe Systems Incorporated.                                            *
 *                                                                        *
 **************************************************************************/

/* ShareOnBehance 3.0.0.17 */
function CSXSWindowType(){}function Version(e,t,n,r){this.major=e,this.minor=t,this.micro=n,this.special=r}function VersionBound(e,t){this.version=e,this.inclusive=t}function VersionRange(e,t){this.lowerBound=e,this.upperBound=t}function Runtime(e,t){this.name=e,this.versionRange=t}function Extension(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){this.id=e,this.name=t,this.mainPath=n,this.basePath=r,this.windowType=i,this.width=s,this.height=o,this.minWidth=u,this.minHeight=a,this.maxWidth=f,this.maxHeight=l,this.defaultExtensionDataXml=c,this.specialExtensionDataXml=h,this.requiredRuntimeList=p,this.isAutoVisible=d,this.isPluginExtension=v}function CSEvent(e,t,n,r){this.type=e,this.scope=t,this.appId=n,this.extensionId=r}function SystemPath(){}function ColorType(){}function RGBColor(e,t,n,r){this.red=e,this.green=t,this.blue=n,this.alpha=r}function Direction(e,t){this.x=e,this.y=t}function GradientStop(e,t){this.offset=e,this.rgbColor=t}function GradientColor(e,t,n,r){this.type=e,this.direction=t,this.numStops=n,this.arrGradientStop=r}function UIColor(e,t,n){this.type=e,this.antialiasLevel=t,this.color=n}function AppSkinInfo(e,t,n,r,i,s,o){this.baseFontFamily=e,this.baseFontSize=t,this.appBarBackgroundColor=n,this.panelBackgroundColor=r,this.appBarBackgroundColorSRGB=i,this.panelBackgroundColorSRGB=s,this.systemHighlightColor=o}function HostEnvironment(e,t,n,r,i,s,o){this.appName=e,this.appVersion=t,this.appLocale=n,this.appUILocale=r,this.appId=i,this.isAppOnline=s,this.appSkinInfo=o}function HostCapabilities(e,t,n,r,i){this.EXTENDED_PANEL_MENU=e,this.EXTENDED_PANEL_ICONS=t,this.DELEGATE_APE_ENGINE=n,this.SUPPORT_HTML_EXTENSIONS=r,this.DISABLE_FLASH_EXTENSIONS=i}function ApiVersion(e,t,n){this.major=e,this.minor=t,this.micro=n}function MenuItemStatus(e,t,n){this.menuItemLabel=e,this.enabled=t,this.checked=n}function ContextMenuItemStatus(e,t,n){this.menuItemID=e,this.enabled=t,this.checked=n}function CSInterface(){}function AAMStatus(e,t,n){this.status=e,this.callerId=t,this.payload=n}function IMSInterface(){}function Vulcan(){}function VulcanMessage(e){this.type=e,this.scope=VulcanMessage.SCOPE_SUITE,this.appId=VulcanMessage.DEFAULT_APP_ID,this.appVersion=VulcanMessage.DEFAULT_APP_VERSION,this.data=VulcanMessage.DEFAULT_DATA}function GetValueByKey(e,t){if(window.DOMParser){var n=new window.DOMParser;try{var r=n.parseFromString(e,"text/xml"),i=r.getElementsByTagName(t)[0];if(i&&i.childNodes[0])return i.childNodes[0].nodeValue}catch(s){}}return""}function requiredParamsValid(){for(var e=0;e<arguments.length;e++){var t=arguments[e];if(t==undefined||t==null)return!1}return!0}function strStartsWith(e,t){return typeof e!="string"?!1:e.indexOf(t)===0}function AgoraLib(){var e=window.__adobe_cep__.getExtensionId(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,n=e=="x"?t:t&3|8;return n.toString(16)}),n=this,r;this.callerID=t+"_"+e,this.bundleID=window.__adobe_cep__.invokeSync("getBundleId",""),this.responseCallback=function(e){if(window.DOMParser){var t=new window.DOMParser;try{var r=t.parseFromString(e.data,"text/xml"),i=r.getElementsByTagName("payload")[0];i&&i.childNodes[0]&&(i=i.childNodes[0].nodeValue),i!==null&&(i=cep.encoding.convertion.b64_to_utf8(i)),console.log("Decoded payload: "+i);var s=t.parseFromString(i,"text/xml"),o=s.getElementsByTagName("Response");for(var u=0;u<o.length;u++){var a=o[u];if(a){var f=a.attributes.getNamedItem("name").nodeValue,l=a.attributes.getNamedItem("callerID").nodeValue;console.log("This caller ID "+n.callerID+" received caller ID "+l),console.log("API: "+f);if(l===n.callerID){console.log("CallerIDs match! Now removing message listener"),VulcanInterface.removeMessageListener(AgoraLib.RESPONSE_TYPE,n.responseCallback);var c=a.getElementsByTagName("Result"),h={};for(var p=0;p<c.length;p++){var d=c[p].attributes.getNamedItem("name").nodeValue,v=c[p].getElementsByTagName("Value")[0].textContent;console.log("param name: "+d+" param value: "+v),h[d]=v}if(f===AgoraLib.IS_ENTITLED){console.log("IsEntitled callback");var m=new AgoraLibResponse(h[AgoraLib.IS_ENTITLED],h[AgoraLib.STATUS],h[AgoraLib.STATUSCODE]);n.isEntitledCallback(m)}else if(f===AgoraLib.GET_PURCHASE_URL){console.log("GetPurchaseUrl callback");var g=h.URL,y=new AgoraLibResponse(g,h[AgoraLib.STATUS],h[AgoraLib.STATUSCODE]);n.getPurchaseUrlCallback(y)}else if(f===AgoraLib.GET_VERSION){console.log("GetVersion callback");var b=new AgoraLibResponse(h.Version,h[AgoraLib.STATUS],h[AgoraLib.STATUSCODE]);n.exchangeVersion=h.Version,n.getVersionCallback(b)}else if(f===AgoraLib.CREATE_ENTITLEMENT){console.log("CreateEntitlement callback");var w=new AgoraLibResponse("",h[AgoraLib.STATUS],h[AgoraLib.STATUSCODE]);n.createEntitlementCallback(w)}}}}}catch(E){console.log("AgoraLibError: "+E)}}},this.checkVersion=function(){console.log("Checking version...");var e='<Request name="'+AgoraLib.GET_VERSION+'" callerID="'+n.callerID+'"><Parameters>';e+="</Parameters></Request>";var t=String.format(AgoraLib.MESSAGE_REQUEST_TEMPLATE,e),r=new VulcanMessage(AgoraLib.MESSAGE_TYPE);r.setPayload(t),VulcanInterface.addMessageListener(AgoraLib.RESPONSE_TYPE,n.responseCallback),VulcanInterface.dispatchMessage(r);return},this.continueWithCheckVersion=function(){if(!n.exchangeVersion)n.checkVersion();else{var e=new AgoraLibResponse(this.exchangeVersion,AgoraLib.status.success.status,AgoraLib.status.success.code);n.getVersionCallback(e)}},this.checkConnection=function(e,t){n.getVersionCallback=e;var r="",i=AgoraLib.status.internalClientError.status,s=AgoraLib.status.internalClientError.code,o=VulcanInterface.isAppInstalled("coresync");if(!o)console.log("CoreSync does not exist"),i=AgoraLib.status.creativeCloudNotFoundError.status,s=AgoraLib.status.creativeCloudNotFoundError.code;else{var u=VulcanInterface.isAppRunning("coresync");console.log("CoreSync running? : "+u+", should it be launched if not running? "+(t?"no":"yes"));if(!u&&!t){u=VulcanInterface.launchApp("creativecloud",!1,"");if(u){console.log("ACCC is now being launched");var a=function(e){console.log("ACCC started up"),VulcanInterface.removeMessageListener(AgoraLib.ACCC_STARTED_UP_MESSAGE,this),n.continueWithCheckVersion()};VulcanInterface.addMessageListener(AgoraLib.ACCC_STARTED_UP_MESSAGE,a);return}i=AgoraLib.status.creativeCloudFailedToLaunchError.status,s=AgoraLib.status.creativeCloudFailedToLaunchError.code}else{if(!!u||!t){n.continueWithCheckVersion();return}i=AgoraLib.status.creativeCloudNotLaunchedError.status,s=AgoraLib.status.creativeCloudNotLaunchedError.code}}var f=new AgoraLibResponse(r,i,s);e(f)},this.compareVersion=function(e,t){var n,r,i,s=/(\.0)+[^\.]*$/;e=(e+"").replace(s,"").split("."),t=(t+"").replace(s,"").split("."),i=Math.min(e.length,t.length);for(n=0;n<i;n++){r=parseInt(e[n],10)-parseInt(t[n],10);if(r!==0)return r}return e.length-t.length}}function AgoraLibResponse(e,t,n){this.response=e,this.status=t,this.statusCode=n}function Vulcan(){}function VulcanMessage(e){this.type=e,this.scope=VulcanMessage.SCOPE_SUITE,this.appId=VulcanMessage.DEFAULT_APP_ID,this.appVersion=VulcanMessage.DEFAULT_APP_VERSION,this.data=VulcanMessage.DEFAULT_DATA}function GetValueByKey(e,t){if(window.DOMParser){var n=new window.DOMParser;try{var r=n.parseFromString(e,"text/xml"),i=r.getElementsByTagName(t)[0];if(i&&i.childNodes[0])return i.childNodes[0].nodeValue}catch(s){}}return""}function requiredParamsValid(){for(var e=0;e<arguments.length;e++){var t=arguments[e];if(t===undefined||t===null)return!1}return!0}function strStartsWith(e,t){return typeof e!="string"?!1:e.indexOf(t)===0}define("lib/CEPGlobals",[],function(){return window.cep}),define("window",[],function(){return window}),CSXSWindowType._PANEL="Panel",CSXSWindowType._MODELESS="Modeless",CSXSWindowType._MODAL_DIALOG="ModalDialog",EvalScript_ErrMessage="EvalScript error.",Version.MAX_NUM=999999999,CSEvent.prototype.data="",SystemPath.USER_DATA="userData",SystemPath.COMMON_FILES="commonFiles",SystemPath.MY_DOCUMENTS="myDocuments",SystemPath.APPLICATION="application",SystemPath.EXTENSION="extension",SystemPath.HOST_APPLICATION="hostApplication",ColorType.RGB="rgb",ColorType.GRADIENT="gradient",ColorType.NONE="none",CSInterface.THEME_COLOR_CHANGED_EVENT="com.adobe.csxs.events.ThemeColorChanged",CSInterface.prototype.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment()),CSInterface.prototype.getHostEnvironment=function(){return this.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment()),this.hostEnvironment},CSInterface.prototype.closeExtension=function(){window.__adobe_cep__.closeExtension()},CSInterface.prototype.getSystemPath=function(e){var t=decodeURI(window.__adobe_cep__.getSystemPath(e)),n=this.getOSInformation();return n.indexOf("Windows")>=0?t=t.replace("file:///",""):n.indexOf("Mac")>=0&&(t=t.replace("file://","")),t},CSInterface.prototype.evalScript=function(e,t){if(t===null||t===undefined)t=function(e){};window.__adobe_cep__.evalScript(e,t)},CSInterface.prototype.getApplicationID=function(){var e=this.hostEnvironment.appId;return e},CSInterface.prototype.getHostCapabilities=function(){var e=JSON.parse(window.__adobe_cep__.getHostCapabilities());return e},CSInterface.prototype.dispatchEvent=function(e){typeof e.data=="object"&&(e.data=JSON.stringify(e.data)),window.__adobe_cep__.dispatchEvent(e)},CSInterface.prototype.addEventListener=function(e,t,n){window.__adobe_cep__.addEventListener(e,t,n)},CSInterface.prototype.removeEventListener=function(e,t,n){window.__adobe_cep__.removeEventListener(e,t,n)},CSInterface.prototype.requestOpenExtension=function(e,t){window.__adobe_cep__.requestOpenExtension(e,t)},CSInterface.prototype.getExtensions=function(e){var t=JSON.stringify(e),n=window.__adobe_cep__.getExtensions(t),r=JSON.parse(n);return r},CSInterface.prototype.getNetworkPreferences=function(){var e=window.__adobe_cep__.getNetworkPreferences(),t=JSON.parse(e);return t},CSInterface.prototype.initResourceBundle=function(){var e=JSON.parse(window.__adobe_cep__.initResourceBundle()),t=document.querySelectorAll("[data-locale]");for(var n=0;n<t.length;n++){var r=t[n],i=r.getAttribute("data-locale");if(i)for(var s in e)if(s.indexOf(i)===0){var o=e[s];if(s.length==i.length)r.innerHTML=o;else if("."==s.charAt(i.length)){var u=s.substring(i.length+1);r[u]=o}}}return e},CSInterface.prototype.dumpInstallationInfo=function(){return window.__adobe_cep__.dumpInstallationInfo()},CSInterface.prototype.getOSInformation=function(){var e=navigator.userAgent;if(navigator.platform=="Win32"||navigator.platform=="Windows"){var t="Windows",n="";return e.indexOf("Windows")>-1&&(e.indexOf("Windows NT 5.0")>-1?t="Windows 2000":e.indexOf("Windows NT 5.1")>-1?t="Windows XP":e.indexOf("Windows NT 5.2")>-1?t="Windows Server 2003":e.indexOf("Windows NT 6.0")>-1?t="Windows Vista":e.indexOf("Windows NT 6.1")>-1?t="Windows 7":e.indexOf("Windows NT 6.2")>-1&&(t="Windows 8"),e.indexOf("WOW64")>-1?n=" 64-bit":n=" 32-bit"),t+n}if(navigator.platform=="MacIntel"||navigator.platform=="Macintosh"){var r="Mac OS X";return e.indexOf("Mac OS X")>-1&&(r=e.substring(e.indexOf("Mac OS X"),e.indexOf(")")),r=r.replace(/_/g,".")),r}return"Unknown Operation System"},CSInterface.prototype.openURLInDefaultBrowser=function(e){return cep.util.openURLInDefaultBrowser(e)},CSInterface.prototype.getExtensionID=function(){return window.__adobe_cep__.getExtensionId()},CSInterface.prototype.getScaleFactor=function(){return window.__adobe_cep__.getScaleFactor()},CSInterface.prototype.setScaleFactorChangedHandler=function(e){window.__adobe_cep__.setScaleFactorChangedHandler(e)},CSInterface.prototype.getCurrentApiVersion=function(){var e=JSON.parse(window.__adobe_cep__.getCurrentApiVersion());return e},CSInterface.prototype.setPanelFlyoutMenu=function(e){if("string"!=typeof e)return;window.__adobe_cep__.invokeSync("setPanelFlyoutMenu",e)},CSInterface.prototype.updatePanelMenuItem=function(e,t,n){var r=!1;if(this.getHostCapabilities().EXTENDED_PANEL_MENU){var i=new MenuItemStatus(e,t,n);r=window.__adobe_cep__.invokeSync("updatePanelMenuItem",JSON.stringify(i))}return r},CSInterface.prototype.setContextMenu=function(e,t){if("string"!=typeof e)return;window.__adobe_cep__.invokeAsync("setContextMenu",e,t)},CSInterface.prototype.setContextMenuByJSON=function(e,t){if("string"!=typeof e)return;window.__adobe_cep__.invokeAsync("setContextMenuByJSON",e,t)},CSInterface.prototype.updateContextMenuItem=function(e,t,n){var r=new ContextMenuItemStatus(e,t,n);ret=window.__adobe_cep__.invokeSync("updateContextMenuItem",JSON.stringify(r))},CSInterface.prototype.isWindowVisible=function(){return window.__adobe_cep__.invokeSync("isWindowVisible","")},CSInterface.prototype.resizeContent=function(e,t){window.__adobe_cep__.resizeContent(e,t)},define("lib/CSInterface-latest",function(){}),define("lib/CSInterface",["lib/CSInterface-latest"],function(e){var t=new CSInterface,n=t.getHostEnvironment(),r="en",i=["cs","da","de","es","fi","fr","hu","it","ja","ko","nl","pl","pt","ru","sv","tr","uk"],s=n.appUILocale.split("_");return s.length==2&&(s[0]=="nb"?r="no":s[1]=="MX"?r="es-MX":s[0]=="zh"&&s[1]=="CN"?r="zh-Hans":s[0]=="zh"&&s[1]=="TW"?r="zh-Hant":s[1]=="CA"?r="fr-CA":s[1]=="MA"?r="fr-MA":i.indexOf(s[0])>-1&&(r=s[0])),document.getElementsByTagName("html")[0].setAttribute("lang",r),t.resourceBundle=t.initResourceBundle(),t.SystemPath=SystemPath,t.EvalScript_ErrMessage=EvalScript_ErrMessage,t}),define("config",["window","lib/CSInterface","lib/CEPGlobals"],function(e,t,n){var r="c2hhcmUtb24tYmVoYW5jZQ==",i="NmExODlhOGItY2JjOC00ODgyLWFhZGUtMDBkNzUxODYyYTFk",s="aHR0cHM6Ly9vb2JlLmFkb2JlLmNvbS8=",o="QmVoYW5jZVdlYlN1c2kx",u="https://www.behance.net",a="https://www.behance.net/portfolio/wips/load/iframe?isa0=1",f="https://www.behance.net/faq",l="https://www.behance.net/xd.php",c=["adobe.com","behance.net","prosite.com","be.net"],h="ShareOnBehance",p=!0,d=4e4,v="3.0.0",m=6e4,g=function(){console.log("Initializing config settings");var g=e.navigator.platform.toLowerCase().indexOf("win")>-1,y=g?"\\":"/",b=t.getSystemPath(SystemPath.USER_DATA);b+=y+"Adobe"+y+"ShareOnBehance"+y+"config_override.json";try{console.log("Attempting to read settings file: "+b);var w=n.fs.readFile(b);if(!w||!w.data||w.data.length===0||w.err!==0)console.log("Unable to read config_override.json, assuming extension should be directed at production");else{var E=JSON.parse(w.data);E.imsClientId&&E.imsClientId.length>0&&(r=E.imsClientId,console.log("imsClientId setting updated")),E.imsClientSecret&&E.imsClientSecret.length>0&&(i=E.imsClientSecret,console.log("imsClientSecret setting updated")),E.imsRedirectUri&&E.imsRedirectUri.length>0&&(s=E.imsRedirectUri,console.log("imsRedirectUri setting updated")),E.imsJumpClientId&&E.imsJumpClientId.length>0&&(o=E.imsJumpClientId,console.log("imsJumpClientId setting updated")),E.behanceDomain&&E.behanceDomain.length>0&&(u=E.behanceDomain,console.log("behanceDomain setting updated")),E.behanceIFrameUrl&&E.behanceIFrameUrl.length>0&&(a=E.behanceIFrameUrl,console.log("behanceIFrameUrl setting updated")),E.behanceHelpUrl&&E.behanceHelpUrl.length>0&&(f=E.behanceHelpUrl,console.log("behanceHelpUrl setting updated")),E.behancePingUrl&&E.behancePingUrl.length>0&&(l=E.behancePingUrl,console.log("behancePingUrl setting updated")),E.whiteListedDomains&&E.whiteListedDomains.length>0&&(c=E.whiteListedDomains,console.log("whiteListedDomains setting updated")),E.aameeServiceName&&E.aameeServiceName.length>0&&(h=E.aameeServiceName,console.log("aameeServiceName setting updated")),E.logging&&E.logging.length>0&&(p=E.logging,console.log("logging setting updated")),E.timeout&&E.timeout.length>0&&(d=E.timeout,console.log("timeout setting updated")),E.version&&E.version.length>0&&(v=E.version,console.log("version setting updated")),E.fetchAccessTokenTimeout&&E.fetchAccessTokenTimeout.length>0&&(m=E.fetchAccessTokenTimeout,console.log("fetchAccessTokenTimeout setting updated"))}}catch(S){console.log("Error reading file: "+S)}console.log("Completed initializing of config settings")};return g(),{aameeServiceName:h,behanceDomain:u,behanceIFrameUrl:a,behanceHelpUrl:f,behancePingUrl:l,imsCi:e.atob(r),imsCs:e.atob(i),imsRu:e.atob(s),imsJci:e.atob(o),logging:p,timeout:d,version:v,whiteListedDomains:c,fetchAccessTokenTimeout:m}}),define("log",["config"],function(e){var t=(new Date).getTime();return{error:function(n){e.logging&&console.log("ERROR ("+((new Date).getTime()-t)+"): "+n)},info:function(n){e.logging&&console.log("INFO ("+((new Date).getTime()-t)+"): "+n)},stringify:function(t){if(!e.logging)return"";try{return JSON.stringify(t)}catch(n){return t+""}}}}),define("localize",["lib/CSInterface","log"],function(e,t){return function(t){if(e.resourceBundle[t]){var n=e.resourceBundle[t],r=1;while(n.indexOf("$"+r)!==-1)n=n.replace("$"+r,arguments[r]),r++;return n}return""}}),define("utils",["lib/CEPGlobals","lib/CSInterface","config","localize","log","window"],function(e,t,n,r,i,s){var o="Photoshop";t.hostEnvironment.appName==="ILST"?o="Illustrator":t.hostEnvironment.appName==="IDSN"&&(o="InDesign"),i.info("Application name is: "+o);var u=s.navigator.platform.toLowerCase().indexOf("win")>-1;i.info("Platform is: "+(u?"Windows":"Mac"));var a=t.getSystemPath(t.SystemPath.EXTENSION);i.info("Extension directory is: "+a);var f="/";u&&(f=t.getSystemPath(t.SystemPath.COMMON_FILES).substring(0,3)),i.info("Root directory is: "+f);var l="com.adobe.behance.shareonbehance.html.extension",c="/tmp/"+l;u&&(c=t.getSystemPath(t.SystemPath.USER_DATA)+"/../Local/Temp/"+l),e.fs.makedir(c),e.fs.chmod(c,511);var h=!1,p=function(e){h=!1,i.info("Pinging "+n.behancePingUrl+" to check internet connection");var t=new s.XMLHttpRequest;t.open("GET",n.behancePingUrl,!0),t.onerror=function(){i.error("Failed to connect to internet"),h=!0},t.send()},d=function(e){i.info("Getting network preferences");var n=t.getNetworkPreferences();i.info("Found network preferences: "+i.stringify(n));if(n&&n.isAppOnline===!1){e.recoverableError(r("Recoverable_error_network_permissions"),r("Recoverable_error_network_permissions_fix_permissions"));return}p(e)},v=function(e){var t=s.document.createElement("a");t.href=e;var n=t.hostname.split(".");return n=n.slice(n.length-2,n.length),{protocol:t.protocol,domain:n.join(".")}},m=function(e){if(!e){i.error("URL is null");return}var r=v(e);if(r.protocol!=="http:"&&r.protocol!=="https:"){i.error("Invalid protocol: "+r.protocol);return}var s=!1;for(var o=0;o<n.whiteListedDomains.length;o++){var u=n.whiteListedDomains[o];if(u===r.domain){s=!0;break}}if(!s){i.error("Invalid domain: "+r.domain);return}t.openURLInDefaultBrowser(e)},g=function(){return h};return{applicationName:o,checkInternetConnection:d,extensionDir:a,isWindows:u,openInDefaultBrowser:m,rootDir:f,tempDir:c,failedToConnectToInternet:g}}),define("aamee",["lib/CEPGlobals","config","log","utils","window"],function(e,t,n,r,i){return{isExtensionEnabled:function(){n.info("Checking to see if AAMEE has the extension enabled or disabled");var s="/Library/Application Support/Adobe/CDI/override.xml";r.isWindows&&(s=r.rootDir+"ProgramData/Adobe/CDI/override.xml");var o=e.fs.readFile(s);if(!o||!o.data||o.data.length===0||o.err!==0)return n.info("Unable to read override.xml, assuming extension should be enabled"),!0;var u=null;try{var a=new i.DOMParser;u=a.parseFromString(o.data,"text/xml")}catch(f){return n.error("Error parsing override file, assuming extension is enabled"),!0}var l=u.documentElement.getAttribute("suppress");if(l==="true")return n.info("Global suppression is turned on, disable"),!1;var c=u.getElementsByTagName("Service");for(var h=0;h<c.length;h++){var p=c[h];if(p.getAttribute("name")===t.aameeServiceName&&p.getAttribute("suppress")==="true")return n.info("Found service specific suppression, disable"),!1}return n.info("Unable to find an entry that suppresses this extension, assuming enabled"),!0}}}),IMSInterface.prototype.addEventListener=function(e,t){window.__adobe_cep__.addEventListener(e,t)},IMSInterface.prototype.removeEventListener=function(e,t){window.__adobe_cep__.removeEventListener(e,t)},IMSInterface.prototype.imsConnect=function(){var e=window.__adobe_cep__.imsConnect();return e},IMSInterface.prototype.imsDisconnect=function(e){window.__adobe_cep__.imsDisconnect(e)},IMSInterface.prototype.imsFetchAccounts=function(e,t){var n=window.__adobe_cep__.imsFetchAccounts(e,t);return n},IMSInterface.prototype.imsFetchAccessToken=function(e,t,n,r,i,s){return window.__adobe_cep__.imsFetchAccessToken(e,t,n,r,i,s)},IMSInterface.prototype.imsRevokeDeviceToken=function(e,t,n,r,i){return window.__adobe_cep__.imsFetchAccessToken(e,t,n,r,i,"REVOKE")},IMSInterface.prototype.imsSetProxyCredentials=function(e,t){window.__adobe_cep__.imsSetProxyCredentials(e,t)},IMSInterface.prototype.showAAM=function(e,t,n,r,i,s){return window.__adobe_cep__.showAAM(e,t,n,r,i,s)},IMSInterface.prototype.imsGetCurrentUserId=function(){var e=window.__adobe_cep__.getCurrentImsUserId();return e},IMSInterface.prototype.imsGetCurrentUserIdHelper=function(e){var t=JSON.parse(window.__adobe_cep__.getHostEnvironment()),n=t.appName;if(n==="ILST")window.__adobe_cep__.evalScript("app.userGUID",function(t){e(t)});else if(n==="IDSN")window.__adobe_cep__.evalScript("app.userGuid",function(t){e(t)});else if(n==="PHSP"||n==="PHXS")window.__adobe_cep__.evalScript("var getUserIdPhotoshop = function() {var userId = '';try {var bhnc = app.charIDToTypeID('bhnc');var ref = new ActionReference();ref.putProperty(app.charIDToTypeID('Prpr'), bhnc);ref.putEnumerated(app.charIDToTypeID('capp'), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));var appDesc = app.executeActionGet(ref);if (appDesc.hasKey(bhnc)) {userId = appDesc.getString(bhnc);}} catch (e) {}return userId;};",function(t){window.__adobe_cep__.evalScript("getUserIdPhotoshop()",function(t){e(t)})});else{var r=window.__adobe_cep__.getCurrentImsUserId();e(r)}},IMSInterface.prototype.imsConnectWithEndpoint=function(e){var t={};return t.imsEndpoint=e===undefined||e===null||e===""?"undefined":e,JSON.parse(window.__adobe_cep__.invokeSync("imsConnectWithEndpoint",JSON.stringify(t))).result},IMSInterface.prototype.imsFetchContinueToken=function(e,t,n,r,i,s,o){if(r===undefined||r===null)r="";if(i===undefined||i===null)i="";if(s===undefined||s===null)s="";if(o===undefined||o===null)o="";var u={};return u.imsRef=e,u.bearerToken=t,u.targetClientId=n,u.redirectUri=r,u.scope=i,u.responseType=s,u.locale=o,JSON.parse(window.__adobe_cep__.invokeSync("imsFetchContinueToken",JSON.stringify(u))).result},IMSInterface.prototype.imsLogoutUser=function(e,t,n){var r={};return r.imsRef=e,r.userAccountGuid=t,r.clientId=n,JSON.parse(window.__adobe_cep__.invokeSync("imsLogoutUser",JSON.stringify(r))).result},IMSInterface.prototype.imsFetchUserProfileData=function(e,t){var n={};return n.imsRef=e,n.userAccountGuid=t,window.__adobe_cep__.invokeSync("imsFetchUserProfileData",JSON.stringify(n))},IMSInterface.events={imsFetchAccessTokenWithStatus:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsFetchAccessToken:"com.adobe.csxs.events.internal.ims.FetchAccessToken",imsRevokeAccessToken:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsFetchContinueToken:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsAAMIMSStatus:"vulcan.SuiteMessage.com.adobe.aam.AAMIMSStatus",imsLogoutUser:"com.adobe.csxs.events.internal.ims.LogoutUser"},IMSInterface.prototype.events=IMSInterface.events,define("lib/IMSInterface-latest",function(){}),define("lib/IMSInterface",["lib/IMSInterface-latest"],function(e){return new IMSInterface}),define("host",["lib/CSInterface","localize","log"],function(e,t,n){var r=t("Error_generic_scripting");return{evalScript:function(i,s){n.info("Evaling script: "+i),e.evalScript(i,function(i){n.info("Received result from eval script: "+i);if(!i||i.length===0||i===e.EvalScript_ErrMessage){s.error(r);return}var o=JSON.parse(i);switch(o.status){case"success":s.success(o.value);break;case"error":s.error(t(o.message));break;case"recoverableError":s.recoverableError(t(o.message),t(o.subMessage));break;case"cancel":e.closeExtension();break;default:s.error(r)}})}}}),define("ui",["lib/CSInterface","config","localize","log","utils","window"],function(e,t,n,r,i,s){var o=!1,u=!1,a=!1,f=!1,l=s.document.getElementsByTagName("body")[0],c=s.document.getElementsByClassName("close-button")[0],h=s.document.getElementsByClassName("proxy-close-button")[0],p=s.document.getElementsByClassName("error")[0],d=s.document.getElementsByClassName("error-message")[0],v=s.document.getElementsByClassName("error-sub-message")[0],m=s.document.getElementsByClassName("help")[0],g=s.document.getElementsByClassName("behance-iframe")[0],y=s.document.getElementsByClassName("loading")[0],b=s.document.getElementsByClassName("loading-message")[0],w=s.document.getElementsByClassName("proxy")[0],E=s.document.getElementsByClassName("proxy-message")[0],S=s.document.getElementsByClassName("proxy-sub-message")[0],x=s.document.getElementsByClassName("proxy-username-label")[0],T=s.document.getElementsByClassName("proxy-password-label")[0],N=function(){return g.contentWindow},C=function(){r.info("generating jump url");var n=e.hostEnvironment,i=t.behanceIFrameUrl;return i+="&extVersion="+t.version,i+="&appId="+n.appName,i+="&appVersion="+n.appVersion,i+="&appLocale="+n.appUILocale,r.info("Initial iframe url before jump "+i),i},k=function(e){r.info("Initializing iframe and pointing iframe to "+e),g.src=e,o=!0},L=function(){r.info("About to display proxy credentials prompt"),a?r.info("Already displaying proxy"):(a=!0,O(),w.style.display="block",r.info("Successfully displayed proxy"))},A=function(){r.info("Starting timeout countdown"),setTimeout(function(){r.info("Checking to see if iframe has been shown: "+f),f||D(n("Error_connection_timeout"))},t.timeout)},O=function(){p.style.display="none",g.style.display="none",y.style.display="none",w.style.display="none"},M=function(){r.info("Attempting to display iframe"),u?r.info("Already displaying error"):(f=!0,O(),g.style.display="block",r.info("Successfully displayed iframe"))},_=function(e,t,i){i=typeof i=="undefined"?"true":i,r.info("ShowFooter: "+i),u?r.info("Already displaying error"):(r.error("Attempting to display recoverable error: "+e),u=!0,O(),d.innerHTML=e,t&&(v.innerHTML=t),i!=="false"?(m.innerHTML=n("UI_recoverable_error_footer"),j()):m.innerHTML="",p.style.display="block",r.info("Successfully displayed recoverable error"))},D=function(e){r.info("About to display error"),r.info("Is an error already being shown? "+u),setTimeout(function(){r.error("Attempting to display error: "+e),u?r.info("Already displaying error"):(u=!0,O(),m.innerHTML=n("UI_error_footer",e),j(),p.style.display="block",r.info("Successfully displayed error"))},100)},P=function(t){t.keyCode===27?(r.info("Caught esc key, attempting to close extension"),e.closeExtension()):t.keyCode===13&&u&&(r.info("Caught enter key while displaying error, attempting to close extension"),e.closeExtension())},H=function(){r.info("Help link clicked, opening browser to help url"),i.openInDefaultBrowser(t.behanceHelpUrl)},B=function(){r.info("Close button clicked, closing extension"),e.closeExtension()},j=function(){var e=s.document.getElementsByClassName("help-link")[0];typeof e!="undefined"&&e.addEventListener("click",H)},F=function(){d.innerHTML=n("UI_error_title_message"),v.innerHTML=n("UI_error_subtitle_message");var t=e.hostEnvironment;t.appUILocale.indexOf("en_")!=0?b.innerHTML="<img class='spinner' src='css/loading.gif'> "+n("UI_loading")+"<br>"+n("UI_entering_english_only_site"):b.innerHTML="<img class='spinner' src='css/loading.gif'> "+n("UI_loading"),c.innerHTML=n("UI_close"),h.innerHTML=n("UI_close"),E.innerHTML=n("UI_proxy_title_message"),S.innerHTML=n("UI_proxy_sub_message"),x.innerHTML=n("UI_proxy_username"),T.innerHTML=n("UI_proxy_password");var r=n("Error_unknown");m.innerHTML=n("UI_error_footer",r)},I=function(){r.info("Initializing UI"),F(),s.document.addEventListener("keydown",P),j(),c.addEventListener("click",B),h.addEventListener("click",B),r.info("Done initializing UI")};return I(),{getIFrameWindow:N,hasInitializedIFrame:function(){return o},hasShownIFrame:function(){return f},initIFrame:k,showIFrame:M,showRecoverableError:_,showError:D,showProxy:L,hideAll:O,startTimeoutCountdown:A,getIFrameUrl:C}}),define("response",["log","ui"],function(e,t){return{create:function(n){return n||(n={}),n.success||(n.success=function(){e.info("Generic success callback triggered")}),n.recoverableError||(n.recoverableError=function(e,n,r){t.showRecoverableError(e,n,r)}),n.error||(n.error=function(e){t.showError(e)}),n}}}),define("ims",["lib/IMSInterface","config","host","localize","log","response","utils","ui"],function(e,t,n,r,i,s,o,u){var a="com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",f="com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",l="openid,AdobeID,creative_cloud,sao.behance",c="openid,AdobeID,sao.behance,gnav",h=t.imsCi,p=t.imsCs,d=t.imsRu,v=t.imsJci,m=!1,g=!1,y,b,w,E="",S=!1,x=window.document.getElementsByClassName("proxy-login-button")[0],T=function(e){var t=!1;return e&&e.data&&e.data!=""&&(t=!0),t},N=function(e){var t=!1;if(T(e)&&e.data.status){var n=e.data.status;["20","21","22","23"].indexOf(n)>=0&&(t=!0,i.info("HTTPError: "+n))}return t},C=function(e){var t=!1;if(T(e)&&e.data.status){var n=e.data.status;["24","25"].indexOf(n)>=0&&(t=!0,i.info("ProxyError: "+n))}return t},k=function(e){var t=!1;if(T(e)&&e.data.status){var n=e.data.status;["80","120","122","123","124","125","126","127"].indexOf(n)>=0&&(t=!0)}return t},L=function(e){var t="sso_inbound=1";return e.indexOf("?")==-1?e+="?"+t:e+="&"+t,e},A=function(){i.info("cleanUp");try{e.imsDisconnect(b),i.info("Successfully cleaned up IMS")}catch(t){i.error("Error cleaning up IMS: "+i.stringify(t))}},O=function(t){i.info("Handling fetch continue token callback: "+i.stringify(t)),e.removeEventListener(f,O),m=!0,T(t)&&t.data.details.jump?y.success(t.data.details.jump):y.error(r("Error_fetching_continue_token")),A()},M=function(t,n){i.info("createFetchContinueTokenCall attempting SSO workflows"),e.addEventListener(f,n),e.imsFetchContinueToken(b,w,v,encodeURIComponent(t),c,"","")},_=function(t){i.info("Handling fetch access token callback: "+i.stringify(t)),e.removeEventListener(a,_),S=!1,T(t)&&t.data.details.access_token?(w=t.data.details.access_token,M(u.getIFrameUrl(),O)):C(t)?(u.showProxy(),S=!0):!T(t)&&o.failedToConnectToInternet()||N(t)?(y.recoverableError(r("Recoverable_error_connecting_to_Behance"),r("Recoverable_error_connecting_to_Behance_check_internet")),S=!0):(k(t)?E.toLowerCase().indexOf("adobeid")==-1?y.recoverableError(r("Error_ims_access_denied"),r("Error_ims_access_denied_enterprise"),"false"):y.error(r("Error_ims_access_denied")):y.error(r("Error_fetching_access_token")),S=!0),S&&A()},D=function(n){i.info("Connecting to IMS"),b=e.imsConnect(h),i.info("Connected to IMS, with ims reference: "+b),e.addEventListener(a,_),i.info("Fetch access token"),y=n,e.imsFetchAccessToken(b,h,p,E,"",l),setTimeout(function(){!m&&!S&&(i.info("Timeout error"),n.error(r("Error_fetching_access_token")),A())},t.fetchAccessTokenTimeout)},P=function(t,n){i.info("Setting Proxy Credentials"),b=e.imsConnect(h),e.imsSetProxyCredentials(t,n),A()},H=function(n){if(!g){g=!0;if(n.indexOf(t.behanceDomain)==-1||!m&&w===null&&w.length===0)o.openInDefaultBrowser(n),g=!1;else{b=e.imsConnect(h);var r=function(t){i.info("Handling fetch continue token: "+i.stringify(t)),e.removeEventListener(f,r),T(t)&&t.data.details.jump?o.openInDefaultBrowser(t.data.details.jump):o.openInDefaultBrowser(n),A(),g=!1};new_url=L(n),i.info("attempting SSO workflows for url "+new_url),M(new_url,r)}}},B=function(){i.info("Login button clicked, retrieving credentials and passing to IMS");var e=window.document.getElementById("proxy-username").value,t=window.document.getElementById("proxy-password").value;P(e,t),u.hideAll(),document.title=r("UI_share_on_Behance"),window.document.getElementsByClassName("loading")[0].style.display="block",D(y),cleanup()},j=function(){x.innerHTML=r("UI_login"),x.addEventListener("click",B)},F=function(t){E===""?e.imsGetCurrentUserIdHelper(function(e){i.info("Received userId: "+e),typeof e=="undefined"||e===null||e.length===0?t.recoverableError(r("Recoverable_error_not_signed_in"),r("Recoverable_error_not_signed_in_therefore_sign_in",o.applicationName)):(E=e,t.success(e))}):t.success(E)};return j(),{getAccessToken:D,setProxyCredentials:P,getSSOUrl:H,getSignedInUser:F}}),define("message",["lib/CSInterface","config","log","ui","utils","window","ims"],function(e,t,n,r,i,s,o){var u=!1,a=[],f=function(e){n.info("Attempting to send message of type: "+e.type);if(u){n.info("Behance iframe is ready, sending message");var i=r.getIFrameWindow();i.postMessage(JSON.stringify(e),t.behanceDomain)}else n.info("Behance iframe is not ready, queueing message"),a.push(e)},l=function(){n.info("Flushing queued messages");for(var e=0;e<a.length;e++)f(a[e]);a=[]};return s.onmessage=function(i){if(t.behanceDomain!==i.origin){n.info("Unable to respond to message from domain: "+i.origin);return}if(i.source!==r.getIFrameWindow()){n.info("Unable to respond to message from different iframe window");return}var s=JSON.parse(i.data);if(s){n.info("Received message: "+n.stringify(s)+", from origin: "+i.origin);switch(s.type){case"close":e.closeExtension();break;case"openBrowser":o.getSSOUrl(s.url);break;case"ready":r.showIFrame();break;case"readyAcceptImage":u=!0,l()}}},{sendWip:function(e){f({type:"wip",image:e})}}}),define("wip",["lib/CEPGlobals","host","localize","log","response","utils"],function(e,t,n,r,i,s){var o={},u=function(e){var t=e.split(".");return t.length>1&&t[t.length-1].length>0&&t.pop(),t.join(".")},a=function(t){var n=null;try{r.info("Reading file: "+t),n=e.fs.readFile(t,e.encoding.Base64).data.replace(/\s/g,""),r.info("Successfully read file")}catch(i){r.error("Error reading file")}return n},f=function(t){try{r.info("Deleting file: "+t);var n=e.fs.deleteFile(t);!n||n.err!==0?r.error("Error deleting file"):r.info("Successfully deleted file")}catch(i){r.error("Error deleting file: "+r.stringify(i))}};return o.isLoaded=function(){return o.value&&o.value.length>0},o.load=function(e){r.info("Loading wip module");var l=s.tempDir+"/wip.jpg";r.info("Saving temporary image to "+l),t.evalScript("saveActiveDocument('"+l+"')",i.create({success:function(t){r.info("Received callback from evalScript: "+t);if(t===null){e.error(n("Error_saving_document"));return}r.info("Successfully saved active document"),o.mime="image/jpeg",o.encoding="base64",o.title=u(t),o.value=a(l),f(l),o.value&&o.value.length>0?(r.info("Successfully read WIP, sending to iframe"),e.success()):e.error(n("Error_reading_document"))}}))},o}),Vulcan.prototype.getTargetSpecifiers=function(){var e={};return JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetTargetSpecifiers",JSON.stringify(e)))},Vulcan.prototype.launchApp=function(e,t,n){if(!requiredParamsValid(e))return!1;var r={};return r.targetSpecifier=e,r.focus=t?"true":"false",r.cmdLine=n==undefined||n==null?"":n,JSON.parse(window.__adobe_cep__.invokeSync("vulcanLaunchApp",JSON.stringify(r))).result},Vulcan.prototype.isAppRunning=function(e){if(!requiredParamsValid(e))return!1;var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppRunning",JSON.stringify(t))).result},Vulcan.prototype.isAppInstalled=function(e){if(!requiredParamsValid(e))return!1;var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppInstalled",JSON.stringify(t))).result},Vulcan.prototype.getAppPath=function(e){if(!requiredParamsValid(e))return"";var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetAppPath",JSON.stringify(t))).result},Vulcan.prototype.addMessageListener=function(e,t,n){if(!requiredParamsValid(e,t)||!strStartsWith(e,VulcanMessage.TYPE_PREFIX))return;var r={};r.type=e,window.__adobe_cep__.invokeAsync("vulcanAddMessageListener",JSON.stringify(r),t,n)},Vulcan.prototype.removeMessageListener=function(e,t,n){if(!requiredParamsValid(e,t)||!strStartsWith(e,VulcanMessage.TYPE_PREFIX))return;var r={};r.type=e,window.__adobe_cep__.invokeAsync("vulcanRemoveMessageListener",JSON.stringify(r),t,n)},Vulcan.prototype.dispatchMessage=function(e){if(!requiredParamsValid(e)||!strStartsWith(e.type,VulcanMessage.TYPE_PREFIX))return;var t={},n=new VulcanMessage(e.type);n.initialize(e),t.vulcanMessage=n,window.__adobe_cep__.invokeSync("vulcanDispatchMessage",JSON.stringify(t))},Vulcan.prototype.getPayload=function(e){if(!requiredParamsValid(e)||!strStartsWith(e.type,VulcanMessage.TYPE_PREFIX))return null;var t=new VulcanMessage(e.type);return t.initialize(e),t.getPayload()};var VulcanInterface=new Vulcan;VulcanMessage.TYPE_PREFIX="vulcan.SuiteMessage.",VulcanMessage.SCOPE_SUITE="GLOBAL",VulcanMessage.DEFAULT_APP_ID="UNKNOWN",VulcanMessage.DEFAULT_APP_VERSION="UNKNOWN",VulcanMessage.DEFAULT_DATA="<data><payload></payload></data>",VulcanMessage.dataTemplate="<data>{0}</data>",VulcanMessage.payloadTemplate="<payload>{0}</payload>",VulcanMessage.prototype.initialize=function(e){this.type=e.type,this.scope=e.scope,this.appId=e.appId,this.appVersion=e.appVersion,this.data=e.data},VulcanMessage.prototype.xmlData=function(){if(this.data==undefined){var e="";e=String.format(VulcanMessage.payloadTemplate,e),this.data=String.format(VulcanMessage.dataTemplate,e)}return this.data},VulcanMessage.prototype.setPayload=function(e){var t=cep.encoding.convertion.utf8_to_b64(e);t=String.format(VulcanMessage.payloadTemplate,t),this.data=String.format(VulcanMessage.dataTemplate,t)},VulcanMessage.prototype.getPayload=function(){var e=GetValueByKey(this.data,"payload");return e!=null?cep.encoding.convertion.b64_to_utf8(e):null},VulcanMessage.prototype.toString=function(){var e="type="+this.type;return e+=", scope="+this.scope,e+=", appId="+this.appId,e+=", appVersion="+this.appVersion,e+=", data="+this.xmlData(),e},String.format=function(e){if(arguments.length==0)return null;var t=Array.prototype.slice.call(arguments,1);return e.replace(/\{(\d+)\}/g,function(e,n){return t[n]})},define("lib/Vulcan",function(){}),AgoraLib.prototype=function(){var e=function(e,t){if(typeof Vulcan=="undefined")throw"Vulcan.js is required.";if(e===null||e===undefined)e=function(e){};if(t===null||t===undefined)t=!1;this.isEntitledCallback=e;var n=this,r=!1;this.checkConnection(function(t){console.log("isEntitled checkConnection response: "+t.response+" with status: "+t.status+" and statusCode: "+t.statusCode),r=!0;if(t.statusCode==="0"&&n.compareVersion(t.response,"1.0.0")>=0){console.log("isEntitled: connection check successful, now continue with isEntitled API call...");var i='<Request name="'+AgoraLib.IS_ENTITLED+'" callerID="'+n.callerID+'"><Parameters>';i+='<Parameter name="BundleID"><Value>'+n.bundleID+"</Value></Parameter>",i+="</Parameters></Request>";var s=String.format(AgoraLib.MESSAGE_REQUEST_TEMPLATE,i),o=new VulcanMessage(AgoraLib.MESSAGE_TYPE);o.setPayload(s),VulcanInterface.addMessageListener(AgoraLib.RESPONSE_TYPE,n.responseCallback),VulcanInterface.dispatchMessage(o)}else{var u=new AgoraLibResponse("Unknown",t.status,t.statusCode);e(u)}},t),setTimeout(function(){if(!r){console.log("isEntitled: Request timed out");var t=new AgoraLibResponse("Unknown",AgoraLib.status.internalClientError.status,AgoraLib.status.internalClientError.code);e(t)}},AgoraLib.TIMEOUT)},t=function(e,t,n){if(typeof Vulcan=="undefined")throw"Vulcan.js is required.";if(e===null||e===undefined)e=function(e){};if(n===null||n===undefined)n=!1;this.getPurchaseUrlCallback=e,t=!requiredParamsValid(t)||t===""?!1:t;var r=this,i=!1;this.checkConnection(function(n){i=!0,console.log("getPurchaseUrl: checkConnection response: "+n.response+" with status: "+n.status+" and statusCode: "+n.statusCode);if(n.statusCode==="0"&&r.compareVersion(n.response,"1.0.0")>=0){console.log("Connection check successful, now continue with getPurchaseUrl API call...");var s='<Request name="'+AgoraLib.GET_PURCHASE_URL+'" callerID="'+r.callerID+'"><Parameters>';s+='<Parameter name="BundleID"><Value>'+r.bundleID+"</Value></Parameter>",s+='<Parameter name="StraightToCheckout"><Value>'+t+"</Value></Parameter>",s+="</Parameters></Request>";var o=String.format(AgoraLib.MESSAGE_REQUEST_TEMPLATE,s),u=new VulcanMessage(AgoraLib.MESSAGE_TYPE);u.setPayload(o),VulcanInterface.addMessageListener(AgoraLib.RESPONSE_TYPE,r.responseCallback),VulcanInterface.dispatchMessage(u)}else{var a=new AgoraLibResponse("",n.status,n.statusCode);e(a)}},n),setTimeout(function(){if(!i){console.log("getPurchaseUrl: Request timed out");var t=new AgoraLibResponse("",AgoraLib.status.internalClientError.status,AgoraLib.status.internalClientError.code);e(t)}},AgoraLib.TIMEOUT)},n=function(e,t){if(typeof Vulcan=="undefined")throw"Vulcan.js is required.";if(typeof CSInterface=="undefined")throw"CSInterface.js is required.";if(e===null||e===undefined)e=function(e){};if(t===null||t===undefined)t=!1;this.createEntitlementCallback=e;var n=this,r=!1;this.checkConnection(function(t){console.log("createEntitlement: checkConnection response: "+t.response+" with status: "+t.status+" and statusCode: "+t.statusCode),r=!0;if(t.statusCode==="0"&&n.compareVersion(t.response,"1.0.0")>=0){console.log("createEntitlement: Connection check successful, now continue with createEntitlement API call...");var i=new CSInterface,s=i.getSystemPath(SystemPath.EXTENSION),o=i.getOSInformation(),u=o.indexOf("Win")>=0?"\\":"/",a=s+u+"CSXS"+u+"manifest.xml",f=window.cep.fs.readFile(a),l=!0;if(window.DOMParser){var c=new window.DOMParser;try{var h=c.parseFromString(f.data,"text/xml"),p=h.getElementsByTagName("ExtensionManifest")[0];if(p){var d=p.attributes.getNamedItem("ExtensionBundleVersion").nodeValue,v='<Request name="'+AgoraLib.CREATE_ENTITLEMENT+'" callerID="'+n.callerID+'"><Parameters>';v+='<Parameter name="BundleID"><Value>'+n.bundleID+"</Value></Parameter>",v+='<Parameter name="ExtensionBundleVersion"><Value>'+d+"</Value></Parameter>",v+="</Parameters></Request>";var m=String.format(AgoraLib.MESSAGE_REQUEST_TEMPLATE,v),g=new VulcanMessage(AgoraLib.MESSAGE_TYPE);g.setPayload(m),VulcanInterface.addMessageListener(AgoraLib.RESPONSE_TYPE,n.responseCallback),VulcanInterface.dispatchMessage(g),l=!1}}catch(y){console.log("AgoraLibError: "+y)}}if(l){var b=new AgoraLibResponse("",AgoraLib.status.internalClientError.status,AgoraLib.status.internalClientError.code);e(b)}}else{var w=new AgoraLibResponse("",t.status,t.statusCode);e(w)}},t),setTimeout(function(){if(!r){console.log("createEntitlement: Request timed out");var t=new AgoraLibResponse("",AgoraLib.status.internalClientError.status,AgoraLib.status.internalClientError.code);e(t)}},AgoraLib.TIMEOUT)};return{constructor:AgoraLib,isEntitled:e,getPurchaseUrl:t,createEntitlement:n}}(),AgoraLib.status={success:{status:"Success",code:"0"},updateAvailable:{status:"Success. Update available",code:"1"},entitlementAlreadyCreated:{status:"Success. Entitlement already created",code:"2"},perpetualPurchase:{status:"Perpetual purchase",code:"1"},trialPurchase:{status:"Trial purchase",code:"2"},subscriptionPurchase:{status:"Subscription purchase",code:"3"},free:{status:"Free",code:"4"},userNotEntitledError:{status:"User not entitled or product not found",code:"-1"},subscriptionExpiredError:{status:"Subscription expired",code:"-2"},networkDisabledError:{status:"Network disabled",code:"1001"},networkError:{status:"Network error",code:"1002"},productNotFoundError:{status:"Product not found",code:"1003"},UserLoggedOutError:{status:"User logged out",code:"1004"},internalClientError:{status:"Internal client error",code:"1005"},internalServerError:{status:"Internal server error",code:"1006"},creativeCloudFailedToLaunchError:{status:"Adobe Creative Cloud Desktop failed to launch",code:"1007"},creativeCloudNotFoundError:{status:"Adobe Creative Cloud Desktop is not installed",code:"1008"},ApiNotSupportedError:{status:"API not supported",code:"1009"},creativeCloudNotLaunchedError:{status:"Creative Cloud was not launched",code:"1010"}},AgoraLib.IS_ENTITLED="IsEntitled",AgoraLib.GET_PURCHASE_URL="GetPurchaseUrl",AgoraLib.CREATE_ENTITLEMENT="CreateEntitlement",AgoraLib.GET_VERSION="GetVersion",AgoraLib.STATUS="Status",AgoraLib.STATUSCODE="StatusCode",AgoraLib.MESSAGE_TYPE="vulcan.SuiteMessage.cosy.exchangeplugin.ApiRequest",AgoraLib.RESPONSE_TYPE="vulcan.SuiteMessage.cosy.exchangeplugin.ApiResponse",AgoraLib.ACCC_STARTED_UP_MESSAGE="vulcan.SuiteMessage.any.cosy.app.StartedUp",AgoraLib.MESSAGE_REQUEST_TEMPLATE="<Message><Requests>{0}</Requests></Message>",AgoraLib.MESSAGE_RESPONSE_TEMPLATE="<Message><Responses>{0}</Responses></Message>",AgoraLib.TIMEOUT=6e4,define("lib/AgoraLib-latest",function(){}),Vulcan.prototype.getTargetSpecifiers=function(){var e={};return JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetTargetSpecifiers",JSON.stringify(e)))},Vulcan.prototype.launchApp=function(e,t,n){if(!requiredParamsValid(e))return!1;var r={};return r.targetSpecifier=e,r.focus=t?"true":"false",r.cmdLine=n===undefined||n===null?"":n,JSON.parse(window.__adobe_cep__.invokeSync("vulcanLaunchApp",JSON.stringify(r))).result},Vulcan.prototype.isAppRunning=function(e){if(!requiredParamsValid(e))return!1;var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppRunning",JSON.stringify(t))).result},Vulcan.prototype.isAppInstalled=function(e){if(!requiredParamsValid(e))return!1;var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppInstalled",JSON.stringify(t))).result},Vulcan.prototype.getAppPath=function(e){if(!requiredParamsValid(e))return"";var t={};return t.targetSpecifier=e,JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetAppPath",JSON.stringify(t))).result},Vulcan.prototype.addMessageListener=function(e,t,n){if(!requiredParamsValid(e,t)||!strStartsWith(e,VulcanMessage.TYPE_PREFIX))return;var r={};r.type=e,window.__adobe_cep__.invokeAsync("vulcanAddMessageListener",JSON.stringify(r),t,n)},Vulcan.prototype.removeMessageListener=function(e,t,n){if(!requiredParamsValid(e,t)||!strStartsWith(e,VulcanMessage.TYPE_PREFIX))return;var r={};r.type=e,window.__adobe_cep__.invokeAsync("vulcanRemoveMessageListener",JSON.stringify(r),t,n)},Vulcan.prototype.dispatchMessage=function(e){if(!requiredParamsValid(e)||!strStartsWith(e.type,VulcanMessage.TYPE_PREFIX))return;var t={},n=new VulcanMessage(e.type);n.initialize(e),t.vulcanMessage=n,window.__adobe_cep__.invokeSync("vulcanDispatchMessage",JSON.stringify(t))},Vulcan.prototype.getPayload=function(e){if(!requiredParamsValid(e)||!strStartsWith(e.type,VulcanMessage.TYPE_PREFIX))return null;var t=new VulcanMessage(e.type);return t.initialize(e),t.getPayload()};var VulcanInterface=new Vulcan;VulcanMessage.TYPE_PREFIX="vulcan.SuiteMessage.",VulcanMessage.SCOPE_SUITE="GLOBAL",VulcanMessage.DEFAULT_APP_ID="UNKNOWN",VulcanMessage.DEFAULT_APP_VERSION="UNKNOWN",VulcanMessage.DEFAULT_DATA="<data><payload></payload></data>",VulcanMessage.dataTemplate="<data>{0}</data>",VulcanMessage.payloadTemplate="<payload>{0}</payload>",VulcanMessage.prototype.initialize=function(e){this.type=e.type,this.scope=e.scope,this.appId=e.appId,this.appVersion=e.appVersion,this.data=e.data},VulcanMessage.prototype.xmlData=function(){if(this.data===undefined){var e="";e=String.format(VulcanMessage.payloadTemplate,e),this.data=String.format(VulcanMessage.dataTemplate,e)}return this.data},VulcanMessage.prototype.setPayload=function(e){var t=cep.encoding.convertion.utf8_to_b64(e);t=String.format(VulcanMessage.payloadTemplate,t),this.data=String.format(VulcanMessage.dataTemplate,t)},VulcanMessage.prototype.getPayload=function(){var e=GetValueByKey(this.data,"payload");return e!==null?cep.encoding.convertion.b64_to_utf8(e):null},VulcanMessage.prototype.toString=function(){var e="type="+this.type;return e+=", scope="+this.scope,e+=", appId="+this.appId,e+=", appVersion="+this.appVersion,e+=", data="+this.xmlData(),e},String.format=function(e){if(arguments.length===0)return null;var t=Array.prototype.slice.call(arguments,1);return e.replace(/\{(\d+)\}/g,function(e,n){return t[n]})},define("lib/Vulcan-latest",function(){}),define("lib/AgoraLib",["lib/AgoraLib-latest","lib/Vulcan-latest"],function(e,t){return new AgoraLib}),define("exchange",["lib/Vulcan","lib/AgoraLib","log","ims","utils","response"],function(e,t,n,r,i,s){var o=[AgoraLib.status.perpetualPurchase.code,AgoraLib.status.trialPurchase.code,AgoraLib.status.subscriptionPurchase.code,AgoraLib.status.free.code],u,a,f=function(e){n.info("createEntitlementCallback received with result "+e.statusCode+", "+e.status+", "+e.response),e.statusCode===AgoraLib.status.updateAvailable.code?n.info("User has a pending update from Exchange."):e.statusCode===AgoraLib.status.success.code||e.statusCode===AgoraLib.status.entitlementAlreadyCreated.code?n.info("User has an entitlement"):n.error("Failed to create an entitlement"),u.success()},l=function(e){console.log("isEntitledCallback received with result "+e.statusCode+", "+e.status+", "+e.response),o.indexOf(e.statusCode)>=0?(console.log("User has an entitlement"),p(e.statusCode,7),u.success()):(console.log("User has not got an entitlement so create one for this user"),t.createEntitlement(f))},c=function(e,r){u=r;var i=h(e+"_entitlement");if(i!==""&&i!==AgoraLib.status.updateAvailable.code){n.info("Use cached result for entitlement"),u.success();return}a=e,n.info("Checking user's entitlement on Exchange"),t.isEntitled(l)},h=function(e){var t="",n=e+"=",r=document.cookie.split(";");for(var i=0;i<r.length;i++){var s=r[i];while(s.charAt(0)==" ")s=s.substring(1);if(s.indexOf(n)==0){t=s.substring(n.length,s.length);break}}return t},p=function(e,t){var n=new Date,r=new Date(n);r.setDate(r.getDate()+t),document.cookie=a+"_entitlement"+"="+e+";expires="+r.toUTCString()};return{checkEntitlement:c}}),require(["aamee","ims","localize","log","message","response","ui","utils","wip","exchange"],function(e,t,n,r,i,s,o,u,a,f){var l=function(){a.load(s.create({success:function(){i.sendWip(a),o.hasInitializedIFrame()&&o.startTimeoutCountdown()}}))},c=function(){r.info("Starting Behance extension"),document.title=n("UI_share_on_Behance");if(!e.isExtensionEnabled()){o.showError(n("Error_extension_disabled"));return}u.checkInternetConnection(s.create()),t.getSignedInUser(s.create({success:function(e){t.getAccessToken(s.create({success:function(t){r.info("Successful retrieval of iframe url"),l(),f.checkEntitlement(e,s.create({success:function(){r.info("Exchange workflows completed."),o.initIFrame(t),a.isLoaded()&&o.startTimeoutCountdown()}}))}}))}}))};c()}),define("main",function(){});