YUI.add("flickr-photosets-setPrimaryPhoto-updater",function(r,t){"use strict";r.namespace("ModelUpdaters")["flickr-photosets-setPrimaryPhoto"]={run:function(o,e){var s={};return s.photoset_id=o.albumId,s.photo_id=o.photoId,e.callAPI("flickr.photosets.setPrimaryPhoto",s).then(null,r.FetcherErrorLogger(t))}}},"@VERSION@",{requires:["flickr-promise"]});YUI.add("set-models",function(e,t){function o(e){o.superclass.constructor.call(this,e)}var r=require("hermes-core/flog")(t);e.Models[this.name]=o,e.extend(o,e.FlickrModelRegistry,{langBundles:this.details.langBundles,name:this.name,remote:{read:function(t){return e.ListFetchers["flickr-photosets-getPhotos"].run(t,this.appContext)},create:function(t,o){return e.ModelCreators["flickr-photosets-create"].run(t,o)},createHidden:function(t,o){return e.ModelCreators["flickr-photosets-createHidden"].run(t,o)},addPhoto:function(t,o){return e.ModelCreators["flickr-photosets-addPhoto"].run(t,o)},removePhoto:function(t,o){return e.ModelCreators["flickr-photosets-removePhoto"].run(t,o)},update:function(t,o){return e.ModelUpdaters["flickr-photosets-editMeta"].run({photosetId:t,title:o.title?o.title.newVal:this.getValue(t,"title"),description:o.description?o.description.newVal:this.getValue(t,"description")},this.appContext)},setPrimaryPhoto:function(t,o){return e.ModelUpdaters["flickr-photosets-setPrimaryPhoto"].run(t,o)},delete:function(t){if("string"==typeof t){t={setID:t}}return e.ModelDeletors["flickr-photosets-delete-deletor"].run(t,this.appContext)}},addPhoto:function(e,t){return this.getValue(e,"photoPageList").hasMaxBoundary()&&this.getValue(e,"photoPageList").appendToList(t),this.getValue(e,"photoContextList").hasMaxBoundary()&&this.getValue(e,"photoContextList").appendToList(t),this},removePhoto:function(e,t){return this.getValue(e,"photoPageList").removeFromList(t.getValue("id")),this.getValue(e,"photoContextList").removeFromList(t.getValue("id")),this},hasPhoto:function(e,t){return this.getValue(e,"photoPageList").getFromListByID(t)||this.getValue(e,"photoContextList").getFromListByID(t)},getSizeToFit:function(t,o,i){r.info("Using `getSizeToFit` is deprecated. See model comments for more details.");var n=e.PhotoModelHelper.getSizeToFit(t,o,e.merge({sizes:this.getValue(t,"primaryPhotoSizes"),includeSquare:!0,cropToFit:!0},i));return n&&(n.url=n.src),n},getLargestPrimaryPhotoSize:function(t,o){return e.PhotoModelHelper.getLargestSize(t,o)},attributes:{normalizedId:{readOnly:!0,defaultFn:function(e){return e.split("-")[0]}},displayType:{readOnly:!0,defaultFn:function(){return"set"}},title:{validator:function(t,o){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)},defaultValue:""},description:{validator:function(t,o){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)},defaultValue:""},owner:{isModel:!0},isOwner:e.PhotoModelHelper.attributes.isOwner,photoPageList:{isCollection:!0,pageFetch:{listFetcher:e.ListFetchers["flickr-photosets-getPhotos"]}},photoContextList:{isListProxy:!0,contextFetch:{listFetcher:e.ListFetchers["flickr-photosets-getContext"],listItemIdField:"photoId"}},photoCount:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},videoCount:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},publicPhotosCount:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},totalCount:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultFn:function(e){return this.getValue(e,"photoCount")+this.getValue(e,"videoCount")}},viewCount:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},photoCountDisplay:{readOnly:!0,derivedBy:["totalCount"],defaultFn:function(e){var t=this.getValue(e,"photoCount"),o=this.getValue(e,"videoCount"),r=this.getValue(e,"totalCount"),i="";return 0===(t-=o)&&0===o?i=this.intlMessage({intlName:"models.ZERO_PHOTOS"}):1===t&&0===o?i=this.intlMessage({intlName:"models.ONE_PHOTO"}):t>1&&0===o?i=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS",photos:t}):0===t&&1===o?i=this.intlMessage({intlName:"models.ONE_VIDEO"}):1===t&&1===o?i=this.intlMessage({intlName:"models.ONE_PHOTO_AND_ONE_VIDEO"}):t>1&&1===o?i=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS_AND_ONE_VIDEO",photos:t}):0===t&&o>1?i=this.intlMessage({intlName:"models.MULTIPLE_VIDEOS",videos:o}):1===t&&o>1?i=this.intlMessage({intlName:"models.ONE_PHOTO_AND_MULTIPLE_VIDEOS",videos:o}):t>1&&o>1&&(i=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS_AND_MULTIPLE_VIDEOS",photos:t,videos:o})),0===r?i=this.intlMessage({intlName:"models.ZERO_ITEMS"}):1===r?i=this.intlMessage({intlName:"models.ONE_ITEM"}):r>1&&(i=this.intlMessage({intlName:"models.MULTIPLE_ITEMS",items:r})),i}},photoAndVideosDisplay:{readOnly:!0,derivedBy:["photoCount","videoCount"],defaultFn:function(e){var t=this.getValue(e,"photoCount"),o=this.getValue(e,"videoCount"),r="";return 0===t&&0===o?r=this.intlMessage({intlName:"models.ZERO_PHOTOS"}):1===t&&0===o?r=this.intlMessage({intlName:"models.ONE_PHOTO"}):t>1&&0===o?r=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS",photos:t}):0===t&&1===o?r=this.intlMessage({intlName:"models.ONE_VIDEO"}):1===t&&1===o?r=this.intlMessage({intlName:"models.ONE_PHOTO_AND_ONE_VIDEO"}):t>1&&1===o?r=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS_AND_ONE_VIDEO",photos:t}):0===t&&o>1?r=this.intlMessage({intlName:"models.MULTIPLE_VIDEOS",videos:o}):1===t&&o>1?r=this.intlMessage({intlName:"models.ONE_PHOTO_AND_MULTIPLE_VIDEOS",videos:o}):t>1&&o>1&&(r=this.intlMessage({intlName:"models.MULTIPLE_PHOTOS_AND_MULTIPLE_VIDEOS",photos:t,videos:o})),r}},sharedEntityDisplay:{readOnly:!0,derivedBy:["videoCount","photoCount"],defaultFn:function(e){var t=this.getValue(e,"photoCount"),o=this.getValue(e,"videoCount"),r=this.getValue(e,"owner"),i="";return t&&!o?i=this.intlMessage({intlName:"shared-entity.USERNAME_HAS_SHARED_PHOTOS_ONLY",username:r.getValue("displayname"),photoCount:parseInt(t,10)}):!t&&o?i=this.intlMessage({intlName:"shared-entity.USERNAME_HAS_SHARED_VIDEOS_ONLY",username:r.getValue("displayname"),videoCount:parseInt(o,10)}):t&&o&&(i=this.intlMessage({intlName:"shared-entity.USERNAME_HAS_SHARED_PHOTOS_VIDEOS",username:r.getValue("displayname"),photoCount:parseInt(t,10),videoCount:parseInt(o,10)})),i}},primary:{},primaryPhotoSizes:{},primaryNeedsInterstitial:{},bestIconURL:{readOnly:!0,derivedBy:["primaryPhotoSizes"],defaultFn:function(t){var o=e.PhotoModelHelper.getSizeToFit(t,{height:75,width:75},e.merge({sizes:this.getValue(t,"primaryPhotoSizes"),includeSquare:!0,cropToFit:!0}));return o?o.src:""}},url:{readOnly:!0,derivedBy:["owner","normalizedId"],defaultFn:function(e){var t=this.getValue(e,"owner"),o=this.getValue(e,"isSharedEntity"),r=this.getValue(e,"normalizedId");return t&&!0===o?"/photos/"+t.getValue("pathAlias")+"/shares/"+r:t?"/photos/"+t.getValue("pathAlias")+"/albums/"+r:void 0}},isAutoUploadSet:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},isSharedEntity:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},canShare:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0},canDownload:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},urlSuffix:{readOnly:!0,defaultFn:function(e){return this.getValue(e,"isSharedEntity")?"shares-"+e:"album-"+e}},gpCode:{defaultFn:function(e){return null}},gpOwner:{defaultFn:function(e){return null}}}},{buildCompoundId:function(e,t,o){var r=e;return t&&(r+="-"+t),o&&(t||(r+="-dateposted"),r+="-"+o),r},splitCompoundId:function(e){var t=e.split("-");return{nsid:t[0],orderBy:t[1],viewAs:t[2]}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-photosets-addPhoto-creator","flickr-photosets-removePhoto-deletor","flickr-photosets-delete-deletor","flickr-photosets-getPhotos-fetcher","flickr-photosets-getContext-fetcher","flickr-photosets-create-creator","flickr-photosets-createHidden-creator","flickr-photosets-editMeta-updater","flickr-photosets-setPrimaryPhoto-updater","photo-model-helper"],langBundles:["models","shared-entity"]});YUI.add("photo-groups-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:{read:function(t){return e.ModelFetchers["flickr-photos-getAllContexts"].run(t,this.appContext)}},attributes:{id:{},groups:{isCollection:!0},total:{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-getAllContexts-fetcher"]});YUI.add("flickr-photos-getAllContexts-fetcher",function(e,t){"use strict";e.namespace("ModelFetchers")["flickr-photos-getAllContexts"]={run:function(o,s){var l=this;return s.flipper.isFlipped("enable-scrappy-photo-page")&&(o.scrappy=!0),e.Promise.all([s.callAPI("flickr.photos.getAllContexts",this._processParams(o),!0),s.getModelRegistry("person-models"),s.getModelRegistry("photo-contexts-models"),s.getModelRegistry("favorite-models"),s.getModelRegistry("gallery-models"),s.getModelRegistry("group-pool-models"),s.getModelRegistry("set-models"),s.getModelRegistry("photostream-models"),s.getModelRegistry("photo-groups-models"),s.getModelRegistry("photo-sets-models"),s.getModelRegistry("photo-galleries-models"),s.getModelRegistry("group-models")]).then(function(e){return l._processResponse(e,o)},e.FetcherErrorLogger(t))},_processParams:function(t){var o;return o={photo_id:t.id,extras:e.APIHelper.request.getRebootPhotoExtras()+","+e.APIHelper.request.getRebootGroupExtras()+","+e.APIHelper.request.getRebootAlbumsListExtras(),primary_photo_extras:"url_sq, url_t, url_s, url_m, needs_interstitial"},t.scrappy&&(o.get_all_galleries=1,o.no_faves_context=1,o.per_type_limit=6,o.get_totals=1,o.sort="date-desc"),o},_processResponse:function(t,o){var s,l,r=t[0],a=t[1],p=t[2],d={},i=[],g=t[8],n=t[9],u=t[10],m=t[11];return d.faves=t[3],d.gallery=t[4],d.pool=t[5],d.set=t[6],d.stream=t[7],e.Object.each(d,function(t,o){r[o]&&e.Array.each(r[o],function(o){e.APIHelper.response.addContextToRegistry(o,t,a,m),i.push(t.proxy(o.id))})}),p.exists(o.id)||(s=p.add({id:o.id,totalGroups:r.totals&&r.totals.groups,totalSets:r.totals&&r.totals.sets,totalGalleries:r.totals&&r.totals.galleries}),p.setValue(o.id,"contexts",i)),g.addOrUpdate({id:o.id,total:r.totals&&r.totals.groups,groups:p.getContextsOfType(o.id,"group-pool-models")}),(l=p.getContextsOfType(o.id,"set-models")).forEach(function(e){e.setValue("totalCount",parseInt(e.getValue("photoCount"),10)+parseInt(e.getValue("videoCount"),10))}),n.addOrUpdate({id:o.id,total:r.totals&&r.totals.sets,sets:l}),u.addOrUpdate({id:o.id,total:r.totals&&r.totals.galleries,galleries:p.getContextsOfType(o.id,"gallery-models")}),s}}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-contexts-models","favorite-models","gallery-models","group-pool-models","photostream-models","set-models","photo-groups-models","photo-sets-models","photo-galleries-models","group-models"]});YUI.add("photo-galleries-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:{read:function(t){return e.ModelFetchers["flickr-photos-getAllContexts"].run(t,this.appContext)}},attributes:{id:{},galleries:{isListProxy:!0},total:{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-getAllContexts-fetcher"]});YUI.add("gallery-photo-association-models",function(t){function e(t){e.superclass.constructor.call(this,t)}t.Models[this.name]=e,t.extend(e,t.FlickrModelRegistry,{langBundles:this.details.langBundles,name:this.name,attributes:{id:{validator:function(e){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},galleryId:{validator:function(e){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},photoId:{validator:function(e){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}}}})},"@VERSION@",{requires:["flickr-model-registry"],langBundles:["models"]});YUI.add("flickr-galleries-removePhoto-deletor",function(o,e){"use strict";o.namespace("ModelDeletors")["flickr-galleries-removePhoto"]={run:function(t,l){var s={full_response:1},r=t.galleryCompoundID?t.galleryCompoundID.split("-").pop():t.galleryID;return s.photo_id=t.photoID,s.gallery_id=r,o.Promise.all([l.callAPI("flickr.galleries.removePhoto",s),l.getModel("gallery-models",r),l.getModel("photo-models",t.photoID),l.getModelRegistry("photo-galleries-models"),l.getModelRegistry("photo-contexts-models"),l.getModelRegistry("gallery-info-models"),l.getModelRegistry("gallery-photo-association-models")]).then(function(o){var e,l=o[0],s=o[1],a=o[2],i=o[3],u=o[4],g=o[5],h=o[6];if("ok"===l.stat)return e=l.gallery,s&&(s.hasPhoto(a.getValue("id"))&&s.removePhoto(a),s.setValue("photoCount",e.countPhotos),s.setValue("videoCount",e.countVideos),s.getValue("photoCount")+s.getValue("videoCount")===0&&(s.setValue("primary",null),s.setValue("primaryPhotoSizes",{}))),g.exists(r)&&g.hasPhoto(r,a.getValue("id"))&&(g.getValue(r,"photoList").removeFromList(a.getValue("id")),g.setValue(r,"photoCount",e.countPhotos),g.setValue(r,"videoCount",e.countVideos),g.getValue(r,"photoList").totalItems=e.countPhotos+e.countVideos||0,g.setValue(r,"primaryPhotoId",e.primaryPhotoId),g.setValue(r,"currentState",e.current_state)),u.exists(t.photoID)&&u.getValue(t.photoID,"contexts").getFromListByID(r)&&(u.setValue(t.photoID,"totalGalleries",u.getValue(t.photoID,"totalGalleries")-1),u.getValue(t.photoID,"contexts").removeFromList(r)),i.exists(t.photoID)&&i.getValue(t.photoID,"galleries").getFromListByID(r)&&(i.setValue(t.photoID,"total",i.getValue(t.photoID,"total")-1),i.getValue(t.photoID,"galleries").removeFromList(r)),h.exists(r+"-"+t.photoID)&&h.remove(r+"-"+t.photoID),s},o.FetcherErrorLogger(e))}}},"@VERSION@",{requires:["flickr-promise"],optional:["gallery-models","photo-models","photo-galleries-models","photo-contexts-models","gallery-info-models","gallery-photo-association-models"]});