YUI.add("flickr-galleries-comments-editComment-updater",function(e,t){"use strict";e.namespace("ModelUpdaters")["flickr-galleries-comments-editComment"]={run:function(n,o){var r=this;return e.Promise.all([o.callAPI("flickr.galleries.comments.editComment",this._processParams(n)),o.getModel("gallery-comment-models",n.commentId)]).then(function(e){return r._processResponse(e,n,o)},e.FetcherErrorLogger(t))},_processParams:function(e){return{comment_id:e.commentId,gallery_id:e.galleryId,owner_id:e.ownerId,comment_text:e.content,extras:"full_response, expand_bbml"}},_processResponse:function(e,t,n){var o,r,m=e[0].comment||{content:""},c=e[1];return m.secureComment&&(o="string"==typeof m.secureComment?m.secureComment:m.secureComment.content),o||(o=m.content||m.comment),m.rawComment&&(r="string"==typeof m.rawComment?m.rawComment:m.rawComment.content),r||(r=m.content||m.comment),c.setValues({content:t.content,contentSecure:o,contentRaw:r}),c}}},"@VERSION@",{requires:["flickr-promise"],optional:[]});YUI.add("gallery-comment-models",function(e){function t(e){t.superclass.constructor.call(this,e)}e.Models[this.name]=t,e.extend(t,e.FlickrModelRegistry,{name:this.name,remote:{create:function(t){return e.ModelCreators["flickr-galleries-comments-addComment"].run(t,this.appContext)},delete:function(t,r){return e.ModelDeletors["flickr-galleries-comments-deleteComment"].run(t,r)},update:function(t,r){return e.ModelUpdaters["flickr-galleries-comments-editComment"].run({commentId:t.commentId,galleryId:t.galleryId,ownerId:t.ownerId,content:t.content},r)}},updateRemote:function(e,t){return this.remote.update({commentId:e,galleryId:this.getValue(e,"galleryId"),ownerId:this.getValue(e,"galleryOwnerId"),content:t},this.appContext)},deleteRemote:function(e){return this.remote.delete({commentId:e,galleryId:this.getValue(e,"galleryId"),ownerId:this.getValue(e,"galleryOwnerId")},this.appContext)},attributes:{id:{},galleryId:{},galleryOwnerId:{},author:{isModel:!0},authorUsername:{},authorId:{},date:{},timeago:{readOnly:!0,derivedBy:["date"],getter:function(t,r){return e.moment.unix(this.getValue(r,"date"))}},permalink:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}},content:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}},contentSecure:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}},contentRaw:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}}}})},"@VERSION@",{requires:["flickr-model-registry","moment","flickr-galleries-comments-addComment-creator","flickr-galleries-comments-deleteComment-deletor","flickr-galleries-comments-editComment-updater"]});YUI.add("flickr-galleries-comments-getList-fetcher",function(e,t){"use strict";e.namespace("ListFetchers")["flickr-galleries-comments-getList"]={run:function(r,o){var n=this,s=this._processParams(r);return e.FlickrPromise({apiResponse:o.callAPI("flickr.galleries.comments.getList",s),galleryInfoModelRegistry:o.getModelRegistry("gallery-info-models"),galleryCommentModelRegistry:o.getModelRegistry("gallery-comment-models"),personModelRegistry:o.getModelRegistry("person-models")}).then(function(e){return n._processResponse(e,r,o)},e.FetcherErrorLogger(t))},_processResponse:function(t,r,o){var n,s,a=t.apiResponse,l=t.galleryInfoModelRegistry,m=t.galleryCommentModelRegistry,i=t.personModelRegistry,c=[];return a.comments&&(a.comments.comment.forEach(function(t,r){var o=i.addOrUpdate(e.APIHelper.response.parsePerson({nsid:t.author,isDeleted:t.authorIsDeleted,pathAlias:t.pathAlias,username:t.authorname,realname:t.realname,isAdFree:t.isAdFree,ispro:t.ispro,proBadge:t.proBadge,iconurls:t.iconurls,location:t.location}));t.secureComment&&(n="string"==typeof t.secureComment?t.secureComment:t.secureComment.content),n||(n=t.content||t.comment),t.rawComment&&(s="string"==typeof t.rawComment?t.rawComment:t.rawComment.content),s||(s=t.content||t.comment),c.push(m.addOrUpdate({id:t.commentId,galleryId:t.galleryId,galleryOwnerId:t.galleryOwnerId,author:o,authorUsername:t.authorname,authorId:t.author,date:t.dateCreate,permalink:t.permalink,content:t.content,contentSecure:n,contentRaw:s}))}),l.getValue(r.id,"comments").concat(c),l.getValue(r.id,"comments").totalItems=parseInt(a.comments.total||0,10),l.setValue(r.id,"commentsContinuation",a.comments.continuation)),c},_processParams:function(e){return{gallery_id:e.id,page:e.page||1,per_page:e.perPage||16,secure_image_embeds:e.secureImageEmbeds||1,extras:"icon_urls, expand_bbml",sort:e.sort||"date-posted-desc",continuation:e.continuation||0}}}},"@VERSION@",{requires:["flickr-promise","api-helper","url-helper"],optional:["gallery-info-models","person-models","gallery-comment-models"]});YUI.add("flickr-galleries-editMeta-updater",function(e,r){"use strict";e.namespace("ModelUpdaters")["flickr-galleries-editMeta"]={run:function(i,t){var l={gallery_id:i.galleryId,title:i.title,description:i.description};return e.Promise.all([t.callAPI("flickr.galleries.editMeta",l),t.getModel("gallery-info-models",i.galleryId)]).then(function(e){var r=e[0],i=e[1];return i.setValues({title:r.title,description:r.description}),i},e.FetcherErrorLogger(r))}}},"@VERSION@",{requires:["flickr-promise"]});YUI.add("flickr-galleries-delete-deletor",function(e,r){"use strict";e.namespace("ModelDeletors")["flickr-galleries-delete"]={run:function(l,i){var t={gallery_id:l};return i.callAPI("flickr.galleries.delete",t).then(null,e.FetcherErrorLogger(r))}}},"@VERSION@",{requires:["flickr-promise"]});YUI.add("photo-contexts-models",function(e){function t(e){t.superclass.constructor.call(this,e),this.getMorePromises={"group-pool-models":{},"set-models":{},"gallery-models":{}},this.continuationKeys={"group-pool-models":{},"set-models":{},"gallery-models":{}}}e.Models[this.name]=t,e.extend(t,e.FlickrModelRegistry,{name:this.name,remote:{read:function(t){return this.appContext.flipper.isFlipped("enable-scrappy-photo-page")?e.ModelFetchers["flickr-photos-getAllContexts"].run(t,this.appContext):e.ModelFetchers["flickr-photos-getInfo"].run(t,this.appContext)}},getMoreContextsOfType:function(t,r,o){var s,n,i,l,a,p,u,c=this,g=e.APIHelper.request.getRebootPhotoExtras();switch(r){case"group-pool-models":s="flickr.photos.getGroups",i="groups.group",g+=","+e.APIHelper.request.getRebootGroupExtras();break;case"set-models":s="flickr.photos.getSets",i="sets.set";break;case"gallery-models":s="flickr.photos.getGalleries",i="galleries.gallery"}return s?this.exists(t)?"-1"===(l=this.continuationKeys[r][t]||"0")?e.Promise.resolve({type:r,newContexts:[],loadedAll:!0}):(n={photo_id:t,extras:g,primary_photo_extras:"url_sq, url_t, url_s, url_m",continuation:l,per_page:o},p=t+"_"+l,(u=this.getMorePromises[r][p])?u:(this.getMorePromises[r][p]=new e.FlickrPromise({apiResponse:this.appContext.callAPI(s,n,!0),contextRegistry:this.appContext.getModelRegistry(r),personRegistry:this.appContext.getModelRegistry("person-models")}).then(function(o){var s,n,l,u=[],g=o.apiResponse,d=o.contextRegistry,f=o.personRegistry;return(n=i.split(".").reduce(function(t,r){return e.Lang.isObject(t)?t[r]:void 0},g))&&(e.Array.each(n,function(t){e.APIHelper.response.addContextToRegistry(t,d,f),u.push(d.proxy(t.id))}),u.length&&(l=c.getContextsOfType(t,r).map(function(e){return e.getValue("id")}),(u=u.filter(function(e){return-1===l.indexOf(e.getValue("id"))})).length&&c.getValue(t,"contexts").appendToListMulti(u))),void 0===(a=g.continuation)?a="-1":e.Lang.isNumber(a)&&(a+=""),s="-1"===a,c.continuationKeys[r][t]=a,delete c.getMorePromises[r][p],{type:r,newContexts:u,loadedAll:s}}),this.getMorePromises[r][p])):e.Promise.reject("[photo-contexts-models] getMoreContextsOfType was called for an ID that isn't in the registry: "+t):e.Promise.reject("[photo-contexts-models] getMoreContextsOfType was called without an invalid type: "+r)},getContextsOfType:function(t,r){return r=e.Array(r),this.getValue(t,"contexts").getList().filter(function(e){return r.indexOf(e.registry.name)>-1})},getContextsNotOfType:function(t,r){return r=e.Array(r),this.getValue(t,"contexts").getList().filter(function(e){return-1===r.indexOf(e.registry.name)})},attributes:{contexts:{isCollection:!0},totalGroups:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0},totalSets:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0},totalGalleries:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0}}})},"@VERSION@",{requires:["api-helper","flickr-model-registry","flickr-promise","flickr-photos-getInfo-fetcher","flickr-photos-getAllContexts-fetcher"]});YUI.add("flickr-favorites-getContext-fetcher",function(e,o){"use strict";e.namespace("ListFetchers")["flickr-favorites-getContext"]={run:function(t,s){var r=this;return e.Promise.all([s.callAPI("flickr.favorites.getContext",this._processParams(t),!0),s.getModelRegistry("favorite-models"),s.getModelRegistry("photo-models"),s.getModelRegistry("person-models"),s.getModelRegistry("photo-engagement-models"),s.getModelRegistry("photo-stats-models")]).then(function(e){return r._processResponse(e,t)},function(e){throw 3===e.code&&"Photo not a favorite"===e.message&&(e.notInContext=!0),e}).then(null,e.FetcherErrorLogger(o))},_processParams:function(o){var t={photo_id:o.photoId,num_prev:o.numNext,num_next:o.numPrev,extras:e.APIHelper.request.getRebootPhotoExtras()};return o.id?t.user_id=o.id:t.path_alias=o.pathAlias,t},_processResponse:function(o,t){var s,r,n,a,p,i,l=o[0],h=o[1],d=o[2],g=o[3],u=o[4],m=o[5],c=[],x=[],y=d.proxy(t.photoId),M=[];return s=l.prevphotos,r=l.nextphotos,x=e.APIHelper.response.parsePhotos({photos:s.photo,personModelRegistry:g,photoModelRegistry:d,photoEngagementModelRegistry:u,photoStatsModelRegistry:m}),c=e.APIHelper.response.parsePhotos({photos:r.photo,personModelRegistry:g,photoModelRegistry:d,photoEngagementModelRegistry:u,photoStatsModelRegistry:m}),i=h.getValue(t.id,"photoContextList"),a=!!i.hasMinBoundary&&i.hasMinBoundary(),p=!!i.hasMaxBoundary&&i.hasMaxBoundary(),n=i.getList(),M=e.APIHelper.response.addOrReplaceListByContext({model:y,next:x,prev:c.reverse(),hasMax:p,hasMin:a,current:n,numNext:t.numNext,numPrev:t.numPrev}),h.setValue(t.id,"photoContextList",M),{next:x,previous:c.reverse()}}}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["favorite-models","photo-models","person-models","photo-engagement-models","photo-stats-models"]});