YUI.add("hermes-template-fave",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){return"is-faved"},3:function(e,t,n,r,i){return"can-not-fave"},5:function(e,t,n,r,i){var s;return e.escapeExpression((n.formatNumber||t&&t.formatNumber||n.helperMissing).call(t!=null?t:{},(s=t!=null?t.photo:t)!=null?s.faveCount:s,{name:"formatNumber",hash:{},data:i}))},7:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},(s=t!=null?t.photo:t)!=null?s.faveCount:s,{name:"if",hash:{},fn:e.program(8,i,0),inverse:e.noop,data:i}))!=null?s:""},8:function(e,t,n,r,i){var s;return e.escapeExpression((n.friendlyNumber||t&&t.friendlyNumber||n.helperMissing).call(t!=null?t:{},(s=t!=null?t.photo:t)!=null?s.faveCount:s,{name:"friendlyNumber",hash:{},data:i}))},10:function(e,t,n,r,i){var s;return' <a href="#" title="'+((s=n["if"].call(t!=null?t:{},t!=null?t.loadingView:t,{name:"if",hash:{},fn:e.program(11,i,0),inverse:e.program(13,i,0),data:i}))!=null?s:"")+'" data-action="fave"></a>\n'},11:function(e,t,n,r,i){return e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"fave-view.LOADING_FAVES"},data:i}))},13:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},(s=t!=null?t.photo:t)!=null?s.isFaved:s,{name:"if",hash:{},fn:e.program(14,i,0),inverse:e.program(16,i,0),data:i}))!=null?s:""},14:function(e,t,n,r,i){return e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"fave-view.UNFAVE_PHOTO"},data:i}))},16:function(e,t,n,r,i){return e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"fave-view.FAVE_PHOTO"},data:i}))},18:function(e,t,n,r,i){return' <a href="#" title="'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"fave-view.WHO_FAVED"},data:i}))+'" data-action="showfaves"></a>\n'},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s,o=t!=null?t:{};return'<div class="button">\n <span class="fave-star '+((s=n["if"].call(o,(s=t!=null?t.photo:t)!=null?s.isFaved:s,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.noop,data:i}))!=null?s:"")+" "+((s=n.unless.call(o,(s=t!=null?t.photo:t)!=null?s.canFave:s,{name:"unless",hash:{},fn:e.program(3,i,0),inverse:e.noop,data:i}))!=null?s:"")+'">\n <svg class="icon icon-fave"><use xlink:href="#icon-fave"></use></svg>\n <svg class="icon icon-fave_hollow"><use xlink:href="#icon-fave_hollow"></use></svg>\n </span>\n <span class="fave-count" unselectable="on">'+((s=n["if"].call(o,t!=null?t.realFullscreen:t,{name:"if",hash:{},fn:e.program(5,i,0),inverse:e.program(7,i,0),data:i}))!=null?s:"")+'</span>\n\n <div class="button-overlay">\n'+((s=n["if"].call(o,(s=t!=null?t.photo:t)!=null?s.canFave:s,{name:"if",hash:{},fn:e.program(10,i,0),inverse:e.noop,data:i}))!=null?s:"")+((s=n["if"].call(o,(s=t!=null?t.photo:t)!=null?s.faveCount:s,{name:"if",hash:{},fn:e.program(18,i,0),inverse:e.noop,data:i}))!=null?s:"")+" </div>\n</div>\n"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/fave",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("fave-view",function(e,t){var n=require("lib/flog")(t);e.FlickrView.create(this.name,e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(e){return this.photoId=e.photoId,this.offNetworkFave=e.offNetworkFave||!1,this.hideWhoFaved=e.hideWhoFaved||!1,this.get("container").get("innerHTML")===""&&this.setContainerWithTemplate("fave",{photo:{canFave:!1},loadingView:!0}),this.appContext.flipper.isFlipped("enable-signed-out-cta-test")&&(this.signedOutTest=!0),this.realFullscreen=!!e.realFullscreen,this},buildContainer:function(){var e=this.get("photo-engagement");return this.setContainerWithTemplate("fave",{photo:e.toJSON(),realFullscreen:this.realFullscreen}),this},loadState:function(){var t=this,n=this.appContext.getViewer(),r=[];return r.push(this.appContext.getModel("photo-engagement-models",this.photoId).then(function(e){t.set("photo-engagement",e)})),n.signedIn&&r.push(this.appContext.getModelRegistry("favorite-models").then(function(e){t.set("favoriteModelRegistry",e)})),n.signedIn&&t.appContext.getModel("person-models",n.nsid).then(function(e){t.set("viewer-person-model",e)}),e.Promise.all(r)},activate:function(){var t=this.get("photo-engagement"),r=this,i,s=this.appContext.getViewer().prefs.keyboardShortcutsEnabled,o,u=this.appContext.getViewer().nsid,a=this.get("container").one(".fave-star");return t&&this.registerEventHandler(t.on("valuesChanged",function(i){var s,f=typeof i.faveCount!="undefined"||typeof i.isFaved!="undefined"||typeof i.canFave!="undefined";if(!f)return;a.addClass("is-transitioning"),setTimeout(function(){i&&i.isFaved&&i.isFaved.newVal?a.addClass("is-faved"):a.removeClass("is-faved")},225),setTimeout(function(){a.removeClass("is-transitioning")},300);var l=r.get("favoriteModelRegistry");l&&l.exists&&l.exists(u)&&(o=l.proxy(u).getValue("photoPageList"),i.isFaved&&i.isFaved.newVal?r.appContext.getModel("photo-models",i.isFaved.id).then(function(e){o.unshift(e)}):o.remove(i.isFaved.id)),s=t.remoteUpdate(),s.then(function(){r.processingFave=!1},function(n){n.code!==3&&(n.code!==5&&e.Object.each(i,function(e,n){t.setValue(n,e.prevVal)}),r.fire("subviewViewEvent","getDialogOffset",function(t){var n=e.Views.dialog.getInstance("dialog-alert",{content:r.intlMessage({intlName:"fave-view.COULDNT_FAVE"}),attrs:{title:r.intlMessage({intlName:"common.ERROR"}),level:"warning",confirmLabel:r.intlMessage({intlName:"common.OK"})},appContext:r.appContext,dialogClass:"scrappy-dialog",offsetLeft:t});n.show()})),r.processingFave=!1}).then(null,function(e){r.processingFave=!1,n.error({err:e})})},r.photoId)),i={":fave":r.faveStarClicked},this.attachEvents(i),s&&r.attachKeyEvent("down:70",r.faveStarClicked.bind(r)),this},showSignUpAndFaveModal:function(t){var n=this.intlMessage({intlName:"fave-view.SIGN_IN_BEFORE_FAVE_TITLE"}),r=this.intlMessage({intlName:"fave-view.JOIN_FLICKR_AND_FAVE"}),i;i=new e.Views.SignUpModal({appContext:this.appContext,signUpHeaderClass:"signup-fave",signUpTitle:n,signUpMessage:r,beaconPrefix:"fave"}),i.on("signUpClick",function(n){e.SigninHelper.signUpPendingFave({id:t})}),i.on("signInClick",function(n){e.SigninHelper.addPendingFave({id:t})}),i.show()},faveStarClicked:function(t,n){var r=this,i=this.get("photo-engagement"),s=this.intlMessage({intlName:"fave-view.SIGN_IN_BEFORE_FAVE_MESSAGE"}),o=this.intlMessage({intlName:"fave-view.SIGN_IN_AND_FAVE"}),u=this.intlMessage({intlName:"common.CANCEL"}),a;t.preventDefault();if(this.processingFave)return;e.rapidTracker.beacon(this.name,"faveButtonClick"),this.processingFave=!0,this.bringIntoFocus();if(!this.appContext.getViewer().signedIn){if(this.offNetworkFave){e.SigninHelper.addPendingFave({id:this.photoId},{withPopup:!0,closeWhenDone:!0}),this.processingFave=!1;return}if(this.signedOutTest)return this.processingFave=!1,this.showSignUpAndFaveModal(this.photoId);a=new e.Views.FluidModal({appContext:this.appContext,title:this.intlMessage({intlName:"fave-view.SIGN_IN_BEFORE_FAVE_TITLE"}),htmlMessage:s,actionButtonLabel:o,cancelButtonLabel:u}),a.on("actionClick",function(){e.rapidTracker.beacon(r.name,"faveModalSigninClick"),e.SigninHelper.addPendingFave({id:r.photoId})}),a.on("cancelClick",function(t){e.rapidTracker.beacon(r.name,"faveModalCancelClick")}),a.show(),this.processingFave=!1}else i.getValue("canFave")&&(i.registry.toggleFave(this.photoId),e.rapidTracker.beacon(this.name,"faveStarActionBarButtonClick"))}})},"@VERSION@",{requires:["flickr-view","hermes-template-fave","fave-css","fluid-modal-view","dialog","signin-helper","hermes-template-fave-menu","hermes-template-person","animation-manager"],optional:["photo-engagement-models","photo-people-who-faved-models","person-models","favorite-models"],langBundles:["fave-view","common"]});
YUI.add("hermes-template-dialog-cta-reboot",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){var s;return' <h1 class="ui-dialog-title">'+e.escapeExpression(e.lambda((s=t!=null?t.attrs:t)!=null?s.title:s,t))+"</h1>\n"},3:function(e,t,n,r,i){var s;return' <div class="ui-dialog-icon">\n <i class="ui-icon-big-'+e.escapeExpression(e.lambda((s=t!=null?t.attrs:t)!=null?s.icon:s,t))+'"></i>\n </div>\n'},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s,o=t!=null?t:{};return'<div class="ui-dialog-wrapper ui-dialog ui-dialog-cta ui-dialog-cta-reboot">\n'+((s=n["if"].call(o,(s=t!=null?t.attrs:t)!=null?s.title:s,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.noop,data:i}))!=null?s:"")+((s=n["if"].call(o,(s=t!=null?t.attrs:t)!=null?s.icon:s,{name:"if",hash:{},fn:e.program(3,i,0),inverse:e.noop,data:i}))!=null?s:"")+'\n <div class="ui-dialog-body">\n '+e.escapeExpression((n.dialogOutlet||t&&t.dialogOutlet||n.helperMissing).call(o,t!=null?t.content:t,{name:"dialogOutlet",hash:{},data:i}))+"\n </div>\n</div>\n"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/dialog-cta-reboot",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-feather-aviary-save-dialog",function(e,t){var n=e.Template.Handlebars.revive({compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s=t!=null?t:{},o=n.helperMissing,u=e.escapeExpression;return'<div class="save-aviary-changes">\n <button class="alt aviary-upload">'+u((n.intlMessage||t&&t.intlMessage||o).call(s,{name:"intlMessage",hash:{intlName:"aviary.SAVE"},data:i}))+'</button>\n <button class="aviary-replace">'+u((n.intlMessage||t&&t.intlMessage||o).call(s,{name:"intlMessage",hash:{intlName:"common.REPLACE"},data:i}))+"</button>\n</div>"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/feather-aviary-save-dialog",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-aviary-cross-platform-edit-warning",function(e,t){var n=e.Template.Handlebars.revive({compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s=t!=null?t:{},o=n.helperMissing,u=e.escapeExpression;return'<div class="aviary-cross-platform-warning">\n <div class="choose-source-message">\n '+u((n.intlMessage||t&&t.intlMessage||o).call(s,{name:"intlMessage",hash:{intlName:"aviary.CROSS_PLATFORM_EDIT_WARNING"},data:i}))+'\n </div>\n <div class="choose-action">\n <button class="aviary-replace">'+u((n.intlMessage||t&&t.intlMessage||o).call(s,{name:"intlMessage",hash:{intlName:"common.REPLACE"},data:i}))+'</button>\n <button class="alt aviary-upload">'+u((n.intlMessage||t&&t.intlMessage||o).call(s,{name:"intlMessage",hash:{intlName:"aviary.SAVE"},data:i}))+"</button>\n </div>\n</div>"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/aviary-cross-platform-edit-warning",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("feather-aviary-view",function(e,t){var n=require("lib/flog")(t);e.FlickrView.create(this.name,e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(e){return this.nsid=e.nsid,this.photoId=e.photoId,this.backToURL=e.backToURL,this.get("container").get("innerHTML")===""&&this.setContainerHTML(""),this},loadState:function(){var t=this,n=new e.FlickrPromise({photo:t.appContext.getModel("photo-models",t.photoId)});return n.then(function(e){t.set("photo",e.photo)})},buildContainer:function(){return this},mapLanguage:function(e){var t={"de-DE":"de","en-US":"en","es-US":"es","fr-FR":"fr","id-ID":"id","it-IT":"it","ko-KR":"ko","pt-BR":"pt_BR","vi-VN":"vi","zh-Hant-HK":"zh_HANT"};return t[e]},responseFromAviaryFrame:function(t){var r=this.get("photo"),i="https:",s,o,u,a,f=e.guid(),l,c,h,p,d,v,m,g=this,y,b=/^https:\/\/s3.amazonaws.com\/hires.aviary.com\/k\/e387fafbf27235a7\/.+/,w="https://s.yimg.com",E={sendAuthParamsToiFrame:"Give new auth params",sendAuthParamsToPollAviaryJobStatus:"Give polling auth params",iFrameIsReady:"iFrame is ready",aviaryEditorClosed:"Aviary Editor is closed",aviaryError:"Error"},S;s=i+r.getLargestSize().url,o=i+r.getValue("sizes").o.url,u=r.getValue("oWidth"),a=r.getValue("oHeight"),t.origin===w&&g.isValidFlickrPhoto(s)&&g.isValidFlickrPhoto(o)&&(t.data===E.iFrameIsReady&&this.handShakeIntervalRef||t.data===E.sendAuthParamsToiFrame||t.data===E.sendAuthParamsToPollAviaryJobStatus?(this.handShakeIntervalRef&&(clearInterval(this.handShakeIntervalRef),clearTimeout(this.iframeTimeoutRef),this.handShakeIntervalRef=!1,this.iframeTimeoutRef=!1),g.appContext.callAPI("flickr.aviary.createSignature",{salt:f}).then(function(e){d=g.mapLanguage(g.appContext.lang),v=g.get("photo").getValue("rotation"),v/90%2&&(u=r.getValue("oHeight"),a=r.getValue("oWidth")),l=e.signature&&e.signature.apiKey?e.signature.apiKey:null,p=e.signature&&e.signature.content?e.signature.content:null,c=e.signature&&e.signature.timestamp?e.signature.timestamp.toString():null,h=e.signature&&e.signature.method?e.signature.method:null,t.data===E.iFrameIsReady?S="Editor setup":t.data===E.sendAuthParamsToiFrame?S="Save auth":t.data===E.sendAuthParamsToPollAviaryJobStatus&&(S="Polling auth"),y={purpose:S,originalPhotoURL:o,originalPhotoWidth:u,originalPhotoHeight:a,largestPhotoURL:s,salt:f,apiKey:l,signature:p,timeStamp:c,hashing:h,language:d,rotation:v},t.source.postMessage(y,w)},function(t){n.error("Error generating Signature for Aviary",{err:t}),g.onError(g.intlMessage({intlName:"errors.ERROR_HAS_OCCURRED"})),e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.aviarySignature.creation.failure",title:"Aviary signature creation API Failure"},e.url("/beacon_flanal_reboot_event.gne"))})})):t.data===E.aviaryEditorClosed?(this.aviaryDialog.close(),e.config.win.removeEventListener("message",this.messageListenerFunction,!1)):t.data.indexOf("Error:")!==-1?(e.rapidTracker.beacon(g.name,"aviaryError"),n.error("Aviary Editor has returned an error",{data:t.data}),e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.aviaryEditor.failure",title:"Aviary Editor Failure"},e.url("/beacon_flanal_reboot_event.gne"))}),m=new e.Views.FluidModal({appContext:g.appContext,dismissOnOverlayClick:!0,showBodyLines:!1,showCancelButton:!0,showActionButton:!0,showCancelX:!0,title:this.intlMessage({intlName:"common.RETRY"}),message:this.intlMessage({intlName:"aviary.RETRY_DIALOG_MESSAGE"}),actionButtonLabel:this.intlMessage({intlName:"common.RETRY"})}),m.on("actionClick",function(r){g.appContext.callAPI("flickr.aviary.createSignature",{salt:f}).then(function(e){l=e.signature&&e.signature.apiKey?e.signature.apiKey:null,p=e.signature&&e.signature.content?e.signature.content:null,c=e.signature&&e.signature.timestamp?e.signature.timestamp.toString():null,h=e.signature&&e.signature.method?e.signature.method:null,y={purpose:"Save auth",originalPhotoURL:o,largestPhotoURL:s,salt:f,apiKey:l,signature:p,timeStamp:c,hashing:h,language:d,rotation:v},t.source.postMessage(y,w)},function(t){n.error("Error generating Signature for Aviary",{err:t}),g.onError(g.intlMessage({intlName:"errors.ERROR_HAS_OCCURRED"})),e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.aviarySignature.creation.failure",title:"Aviary signature creation API Failure"},e.url("/beacon_flanal_reboot_event.gne"))})})}),m.show()):(!g.urlFromAviary||g.urlFromAviary==="")&&b.test(t.data)&&g.saveFromAviary(t.data))},isValidFlickrPhoto:function(e){return e.indexOf("s.yimg.com")===-1&&e.indexOf("photo_unavailable")===-1},aviaryReplaceImage:function(t,r){var i=new FormData,s,o=e.config.flickr.api.hostname_client_replace,u,a,f=this;r=r.split(" "),f.saveModal&&!f.saveModal.get("container").one(".body").hasClass("loading")?f.saveModal.get("container").one(".body").addClass("loading").append(f.templates("flickr-balls")({})):f.chooseEditingSourceModal&&!f.chooseEditingSourceModal.get("container").one(".body").hasClass("loading")&&f.chooseEditingSourceModal.get("container").one(".body").addClass("loading").append(f.templates("flickr-balls")({})),i.append("api_key",e.config.flickr.api.site_key),i.append("csrf",e.config.flickr.csrf.token),i.append("external_image_link",r[0]),i.append("photo_id",f.photoId),i.append("clone_meta_from_photo_id",1),f.appContext.flipper.isFlipped("enable-non-destructive-edits")&&(i.append("store_original",1),i.append("client",3),i.append("meta",r[1])),s=new XMLHttpRequest,s.open("POST",o,!0),s.withCredentials=!0,u=function(t){var r=typeof t=="object"?t.target.statusText:t+"";f.urlFromAviary="",n.error("Error replacing the Image",{statusText:r}),f.onError(f.intlMessage({intlName:"errors.ERROR_REPLACING"})),e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.replace.failure",title:"Replace API Failure"},e.url("/beacon_flanal_reboot_event.gne"))})},a=function(t){var n,r,i;f.urlFromAviary="";try{i=document.createElement("div"),i.innerHTML=t.target.responseText,r=i.getElementsByTagName("rsp")[0]||"",r&&(r=r.getAttribute("stat")||""),n=i.
getElementsByTagName("err")[0]||"",n&&(n=n.getAttribute("msg")||"")}catch(s){r="",n=""}if(r!=="ok")return u((r||"empty")+": "+(n||"no message"));e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.replace.success",title:"Aviary Replace Image successful"},e.url("/beacon_flanal_reboot_event.gne"))}),f.fire("subviewViewEvent","photo:reload")},s.addEventListener("load",a),s.addEventListener("error",u),s.send(i)},aviaryUploadImage:function(t,r){var i=new FormData,s,o="https://up.flickr.com/services/upload",u,a,f=this;f.saveModal&&!f.saveModal.get("container").one(".body").hasClass("loading")?f.saveModal.get("container").one(".body").addClass("loading").append(f.templates("flickr-balls")({})):f.chooseEditingSourceModal&&!f.chooseEditingSourceModal.get("container").one(".body").hasClass("loading")&&f.chooseEditingSourceModal.get("container").one(".body").addClass("loading").append(f.templates("flickr-balls")({})),i.append("api_key",e.config.flickr.api.site_key),i.append("csrf",e.config.flickr.csrf.token),i.append("external_image_link",r),i.append("clone_meta_from_photo_id",f.photoId),s=new XMLHttpRequest,s.open("POST",o,!0),s.withCredentials=!0,u=function(t){var r=typeof t=="object"?t.target.statusText:t+"";f.urlFromAviary="",n.error("Error during Aviary edited image upload",{statusText:r}),f.onError(f.intlMessage({intlName:"errors.ERROR_SAVING"})),e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.upload.failure",title:"Upload API Failure"},e.url("/beacon_flanal_reboot_event.gne"))})},a=function(t){var n,r,i,s,o=f.get("photo").getValue("owner");f.urlFromAviary="";try{i=document.createElement("div"),i.innerHTML=t.target.responseText,r=i.getElementsByTagName("rsp")[0]||"",r&&(r=r.getAttribute("stat")||""),s=i.getElementsByTagName("photoid")[0].innerHTML||"",n=i.getElementsByTagName("err")[0]||"",n&&(n=n.getAttribute("msg")||"")}catch(a){r="",n=""}if(r!=="ok")return u((r||"empty")+": "+(n||"no message"));e.use("rrd",function(e){e.RRD.queue({event:"flickr.hermes.upload.success",title:"Aviary upload as a new Image successful"},e.url("/beacon_flanal_reboot_event.gne"))}),window.location="/photos/"+(o.getValue("pathAlias")||o.getValue("nsid"))+"/"+s},s.addEventListener("load",a),s.addEventListener("error",u),s.send(i)},saveFromAviary:function(t){var n=this,r,i=t.split(" ")[0];n.saveModal=new e.Views.FluidModal({appContext:n.appContext,dismissOnOverlayClick:!0,dismissOnActionClick:!1,dismissOnCancelClick:!1,showBodyLines:!1,showCancelButton:!1,showActionButton:!1,showCancelX:!0,title:this.intlMessage({intlName:"aviary.SAVE_PHOTO"}),message:this.templates("feather-aviary-save-dialog")({}),hideModalOverlay:!0,showButtons:!1,classList:"aviary-save-dialog"}),n.saveModal.show(),r=n.saveModal.get("container"),n.saveModal.on("activated",function(){r.one(".aviary-upload").on("click",n.aviaryUploadImage.bind(n),null,i),n.appContext.flipper.isFlipped("enable-non-destructive-edits")?r.one(".aviary-replace").on("click",n.checkForPreviousEdits.bind(n),null,t):r.one(".aviary-replace").on("click",n.aviaryReplaceImage.bind(n),null,t)})},aviaryEditSelected:function(){var t=this,n=this.get("photo"),r=window.YUI_config.groups.hermes.base,i,s=r+"html/feather_aviary.html",o,u,a,f,l=e.one("body");t.aviaryDialog&&(t.aviaryDialog.close(),t.aviaryDialog=null),t.saveModal&&(t.saveModal.close(),t.saveModal=null),t.chooseEditingSourceModal&&(t.chooseEditingSourceModal.close(),t.chooseEditingSourceModal=null);try{u=parseInt(n.getValue("sizes").o.width,10),a=parseInt(n.getValue("sizes").o.height,10)}catch(c){}f=u*a/1e6,f&&f<50?(t.aviaryDialog=e.Views.dialog.getNewInstance("dialog-modal",{content:'<iframe id="aviary-iframe"></iframe>',appContext:t.appContext,tintCurtain:.5,dialogClass:"scrappy-dialog aviary-dialog"}),t.aviaryDialog.show(),i=t.aviaryDialog.get("container").one("#aviary-iframe"),i.setAttribute("seamless","seamless"),i.setAttribute("frameborder","0"),i.setAttribute("scrolling","no"),i.setAttribute("marginheight","0"),i.setAttribute("marginwidth","0"),i.set("src",s),e.one(".aviary-dialog").setStyles({marginLeft:-((l.get("winWidth")-50)/2),marginTop:-((l.get("winHeight")-100)/2)}),i.setStyles({width:l.get("winWidth")-100,height:l.get("winHeight")-100}),o=i.getDOMNode().contentWindow,t.handShakeIntervalRef=setInterval(function(){try{o.postMessage("Is the iFrame ready?","https://s.yimg.com")}catch(e){}},200),t.iframeTimeoutRef=setTimeout(function(){t.handShakeIntervalRef&&(clearInterval(t.handShakeIntervalRef),t.onError(t.intlMessage({intlName:"aviary.ERROR"})))},2e4),this.messageListenerFunction=this.responseFromAviaryFrame.bind(this),e.config.win.addEventListener("message",this.messageListenerFunction,!1)):f?t.onError(t.intlMessage({intlName:"aviary.IMAGE_TOO_LARGE"})):t.onError(t.intlMessage({intlName:"aviary.NO_ORIGINAL_PHOTO"}))},checkForPreviousEdits:function(t,r){var i=this,s={},o;s.photo_id=i.photoId,i.saveModal&&!i.saveModal.get("container").one(".body").hasClass("loading")&&i.saveModal.get("container").one(".body").addClass("loading").append(i.templates("flickr-balls")({})),i.appContext.callAPI("flickr.photos.getEdits",s).then(function(t){var n=t.edits;n&&n.client&&parseInt(n.client,10)!==3?(i.saveModal&&(i.saveModal.close(),i.saveModal=null),i.chooseEditingSourceModal=new e.Views.FluidModal({appContext:i.appContext,dismissOnOverlayClick:!1,dismissOnActionClick:!1,dismissOnCancelClick:!1,showBodyLines:!1,showCancelButton:!1,showActionButton:!1,showCancelX:!0,title:i.intlMessage({intlName:"aviary.SAVE_PHOTO"}),message:i.templates("aviary-cross-platform-edit-warning")({}),hideModalOverlay:!0,showButtons:!1,classList:"aviary-cross-platform-edit-warning-dialog"}),i.chooseEditingSourceModal.show(),o=i.chooseEditingSourceModal.get("container"),i.chooseEditingSourceModal.on("activated",function(){o.one(".aviary-upload").on("click",i.aviaryUploadImage.bind(i),null,r.split(" ")[0]),o.one(".aviary-replace").on("click",i.aviaryReplaceImage.bind(i),null,r)})):i.aviaryReplaceImage.bind(i)(null,r)},function(e){n.error
("Error getting previous edits for this photo",{err:e}),i.onError(i.intlMessage({intlName:"errors.ERROR_HAS_OCCURRED"}))})},activate:function(){var t=this;return e.one(".aviary-dialog")&&e.one(".aviary-dialog").remove(!0),t.aviaryEditSelected.bind(t)(),!1},onError:function(t){var n=this,r;n.aviaryDialog&&(n.aviaryDialog.close(),n.aviaryDialog=null),n.saveModal&&(n.saveModal.close(),n.saveModal=null),n.chooseEditingSourceModal&&(n.chooseEditingSourceModal.close(),n.chooseEditingSourceModal=null),r=new e.Views.FluidModal({appContext:n.appContext,title:n.intlMessage({intlName:"common.ERROR"}),message:t,actionButtonLabel:n.intlMessage({intlName:"common.OK"}),showCancelButton:!1,hideModalOverlay:!0}),r.show()},destructor:function(){this.handShakeIntervalRef&&clearInterval(this.handShakeIntervalRef),this.iframeTimeoutRef&&clearTimeout(this.iframeTimeoutRef),this.handShakeIntervalRef=null,this.iframeTimeoutRef=null,this.aviaryDialog&&(this.aviaryDialog.close(),this.aviaryDialog=null),this.saveModal&&(this.saveModal.close(),this.saveModal=null),this.chooseEditingSourceModal&&(this.chooseEditingSourceModal.close(),this.chooseEditingSourceModal=null)}})},"@VERSION@",{requires:["flickr-view","url-helper","dialog","confirmation-dialog-view","flickr-promise","hermes-template-feather-aviary-save-dialog","hermes-template-aviary-cross-platform-edit-warning","fluid-balls-css","fluid-modal-view","hermes-template-flickr-balls"],langBundles:["common","aviary","errors"],optional:[]});
YUI.add("hermes-lang-aviary",function(e,t){e.Intl.add("hermes/aviary","en-US",{SAVE:["Save a new copy"],SAVE_PHOTO:["Save this photo"],ERROR:["An error has occurred using Aviary. Please try again."],ENHANCE:["Enhance"],IMAGE_TOO_LARGE:["Sorry, but this image is too large to be edited. Please try again with an image that is less than 50 megapixels."],NO_ORIGINAL_PHOTO:["Unable to get the original photo. Please try again."],RETRY_DIALOG_MESSAGE:["This is taking longer than usual. Would you like to retry saving your changes?"],EDIT_IN_AVIARY:["Edit in Aviary"],SELECT_PHOTO_TO_EDIT:["Select photo to Edit"],PREVIOUS_EDIT_WARNING:["This photo has previously been edited on a mobile device. Choose if you want to edit the current version, or its original. If you select the current version, you will no longer be able to undo the edits that you have made so far on your mobile device."],ORIGINAL_LABEL:["Original"],CURRENT_LABEL:["Current"],ORIGINAL_IMAGE:["Original image"],CURRENT_IMAGE:["Current image"],CROSS_PLATFORM_EDIT_WARNING:["This photo was last edited on a mobile device. If you choose to replace this photo, you will no longer be able to undo the edits that you have made so far on your mobile device."]})},"@VERSION@",{requires:["intl"]});
YUI.add("hermes-lang-errors",function(e,t){e.Intl.add("hermes/errors","en-US",{UNAUTHORIZED_ACCESS:["Unauthorized Access"],YOU_ARE_NOT_AUTHORIZED:["You have attempted to access a page for which you are not authorized."],AUTO_REDIRECT_IN_10_SECONDS:["This page will automatically redirect to the Flickr home page in 10 seconds,"],OR_CLICK_LINK_FOR_HOME:["or click the following link to go straight to the <a href='/'>home page</a>."],ERROR:["Error"],ERROR_HAS_OCCURRED:["An error has occurred. Please try again."],ERROR_REPLACING:["An error has occurred replacing the image. Please try again."],ERROR_SAVING:["An error has occurred saving the image. Please try again."],DOWNLOAD_EXPIRED:["Download expired"],DOWNLOAD_NO_LONGER_AVAILABLE:["Your download is no longer available."]})},"@VERSION@",{requires:["intl"]});
YUI.add("hermes-template-scrappy-edit-button",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){return' <div class=\'edit\'>\n <a href="#" title="'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.EDIT_PHOTO"},data:i}))+'" class="button">\n <i class="ui-icon-edit"></i>\n </a>\n </div>\n'},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},t!=null?t.viewerIsOwner:t,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.noop,data:i}))!=null?s:""},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/scrappy-edit-button",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-scrappy-edit-menu",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){var s,o=t!=null?t:{};return((s=n["if"].call(o,t!=null?t.enableEditInAviary:t,{name:"if",hash:{},fn:e.program(2,i,0),inverse:e.program(4,i,0),data:i}))!=null?s:"")+" "+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(o,{name:"intlMessage",hash:{intlName:"aviary.EDIT_IN_AVIARY"},data:i}))+"\n </a></li>\n"},2:function(e,t,n,r,i){return' <li><a href="#" class="edit-aviary">\n'},4:function(e,t,n,r,i){var s,o=t!=null?t:{};return' <li><a href="#" class="unavailable-feature '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(5,i,0),inverse:e.noop,data:i}))!=null?s:"")+'" '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(7,i,0),inverse:e.noop,data:i}))!=null?s:"")+">\n"},5:function(e,t,n,r,i){return"isVideo"},7:function(e,t,n,r,i){return'title="'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.NO_VIDEOS_IN_AVIARY"},data:i}))+'"}}"'},9:function(e,t,n,r,i){var s,o=t!=null?t:{};return' <li><a href="#" class="rotate-photo '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(10,i,0),inverse:e.noop,data:i}))!=null?s:"")+'" '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(12,i,0),inverse:e.noop,data:i}))!=null?s:"")+">\n "+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(o,{name:"intlMessage",hash:{intlName:"photo-page-scrappy.ROTATE"},data:i}))+"\n </a></li>\n"},10:function(e,t,n,r,i){return"isVideo unavailable-feature"},12:function(e,t,n,r,i){return'title="'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.NO_VIDEO_ROTATION"},data:i}))+'"'},14:function(e,t,n,r,i){var s,o=t!=null?t:{};return' <li><a href="#" class="replace-photo '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(10,i,0),inverse:e.noop,data:i}))!=null?s:"")+'" '+((s=n["if"].call(o,t!=null?t.isVideo:t,{name:"if",hash:{},fn:e.program(15,i,0),inverse:e.noop,data:i}))!=null?s:"")+">\n "+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(o,{name:"intlMessage",hash:{intlName:"photo-page-scrappy.REPLACE"},data:i}))+"\n </a></li>\n"},15:function(e,t,n,r,i){return'title="'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.NO_VIDEO_REPLACE"},data:i}))+'"'},17:function(e,t,n,r,i){return' <li><a href="#" class="delete-photo">\n '+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"common.DELETE"},data:i}))+"\n </a></li>\n"},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s,o=t!=null?t:{};return"<ul>\n\n"+((s=n["if"].call(o,t!=null?t.showEditInAviaryLink:t,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.noop,data:i}))!=null?s:"")+"\n"+((s=n["if"].call(o,t!=null?t.showRotateLink:t,{name:"if",hash:{},fn:e.program(9,i,0),inverse:e.noop,data:i}))!=null?s:"")+"\n"+((s=n["if"].call(o,t!=null?t.showReplaceLink:t,{name:"if",hash:{},fn:e.program(14,i,0),inverse:e.noop,data:i}))!=null?s:"")+"\n\n"+((s=n["if"].call(o,t!=null?t.showDeleteLink:t,{name:"if",hash:{},fn:e.program(17,i,0),inverse:e.noop,data:i}))!=null?s:"")+"\n</ul>"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/scrappy-edit-menu",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-delete-photo-dialog-content",function(e,t){var n=e.Template.Handlebars.revive({compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){return"Are you sure you want to delete this photo?<br>\n<strong>This cannot be undone.</strong>"},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/delete-photo-dialog-content",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-replace-photo-dialog-content",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){return'<div class="ui-dialog-wrapper c-dialog-cta-photoreplace">\n <button class="ui-button ui-dialog-button-close" data-action="dismiss"><span> </span></button>\n <div class="ui-dialog-description js-description">\n '+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.ERROR_REPLACING_PHOTO"},data:i}))+'\n </div>\n <div class="ui-buttonbar ui-dialog-buttonbar"></div>\n</div>\n'},3:function(e,t,n,r,i){var s,o=t!=null?t:{};return'<div class="ui-dialog-wrapper c-dialog-cta-photoreplace">\n <div class="ui-dialog-title">\n <h3>'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(o,{name:"intlMessage",hash:{intlName:"photo-page-scrappy.REPLACE_PHOTO"},data:i}))+'</h3>\n <i data-action="dismiss" class="cancel-confirmation ui-dialog-button-close"></i>\n </div>\n <div class="dialog-content">\n <i class="dialog-icon ui-icon-modal-warning"></i>\n <div class="ui-dialog-description js-description">\n'+((s=n["if"].call(o,t!=null?t.fileName:t,{name:"if",hash:{},fn:e.program(4,i,0),inverse:e.program(9,i,0),data:i}))!=null?s:"")+' </div>\n </div>\n <div class="ui-buttonbar ui-dialog-buttonbar">\n'+((s=n["if"].call(o,t!=null?t.fileName:t,{name:"if",hash:{},fn:e.program(11,i,0),inverse:e.program(14,i,0),data:i}))!=null?s:"")+" \n </div>\n</div>\n"},4:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},t!=null?t.uploading:t,{name:"if",hash:{},fn:e.program(5,i,0),inverse:e.program(7,i,0),data:i}))!=null?s:""},5:function(e,t,n,r,i){return" "+e.escapeExpression((n.intlHTMLMessage||t&&t.intlHTMLMessage||n.helperMissing).call(t!=null?t:{},{name:"intlHTMLMessage",hash:{fileName:t!=null?t.fileName:t,intlName:"photo-page-scrappy.REPLACE_UPLOADING"},data:i}))+'\n <progress min="0" max="100" value="0"></progress>\n'},7:function(e,t,n,r,i){return" "+e.escapeExpression((n.intlHTMLMessage||t&&t.intlHTMLMessage||n.helperMissing).call(t!=null?t:{},{name:"intlHTMLMessage",hash:{fileName:t!=null?t.fileName:t,username:t!=null?t.username:t,photoTitle:t!=null?t.photoTitle:t,intlName:"photo-page-scrappy.PERMANENTLY_REPLACE"},data:i}))+"\n"},9:function(e,t,n,r,i){return" "+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.REPLACE_WARNING"},data:i}))+"\n"},11:function(e,t,n,r,i){var s;return(s=n.unless.call(t!=null?t:{},t!=null?t.uploading:t,{name:"unless",hash:{},fn:e.program(12,i,0),inverse:e.noop,data:i}))!=null?s:""},12:function(e,t,n,r,i){return' <button class="ui-button ui-button-cta c-button-replace ui-dialog-button-done" data-action="submit">'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.REPLACE"},data:i}))+"</button>\n"},14:function(e,t,n,r,i){return' <input type="file" name="file" accept="image/*">\n <button class="ui-button ui-button-cta c-button-changefile ui-dialog-button-done" data-action="change">'+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"common.CHOOSE_FILE"},data:i}))+"</button>\n"},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},t!=null?t.error:t,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.program(3,i,0),data:i}))!=null?s:""},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/replace-photo-dialog-content",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("hermes-template-rotate-photo-dialog-content",function(e,t){var n=e.Template.Handlebars.revive({1:function(e,t,n,r,i){return'<div class="ui-dialog-wrapper c-dialog-cta-photorotate">\n <button class="ui-button ui-dialog-button-close" data-action="dismiss"><span> </span></button>\n <div class="ui-dialog-description js-description">\n '+e.escapeExpression((n.intlMessage||t&&t.intlMessage||n.helperMissing).call(t!=null?t:{},{name:"intlMessage",hash:{intlName:"photo-page-scrappy.ERROR_ROTATING_PHOTO"},data:i}))+'\n </div>\n <div class="ui-buttonbar ui-dialog-buttonbar"></div>\n</div>\n'},3:function(e,t,n,r,i){var s,o=t!=null?t:{},u=n.helperMissing,a=e.escapeExpression,f=e.lambda;return'<div class="ui-dialog-wrapper c-dialog-cta-photorotate">\n <div class="ui-dialog-description js-description">\n <button class="ui-button ui-dialog-button-close" data-action="dismiss"><span> </span></button>\n <h3>'+a((n.intlMessage||t&&t.intlMessage||u).call(o,{name:"intlMessage",hash:{intlName:"photo-page-scrappy.ROTATE_PHOTO"},data:i}))+'</h3>\n\n <ul class="c-rotations '+((s=(n.ifCond||t&&t.ifCond||u).call(o,(s=t!=null?t.preview:t)!=null?s.width:s,"<",(s=t!=null?t.preview:t)!=null?s.height:s,{name:"ifCond",hash:{},fn:e.program(4,i,0),inverse:e.noop,data:i}))!=null?s:"")+'">\n <li><img class="ui-util-rotate-90" src="'+a(f((s=t!=null?t.preview:t)!=null?s.url:s,t))+'" data-action="select" data-rotation="90"></li>\n <li><img class="ui-util-rotate-180" src="'+a(f((s=t!=null?t.preview:t)!=null?s.url:s,t))+'" data-action="select" data-rotation="180"></li>\n <li><img class="ui-util-rotate-270" src="'+a(f((s=t!=null?t.preview:t)!=null?s.url:s,t))+'" data-action="select" data-rotation="270"></li>\n </ul>\n\n </div>\n <div class="ui-buttonbar ui-dialog-buttonbar">\n <button class="ui-button ui-button-cta c-button-rotate ui-dialog-button-done" data-action="submit">'+a((n.intlMessage||t&&t.intlMessage||u).call(o,{name:"intlMessage",hash:{intlName:"photo-page-scrappy.ROTATE_PHOTO"},data:i}))+"</button>\n </div>\n</div>\n"},4:function(e,t,n,r,i){return"c-rotations-portrait"},compiler:[7,">= 4.0.0"],main:function(e,t,n,r,i){var s;return(s=n["if"].call(t!=null?t:{},t!=null?t.error:t,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.program(3,i,0),data:i}))!=null?s:""},useData:!0}),r={};e.Array.each([],function(t){var n=e.Template.get("hermes/"+t);n&&(r[t]=n)}),e.Template.register("hermes/rotate-photo-dialog-content",function(t,i){return i=i||{},i.partials=i.partials?e.merge(r,i.partials):r,n(t,i)})},"@VERSION@",{requires:["template-base","handlebars-base"]});
YUI.add("photo-well-scrappy-edit-view",function(e,t){var n=require("lib/flog")(t);e.FlickrView.create(this.name,e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(e){return this.nsid=e.nsid,this.photoId=e.photoId,this.backToURL=e.backToURL,this.context=e.context,this.get("container").get("innerHTML")===""&&this.setContainerWithTemplate("scrappy-edit-button",{loadingView:!0}),this},subviewConfig:{"feather-aviary-view":{requiredToShowOnClient:!1,requiredToShowOnServer:!1}},loadState:function(){var t=this,n=[];return this.appContext.forceServerRender||n.push(this.appContext.getModel(this.context.modelName,this.context.params).then(function(e){t.set("contextModel",e)}).then(function(){var n=e.merge(t.context.params,{photoId:t.photoId,numNext:1,numPrev:1});return t.get("contextModel").getValue("photoContextList").getContext(n).then(function(){var e,n=t.get("contextModel").getValue("photoContextList").getList(),r=n.length;e=n.map(function(e){return e.getValue("id")}).indexOf(t.photoId),e>=0&&e<r&&t.set("nextPhotoModel",n[e+1]),e>0&&t.set("prevPhotoModel",n[e-1])})})),n.push(this.appContext.getModel("photo-models",t.photoId).then(function(e){t.set("photo",e)})),e.Promise.all(n)},buildContainer:function(){var e=this.get("photo").getValue("owner").getValue("isMe");return this.setContainerWithTemplate("scrappy-edit-button",{viewerIsOwner:e}),this},setupDropdown:function(){var t=this.get("container"),n=this.get("photo"),r,i=n.getValue("owner").getValue("isMe"),s=t,o,u=!1,a=!1,f=n.getValue("isVideo"),l=n.getValue("id"),c=this;this.appContext.flipper.isFlipped("turn-off-aviary")&&(a=!0),i&&(u=!0),r=e.URLHelper.getPhotoPage({photoId:n.getValue("id"),pathAlias:n.getValue("owner").getValue("pathAlias")}),o=this.templates("scrappy-edit-menu")({photoURL:r,photoId:l,viewerIsOwner:i,showDeleteLink:i,showRotateLink:i&&!f,showReplaceLink:i&&!f,isVideo:f,showEditInAviaryLink:i&&!f&&!a,enableEditInAviary:u}),this.editMenu=e.Views.dialog.getNewInstance("dialog-tooltip",{content:o,anchorTo:s,dropUp:!0,parent:this,positioning:!1,rootEl:t}),this.editMenu.render(),this.editMenu.on("toggle",function(e){e&&e.details&&e.details.length>0&&(e.details[0]?c.fire("subviewViewEvent","make in view",t):c.fire("subviewViewEvent","close in view"))})},handleMenuButtonClick:function(t){t.preventDefault(),e.rapidTracker.beacon(this.name,"editMenuClick"),this.editMenu.toggle()},handleDeletePhotoClick:function(t){t.preventDefault();var n,r,i=this;this.editMenu.hide(),n=new e.Views["confirmation-dialog-view"]({photoID:this.photoId,appContext:this.appContext,title:this.intlMessage({intlName:"photo-page-scrappy.DELETE_PHOTO"}),content:this.intlMessage({intlName:"photo-page-scrappy.PERMANTENTLY_DELETE"}),confirmButtonLabel:this.intlMessage({intlName:"common.DELETE"}),confirmButtonClass:"ui-dialog-button-negative"}),n.render(),n.activate(),r=n.get("container"),n.registerEventHandler(r.one(".ui-dialog-button-confirm").on("click",this.handleDeletePhotoConfirmClick,this)),n.registerEventHandler(r.one(".ui-dialog-button-close").on("click",function(){i.deleteDialog.close()})),this.fire("subviewViewEvent","getDialogOffset",function(t){i.deleteDialog=e.Views.dialog.getNewInstance("dialog-modal",{content:n.get("container"),appContext:i.appContext,offsetLeft:t,dialogClass:"scrappy-dialog"}),i.deleteDialog.show()}),e.rapidTracker.beacon(this.name,"deletePhotoClick")},handleDeletePhotoConfirmClick:function(t){var n=this,r=n.get("photo").getValue("owner"),i,s=n.get("nextPhotoModel"),o=n.get("prevPhotoModel");e.rapidTracker.beacon(this.name,"deletePhotoConfirmationClick"),n.deleteDialog.close(),n.deleteDialog.destroy(),this.appContext.callAPI("flickr.photos.delete",{photo_id:this.photoId}).then(function(t){s?i=e.URLHelper.getPhotoPage({photoId:s.getValue("id"),pathAlias:s.getValue("owner").getValue("pathAlias"),contextSuffix:n.get("contextModel").getValue("urlSuffix")}):o?i=e.URLHelper.getPhotoPage({photoId:o.getValue("id"),pathAlias:o.getValue("owner").getValue("pathAlias"),contextSuffix:n.get("contextModel").getValue("urlSuffix")}):i=r.getValue("url")+"?deleted="+n.photoId,e.config.win.location=i},function(e){n.showErrorDialog(n.intlMessage({intlName:"photo-page-scrappy.ERROR_DELETING_PHOTO"}))})},handleReplacePhotoClick:function(t){t.halt();var n=this.get("container"),r=this,i=this.get("photo").getValue("isVideo");if(i)return;this.editMenu.hide(),this.fire("subviewViewEvent","getDialogOffset",function(t){r.replaceDialog=e.Views.dialog.getNewInstance("dialog-cta",{id:"replace-"+r.photoId,attrs:{},template:"dialog-cta-reboot",content:r.templates("replace-photo-dialog-content"),parent:r,photoTitle:r.get("photo").getValue("title"),username:r.get("photo").getValue("owner").getValue("displayname"),rootEl:n.ancestor(".photo-page-scrappy-view"),offsetLeft:t,dialogClass:"scrappy-dialog"}),r.replaceDialog.attachEvents({"input change:":function(e){e.halt();var t=e.target.getDOMNode().files[0];if(!t)return;r._imgFile=t,r.replaceConfirm()},":submit":function(){r.replaceSubmit()}}),r.replaceDialog.on("hide",function(){r._imgFileXhr&&r._imgFileXhr.abort(),r._imgFileXhr=null,r._imgFile=null,r.replaceDialog.destroy(),r.replaceDialog=null}),r.replaceDialog.show()}),e.rapidTracker.beacon(this.name,"replacePhotoClick")},replaceConfirm:function(){this.replaceDialog.set("fileName",this._imgFile.name),this.replaceDialog.renderContent({photoTitle:this.get("photo").getValue("title"),username:this.get("photo").getValue("owner").getValue("displayname")}),e.rapidTracker.beacon(this.name,"replacePhotoConfirmationClick")},replaceSubmit:function(){var t=new FormData,r=this,i,s,o=e.config.flickr.api.hostname_client_replace,u,a,f;this.replaceDialog.set("uploading",!0),this.replaceDialog.renderContent(),this.replaceDialog.switchToWorking(),t.append("api_key",e.config.flickr.api.site_key),t.append("csrf",e.config.flickr.csrf.token),t.append("photo",this._imgFile,this._imgFile.name),t.append("photo_id",this.photoId),i=this._imgFileXhr=new XMLHttpRequest,i.open("POST"
,o,!0),i.withCredentials=!0,a=function(e){var t=typeof e=="object"?e.target.statusText:e+"";r.replaceDialog.switchToWorking(!1),r.replaceDialog.close(),r.showErrorDialog(r.intlMessage({intlName:"photo-page-scrappy.ERROR_REPLACING_PHOTO"})),n.error("error during upload",{statusText:t})},f=function(e){var t,n,i;try{i=document.createElement("div"),i.innerHTML=e.target.responseText,n=i.getElementsByTagName("rsp")[0]||"",n&&(n=n.getAttribute("stat")||""),t=i.getElementsByTagName("err")[0]||"",t&&(t=t.getAttribute("msg")||"")}catch(s){n="",t=""}if(n!=="ok")return a((n||"empty")+": "+(t||"no message"));r.replaceDialog.close(),r.fire("subviewViewEvent","photo:reload")},i.addEventListener("load",f),i.addEventListener("error",a),u=r.replaceDialog.get("container").one("progress").getDOMNode(),i.upload.addEventListener("progress",function(e){u.value=s=Math.floor(100*(e.loaded/e.total)),e.loaded===e.total&&u.removeAttribute("value")}),i.send(t)},handleRotatePhotoClick:function(t){t.halt();var n=this,r=240,i=this.get("photo").getValue("isVideo");if(i)return;this.editMenu.hide(),this.fire("subviewViewEvent","getDialogOffset",function(t){n.rotateDialog=e.Views.dialog.getNewInstance("dialog-cta",{id:"rotate-"+n.photoId,attrs:{},template:"dialog-cta-reboot",content:n.templates("rotate-photo-dialog-content"),parent:n,offsetLeft:t,dialogClass:"scrappy-dialog"}),n.rotateDialog.attachEvents({":select":function(t,r){n.rotateDialog.switchToLocked(!1),t.target.ancestor(".c-rotations").all("img").removeClass("c-state-selected"),t.target.addClass("c-state-selected"),n._imgRotation=e.flutil.constrainToValues(r.rotation,["90","180","270"])},":submit":function(){n.rotateSubmit()}}),n.rotateDialog.on("hide",function(){n.rotateDialog.destroy(),n.rotateDialog=null}),n.rotateDialog.set("preview",n.get("photo").getSizeToFit({width:r,height:r})),n.rotateDialog.switchToLocked(),n.rotateDialog.show()}),e.rapidTracker.beacon(this.name,"rotatePhotoClick")},rotateSubmit:function(){var t=this;t.rotateDialog.get("container").one(".ui-dialog-buttonbar").addClass("loading").append(t.templates("flickr-balls")({})),e.rapidTracker.beacon(this.name,"rotatePhotoConfirmationClick"),this.appContext.callAPI("flickr.photos.transform.rotate",{photo_id:this.photoId,degrees:this._imgRotation}).then(function(){setTimeout(function(){t.rotateDialog.close(),t.fire("subviewViewEvent","photo:reload")},2e3)},function(e){t.rotateDialog.get("container").one(".ui-dialog-buttonbar").removeClass("loading"),t.rotateDialog.close(),t.showErrorDialog(t.intlMessage({intlName:"photo-page-scrappy.ERROR_ROTATING_PHOTO"})),n.error("error during rotation",{statusText:e.toString()})})},handleEditAviaryClick:function(t){var n;t.halt(),this.editMenu.hide(),n=this.subviews["feather-aviary-view"],n&&n.activate(),e.rapidTracker.beacon(this.name,"editAviary")},activate:function(){var e=this,t=this.get("container"),n,r={};return this.appContext.experiments.fullscreen.getMode()||(this.setupDropdown(),n=e.editMenu.get("container")),t&&this.registerEventHandler(t.on("click",e.handleMenuButtonClick,e)),this.appContext.experiments.fullscreen.getMode()||this.appContext.auth.signedIn&&(r.deleteMenuItem=n.one(".delete-photo"),r.deleteMenuItem&&r.deleteMenuItem.on("click",e.handleDeletePhotoClick,e),r.rotateMenuItem=n.one(".rotate-photo"),r.rotateMenuItem&&r.rotateMenuItem.on("click",e.handleRotatePhotoClick,e),r.replaceMenuItem=n.one(".replace-photo"),r.replaceMenuItem&&r.replaceMenuItem.on("click",e.handleReplacePhotoClick,e),r.aviaryMenuItem=n.one(".edit-aviary"),r.aviaryMenuItem&&r.aviaryMenuItem.on("click",e.handleEditAviaryClick,e)),this},showErrorDialog:function(t){return this.errorDialog=new e.Views.FluidModal({appContext:this.appContext,dismissOnOverlayClick:!0,dismissOnActionClick:!0,showCancelButton:!1,title:this.intlMessage({intlName:"common.OOPS"}),actionButtonLabel:this.intlMessage({intlName:"common.OK"}),message:t,darkOverlay:!0}),this.errorDialog.show(),this.errorDialog}})},"@VERSION@",{requires:["flickr-view","dialog","flutil","hermes-template-dialog-cta-reboot","flickr-promise","more-menu-css","feather-aviary-view","confirmation-dialog-view","hermes-template-scrappy-edit-button","hermes-template-scrappy-edit-menu","hermes-template-delete-photo-dialog-content","hermes-template-replace-photo-dialog-content","hermes-template-rotate-photo-dialog-content","photo-well-scrappy-edit-view-css","hermes-template-flickr-balls","fluid-balls-css"],optional:[],langBundles:["common","photo-page-scrappy","aviary"]});