YUI.add("flickr-groups-pools-remove-deletor",(function(o,e){"use strict";o.namespace("ModelDeletors")["flickr-groups-pools-remove"]={run:function(t,r){var s,l,p=this,d=t.registryName||"group-pool-models",i=[];return t.photoID?t.photoIds=[t.photoID]:t.photoIds="string"==typeof t.photoIds?[t.photoIds]:t.photoIds,s=this._processParams(t),l={apiResponse:r.callAPI("flickr.groups.pools.remove",s),groupPoolModelRegistry:r.getModel(d,t.groupID),photoGroupsModelRegistry:r.getModelRegistry("photo-groups-models"),photoContextsModelRegistry:r.getModelRegistry("photo-contexts-models")},t.photoIds.forEach((function(o){i.push(r.getModel("photo-models",o))})),l.photoModels=o.Promise.all(i),t.unfilteredGroupId=s.group_id,"group-pool-models"!==d&&(l.unfilteredGroupPoolModelRegistry=r.getModel("group-pool-models",t.unfilteredGroupId)),new o.FlickrPromise(l).then((function(o){return p._processResponse(o,t)}),o.FetcherErrorLogger(e))},_processParams:function(e){return{photo_id:e.photoIds.join(","),group_id:o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID)}},_processResponse:function(o,e){var t=o.apiResponse,r=o.groupPoolModelRegistry,s=o.photoModels,l=o.photoGroupsModelRegistry,p=o.photoContextsModelRegistry,d=o.unfilteredGroupPoolModelRegistry;if("ok"===t.stat)return s.forEach((function(o){p.exists(o.id)&&p.getValue(o.id,"contexts").getFromListByID(e.unfilteredGroupId)&&(p.setValue(o.id,"totalGroups",p.getValue(o.id,"totalGroups")-1),p.getValue(o.id,"contexts").removeFromList(e.unfilteredGroupId)),l.exists(o.id)&&l.getValue(o.id,"groups").getFromListByID(e.unfilteredGroupId)&&(l.setValue(o.id,"total",l.getValue(o.id,"total")-1),l.getValue(o.id,"groups").removeFromList(e.unfilteredGroupId)),r&&r.hasPhoto(o.getValue("id"))&&r.removePhotoLocal(o),d&&d.hasPhoto(o.getValue("id"))&&d.removePhotoLocal(o)})),r}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});YUI.add("flickr-groups-invite-photo-invite-creator",(function(o,t){"use strict";o.namespace("ModelCreators")["flickr-groups-invite-photo-invite"]={run:function(e,i){var r={},p=o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID);return r.photo_id=e.photoID,r.group_id=p,o.Promise.all([i.callAPI("flickr.groups.invite.photo.invite",r),i.getModel("group-pool-models",p),i.getModelRegistry("photo-group-invitation-models"),i.getModelRegistry("photo-group-invitations-models")]).then((function(t){var r,n,l,u=t[0],s=t[1],g=t[2],d=t[3];if("ok"===u.stat){if(n={id:r=[e.photoID,p].join("-"),photoId:e.photoID,groupId:p,invitedBy:i.getViewer().nsid},l=g.exists(r)?g.proxy(r):g.add(n),d.exists(e.photoID)&&!d.getValue(e.photoID,"invitations").getFromListByID(r)&&(d.getValue(e.photoID,"groups").prependToList(s),d.getValue(e.photoID,"invitations").prependToList(l),d.setValue(e.photoID,"total",d.getValue(e.photoID,"total")+1)),o.Snowplough){var a={id:p},h=[];h=h.concat(o.Snowplough.getGroupContext(a)),i.getModel("photo-models",e.photoID).then(function(t){o.Snowplough.sendStructuredEvent({category:"group",action:"invite_photo"},h.concat(o.Snowplough.getPhotoContextFromModel(t)))}.bind(this))}return s}}),o.FetcherErrorLogger(t))}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});YUI.add("flickr-groups-invite-photo-cancel-deletor",(function(o,t){"use strict";o.namespace("ModelDeletors")["flickr-groups-invite-photo-cancel"]={run:function(e,r){var i={},l=o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID);return i.photo_id=e.photoID,i.group_id=l,o.Promise.all([r.callAPI("flickr.groups.invite.photo.cancel",i),r.getModel("group-pool-models",l),r.getModelRegistry("photo-group-invitation-models"),r.getModelRegistry("photo-group-invitations-models")]).then((function(o){var t,r=o[0],i=o[1],p=o[2],s=o[3];if("ok"===r.stat)return t=[e.photoID,l].join("-"),s.exists(e.photoID)&&s.getValue(e.photoID,"invitations").getFromListByID(t)&&(s.setValue(e.photoID,"total",s.getValue(e.photoID,"total")-1),s.getValue(e.photoID,"groups").removeFromList(l),s.getValue(e.photoID,"invitations").removeFromList(t)),p.remove(t),i}),o.FetcherErrorLogger(t))}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});YUI.add("group-pool-by-person-models",(function(e){function o(e){o.superclass.constructor.call(this,e)}e.Models[this.name]=o,e.extend(o,e.Models["group-pool-models"],{name:this.name,attributes:e.merge(e.Models["group-pool-models"].prototype.attributes,{personFilter:{validator:function(o,r){return e.AttributeHelpers.validateString(o)},setter:function(o){return e.AttributeHelpers.coerceString(o)},defaultValue:null}})})}),"@VERSION@",{requires:["attribute-helpers","group-pool-models","flickr-groups-pools-getPhotos-fetcher","flickr-groups-pools-add-creator","flickr-groups-pools-remove-deletor","flickr-groups-invite-photo-invite-creator","flickr-groups-invite-photo-cancel-deletor"]});YUI.add("group-pool-by-tag-models",(function(t){function e(t){e.superclass.constructor.call(this,t)}t.Models[this.name]=e,t.extend(e,t.Models["group-pool-models"],{name:this.name,attributes:{tagFilter:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)},defaultValue:null}}})}),"@VERSION@",{requires:["attribute-helpers"]});YUI.add("flickr-groups-pools-getPhotos-fetcher",(function(o,e){"use strict";o.namespace("ListFetchers")["flickr-groups-pools-getPhotos"]={run:function(t,r){var s=this,p=this._processParams(t),l={apiResponse:r.callAPI("flickr.groups.pools.getPhotos",p,!0),photoModelRegistry:r.getModelRegistry("photo-models"),personModelRegistry:r.getModelRegistry("person-models"),groupPoolModelRegistry:r.getModelRegistry("group-pool-models"),photoEngagementModelRegistry:r.getModelRegistry("photo-engagement-models"),photoStatsModelRegistry:r.getModelRegistry("photo-stats-models"),groupModelRegistry:r.getModelRegistry("group-models")};return t.personFilter&&(l.groupPoolByPersonModelRegistry=r.getModelRegistry("group-pool-by-person-models")),t.tagFilter&&(l.groupPoolByTagModelRegistry=r.getModelRegistry("group-pool-by-tag-models")),new o.FlickrPromise(l).then((function(o){return s._processResponse(o,t)}),o.FetcherErrorLogger(e))},_processParams:function(e){var t={extras:o.APIHelper.request.getRebootPhotoExtras()+","+o.APIHelper.request.getRebootGroupExtras(),per_page:e.perPage||20,page:e.page||1,get_group_info:1};if(e.id)t.group_id=o.Models["group-pool-models"].extractGroupFromCompoundId(e.id);else{if(!e.pathAlias)throw new Error("[flickr-groups-pools-getPhotos-fetcher] `id` or `pathAlias` is required.");t.group_path_alias=e.pathAlias}return e.withPhotoId&&(t.jump_to=e.withPhotoId),e.privacyFilter&&(t.privacy_filter=e.privacyFilter),e.safeSearch&&(t.safe_search=e.safeSearch),e.media&&(t.media=e.media),e.personFilter&&(t.user_id=e.personFilter),e.tagFilter&&(t.tags=e.tagFilter),t},_processResponse:function(e,t){var r,s,p,l,i=e.apiResponse,g=e.photoModelRegistry,a=e.personModelRegistry,d=e.groupPoolModelRegistry,u=e.groupPoolByPersonModelRegistry,n=e.groupPoolByTagModelRegistry,h=e.photoEngagementModelRegistry,m=e.photoStatsModelRegistry,y=e.groupModelRegistry;return i.group.pathAlias=""===i.group.pathalias?null:i.group.pathalias,r=y.parseGroupModel(i.group.nsid,i.group.pathAlias,i.group),y.addOrUpdate(r),s={pathAlias:i.group.pathAlias,group:y.proxy(r.id),filteredPoolCount:i.group.poolCount},p=o.APIHelper.response.parsePhotos({photos:i.photos.photo,personModelRegistry:a,photoModelRegistry:g,photoEngagementModelRegistry:h,photoStatsModelRegistry:m}),s.photoPageList={perPage:i.photos.perpage,page:i.photos.page,pageContent:p,totalItems:s.filteredPoolCount},t.personFilter?(s.id=o.Models["group-pool-models"].buildCompoundId(i.group.nsid,t.personFilter),s.personFilter=t.personFilter,s.filteredPoolCount=s.photoPageList.totalItems=i.photos.total,l=u):t.tagFilter?(s.id=o.Models["group-pool-models"].buildCompoundId(i.group.nsid,t.tagFilter),s.tagFilter=t.tagFilter,s.filteredPoolCount=s.photoPageList.totalItems=i.photos.total,l=n):(t.id&&t.id!==i.group.nsid?s.id=t.id:s.id=i.group.nsid,l=d),l.exists(s.id)?(l.setValue(s.id,"photoPageList",s.photoPageList),l.setValue(s.id,"group",s.group),l.setValue(s.id,"pathAlias",s.pathAlias),l.setValue(s.id,"filteredPoolCount",parseInt(s.filteredPoolCount,10)||0),s.group.setValue("poolCount",parseInt(i.group.poolCount,10)||0)):l.add(s),p}}}),"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-models","person-models","photo-engagement-models","photo-stats-models","group-models","group-pool-models","group-pool-by-person-models","group-pool-by-tag-models"]});