YUI.add("flickr-galleries-comments-deleteComment-deletor",(function(e,o){"use strict";e.namespace("ModelDeletors")["flickr-galleries-comments-deleteComment"]={run:function(t,r){var l=this;return e.Promise.all([r.callAPI("flickr.galleries.comments.deleteComment",this._processParams(t)),r.getModel("gallery-info-models",t.galleryId)]).then((function(e){l._processResponse(e,t,r)}),e.FetcherErrorLogger(o))},_processParams:function(e){return{comment_id:e.commentId,gallery_id:e.galleryId,owner_id:e.ownerId}},_processResponse:function(e,o,t){e[0];var r=e[1];r.getValue("comments").removeFromList(o.commentId),r.getValue("comments").totalItems--,r.setValue("commentCount",r.getValue("commentCount")-1)}}}),"@VERSION@",{requires:["flickr-promise"],optional:[]});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, use_text_for_links, bbml_need_all_photo_sizes"}},_processResponse:function(e,t,n){var o,r,m=e[0].comment||{content:""},s=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),s.setValues({content:t.content,contentSecure:o,contentRaw:r}),s}}}),"@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=[],d=parseInt(a.comments.total||0,10);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}))})),0===l.getValue(r.id,"comments").size()&&(l.getValue(r.id,"comments").totalItems=d>0?d:c.length),l.getValue(r.id,"comments").concat(c),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, use_text_for_links, bbml_need_all_photo_sizes",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"]});