function embedRun(n,t){var i=t.get("easyzoom.Culture")||"en";n.setCurrentLanguage(i);n.loadRemote("/Scripts/app/lang/"+i+".json")}function HttpService(n){var t=function(t,i,r,u){var f={headers:i};return n.get(t,f).then(function(n){typeof r=="function"&&r(n.data,n.status)},function(n){typeof u=="function"&&u(n.data||"Request failed",n.status)})},i=function(n){return t("/api/dictionary/languages",{},n)},r=function(n,i,r){return t("/api/image/"+n,{},i,r)},u=function(n,i,r){return t("/api/image/urlaccess/"+n,{},i,r)},f=function(n,i,r,u){return t("/api/image/"+n+"/albumKey/"+i,{},r,u)},e=function(n,i,r,u){return t("/api/image/"+n+"/comment",{"Grant-Code":i},r,u)},o=function(n,i){return t("/api/dictionary/annotationtype",{},n,i)};return{LoadLanguages:i,GetImageInformation:r,GetImageInformationByAccessCode:u,GetImageInformationByAlbumAccessCode:f,GetComments:e,LoadAnnotationTypes:o}}function ZoomableImageController(n,t,i,r,u,f,e,o){function y(n,t){h(n,t)}function h(n,t){typeof t!="undefined"&&(s.modelIndex=t);s.positionIndex=n;console.log("Image-Model: "+s.modelIndex+", Position: "+s.positionIndex)}function p(){s.share.shareLink=ft(s.model);s.share.shareSubject=u.getString("ShareByEmailSubjectImage");s.share.shareBody=yt(u.getString("ShareImageByEmailBody"),s.model.imageData.Title,s.share.shareLink)}function w(n){var t=s.modelIndex+1,i={containerId:"mapContainer"+t,url:n.TilesDataSourceUrl,height:n.Height,width:n.Width,tileSize:n.TileSize,onePixelPyramid:n.TileDataSourceType===3,initialRotation:n.Orientation,enableAnnotating:!0,popupContainerId:"popupContainer"+t,annotationTypes:s.annotationTypes,onAnnotationClicked:function(n){s.updatePopup(n)},onPopupShown:function(){$("#annotationTextValue").focus()},onPopupHidden:function(){},overviewControl:!0,overviewControlCollapsed:!1,extraZoomEnabled:o.get("extraZoomEnabled"),onResolutionChanged:function(){e(function(){var n=s.model.zoomableImage.getView();s.state.maxZoomReached=n.getZoom()>=n.getMaxZoom()})}};return b(i),i}function b(n){var t=document.getElementById(n.containerId).offsetWidth,i=document.getElementById(n.containerId).offsetHeight;t>i?n.adaptInitialZoomByHeight=i-50:n.adaptInitialZoomByWidth=t-50}function k(n,t){t.IsMicroscopeSlide&&(n.annotationOverlayCssClass=null,t.MicronsPerPixel&&(n.scaleLineControl=!0,n.metersPerPixel=t.MicronsPerPixel/1e6))}function d(t){n.$apply(function(){t.userDefined===null&&(t.userDefined={annotationText:"",commentId:-1});s.activeAnnotation=t})}function g(){s.model.zoomableImage.zoomin()}function nt(){s.model.zoomableImage.zoomout()}function tt(){s.state.extraZoomEnabled?(s.model.zoomableImage.disableExtraZoom(),s.state.extraZoomEnabled=!1,o.remove("extraZoomEnabled")):(s.model.zoomableImage.enableExtraZoom(),s.state.extraZoomEnabled=!0,o.put("extraZoomEnabled",!0));s.state.maxZoomReached=s.model.zoomableImage.getView().getZoom()>=s.model.zoomableImage.getView().getMaxZoom()}function it(){s.state.filterPopup=!s.state.filterPopup;s.model.zoomableImage.hidePopup()}function rt(){s.model.zoomableImage.hidePopup();s.state.annotating=!1;s.state.editMode=!1}function ut(){s.state.share=!s.state.share}function ft(n){var i=location.protocol+"//"+location.host,t="";return t=n.id&&n.albumAccessCode?"/embed/"+n.id+"?albumAccessKey="+n.albumAccessCode.replace(/-/g,""):n.accessCode?"/imageaccess/"+n.accessCode.replace(/-/g,""):"/image/"+n.id,i+t}function et(){var r=[],i,n,t;if(s.annotationCount=0,s.model.imageData.Id>0&&s.model.imageData.Comments!==null&&s.model.imageData.Comments.length>0)for(i=0;i<s.model.imageData.Comments.length;i++)n=s.model.imageData.Comments[i],n.HasAnnotation&&(s.annotationCount++,t=n.Annotation,r.push({geometry:t.GeometryType,coord:t.Geometry,typeId:ct(t.GeometryType,t.PinTypeId),userDefined:{annotationText:n.Text,isCurrentUserCanEditIt:n.IsCurrentUserCanEditIt,isCurrentUserCanDeleteIt:n.IsCurrentUserCanDeleteIt,isBelongsToImageOwner:s.model.imageData.OwnerId===n.UserId,commentId:n.Id,userId:n.UserId,userName:n.UserName,attachments:n.Attachments,link:n.Link,meta:n.LinkMeta}}));return r}function ot(n){switch(n){case"none":s.model.zoomableImage.hideAllAnnotations();break;case"owner":s.model.zoomableImage.showAnnotationsOnlyWithUserDefinedProperty({isBelongsToImageOwner:!0});break;case"all":s.model.zoomableImage.showAllAnnotations()}s.state.filterPopup=!1;s.state.filtered=n}function st(){s.state.filterPopup=!1;s.state.annotationList=!1}function ht(n){for(var i,r={},t=0;t<n.length;t++)i="/Content/img/icon/annos/"+n[t].Value,s.annotationTypes.push({id:n[t].Key,type:"image",imageSrc:i,properties:{anchor:v[n[t].Key]}}),r[n[t].Key]=i;s.annotationTypes.push({id:c,type:"circle",properties:{fillColor:[255,255,255,.5],strokeColor:"#30a3f1",strokeWidth:2}});s.annotationTypes.push({id:l,type:"polygon",properties:{fillColor:[255,255,255,.5],strokeColor:"#30a3f1",strokeWidth:2}})}function ct(n,t){switch(n){case"image":return t;case"circle":return c;case"polygon":return l}}function lt(n,t){window.parent.postMessage(n,t)}function at(){window.addEventListener("message",vt)}function vt(t){var i=t.data,u,f,r;if(typeof i!="undefined"&&i!==null){(typeof i.imageIndex=="undefined"||i.imageIndex===null)&&(i.imageIndex=0);switch(i.type){case"bind":n.$parent.embedVm.bindImage(s.model.zoomableImage,s.modelIndex===0);return;case"unbind":s.model.zoomableImage.unBind();return}if(u=parseInt(i.imageIndex),f=parseInt(s.positionIndex),u===f)switch(i.type){case"zoomin":s.model.zoomableImage.zoomin();break;case"zoomout":s.model.zoomableImage.zoomout();break;case"expand":s.model.expanded=!s.model.expanded;document.getElementById("body").click();setTimeout(function(){s.model.zoomableImage.updateSize()},100);break;case"zoomAnno":a(i.annoId);break;case"showImages":r=i.positions.indexOf(s.modelIndex);r===-1&&(r=null);s.positionIndex=r}}}function yt(){for(var i,t=arguments[0],n=0;n<arguments.length-1;n++)i=new RegExp("\\{"+n+"\\}","gm"),t=t.replace(i,arguments[n+1]);return t}function pt(n){s.state.share=!1;f.showModal({templateUrl:"/Ng/Embed/QRCode",controller:"QRModalController",controllerAs:"vm",inputs:{url:n}}).then(function(n){n.element.modal()})}function a(n){s.model.zoomableImage.getAnnotator().zoomToAnnotationWithUserDefinedProperty({commentId:n})}function wt(){s.state.showAnnoListButtonWasPressedFirstTime?s.state.showAnnoList=!s.state.showAnnoList:(s.state.showAnnoList=!0,s.state.showAnnoListButtonWasPressedFirstTime=!0)}var c=300,l=400,v={1:[11,27],2:[11,27],3:[11,27],4:[11,27],5:[11,27],6:[11,27],7:null,8:null,9:null,10:null,11:null,12:null,13:null,14:null,15:null,16:null,17:null,18:[1,26],19:[2,25],20:[2,25],21:[2,23],22:[2,25],23:[2,25]},s=this;s.activeAnnotation=null;s.annotationTypes=[];s.annotationCount=0;s.state={loading:!0,filterPopup:!1,filtered:"all",annotationSelect:!1,share:!1,link:!1,showAnnos:!0,showAnnoList:!1,showAnnoListButtonWasPressedFirstTime:!1,extraZoomEnabled:o.get("extraZoomEnabled")};s.share={shareSubject:"",shareBody:"",shareLink:""};s.model=null;s.modelIndex=null;s.positionIndex=null;s.annos=null;s.init=y;s.setIndex=h;s.updatePopup=d;s.zoomin=g;s.zoomout=nt;s.toggleExtraZoom=tt;s.toggleFilter=it;s.togglePopup=rt;s.toggleShare=ut;s.hidePopups=st;s.filterAnnotations=ot;s.showQRCode=pt;s.zoomToAnnotation=a;s.toogleAnnotationList=wt;n.$on("updateIndex",function(n,t){t.position===-1&&(t.position=null);t.model===s.modelIndex?h(t.position,t.model):t.model!==s.modelIndex&&t.position===s.positionIndex&&h(null);console.log("Image-Model: "+s.modelIndex+", Position: "+s.positionIndex)});n.$on("LoadZoomableImage",function(i,r,u,f,e,h,c,l){s.model=u[s.modelIndex];s.model.expanded=!1;s.state.showAnnos=f;s.state.loading=!0;ht(r);var a=s.model.imageData,v=w(a),y=new Zoomable.ImageInitializer({tileDataSourceType:a.TileDataSourceType,tilesMapUrl:a.TilesMapUrl,tilesZipUrl:a.TilesZipUrl});y.initialize(v,function(n){var t,r,f,i,c;u.length===1&&h&&k(n,a);e||(n.overviewControl=!1);l&&(t=JSON.parse(l),t&&(r=parseInt(t[0],10),f=parseInt(t[1],10),r&&f&&(n.center=[r,f]),i=parseInt(t[2],10),i&&(n.initialZoomLevel=i,calculateNumberOfZoomLevels=function(n,t,i){for(var r=n>t?n:t,u=1;r>i;)u++,r=Math.ceil(r/2);return u},c=calculateNumberOfZoomLevels(n.width,n.height,n.tileSize)-(1+(n.minZoomLevel||0)),i>c&&!n.extraZoomEnabled&&(n.extraZoomEnabled=!0,s.state.extraZoomEnabled=!0,o.put("extraZoomEnabled",!0)),i>=c+(s.state.extraZoomEnabled?2:0)&&(s.state.maxZoomReached=!0))))}).then(function(n){s.model.zoomableImage=n;typeof c=="function"&&c&&c(s.model.zoomableImage,s.modelIndex===0)}).then(function(){s.state.showAnnos&&t.GetComments(s.model.imageData.Id,s.model.accessCode||s.model.albumAccessCode,function(n){s.model.imageData.Comments=n;s.model.zoomableImage!==null&&(s.annos=et(),s.model.zoomableImage.loadAnnotations(s.annos));s.model.zoomableImage.updateSize()})}).then(function(){at();p();lt({type:"loaded",imageId:s.model.imageData.Id},"*");s.state.loading=!1;n.$digest()})})}function EmbeddedImageController(n,t,i,r,u,f){function a(t,i,r,o,s,h,c,l,a,y,p,w,b,d,g){var nt,it;if(e.albumAccessCode=i,e.state.showLogo=l?!0:!1,e.state.showAnnos=a?!0:!1,e.state.isAnnoListActive=y?!0:!1,e.state.bindImages=r?!0:!1,e.state.gap=c?c:0,e.state.showToolbar=p?!0:!1,e.models=t,e.state.overview=w?!0:!1,e.state.scalebar=b?!0:!1,d!==""&&d.indexOf(":")>0){e.state.showImagesIndexes=d.split(":");for(nt in e.state.showImagesIndexes)e.state.showImagesIndexes[nt]=Number(e.state.showImagesIndexes[nt])}else if(d!=="")e.state.showImagesIndexes=[Number(d)];else for(nt=0;nt<e.models.length;nt++)e.state.showImagesIndexes.push(nt);e.state.bindImages&&(e.state.offsets={hasValues:o||s||h,x:o,y:s,angle:h});it=[];_.each(e.models,function(n){n.albumAccessCode=i;it.push(v(n))});it.push(u.LoadAnnotationTypes(function(n){e.annotationTypesResponse=n}));f.all(it).then(function(){tt();n.$broadcast("LoadZoomableImage",e.annotationTypesResponse,e.models,e.state.showAnnos,e.state.overview,e.state.scalebar,k,g)})}function v(n){return n.id&&e.albumAccessCode?y(n):n.id?p(n):w(n)}function y(n){return u.GetImageInformationByAlbumAccessCode(n.id,e.albumAccessCode,function(t){o(n,t)},function(){s()})}function p(n){return u.GetImageInformation(n.id,function(t){o(n,t)},function(){s()})}function w(n){return u.GetImageInformationByAccessCode(n.accessCode,function(t){o(n,t)},function(){s()})}function o(n,t){t!==null&&(n.imageData=t,e.state.isMetaInitialized||(e.state.isMetaInitialized=!0,b(t)))}function s(){e.state.whenNotFound=!0}function b(n){document.title=n.Title;i.meta={image:{url:r.trustAsResourceUrl(n.Thumbnail600Url),width:600,height:315,type:"image/jpeg"}}}function k(n,t){e.state.bindImages&&h(n,t)}function d(n,t){h(n,t)}function h(n,t){if(t?e.state.primaryImage=n:e.state.secondaryImages.push(n),e.state.primaryImage!==null&&e.state.secondaryImages.length>0)if(e.state.isImagesBoundExists){if(e.state.offsets&&e.state.offsets.hasValues)return;n.bindTo(e.state.primaryImage)}else{if(e.state.offsets&&e.state.offsets.hasValues){var i=e.state.secondaryImages[0];e.state.primaryImage.bindWithOffset(i,e.state.offsets.x,e.state.offsets.y);i.rotate(e.state.offsets.angle)}else _.each(e.state.secondaryImages,function(n){n.bindTo(e.state.primaryImage)});e.state.isImagesBoundExists=!0}}function g(){return"calc((100% - (("+e.state.showImagesIndexes.length+" - 1) * "+e.state.gap+"px)) / "+e.state.showImagesIndexes.length+")"}function c(n){return e.state.showImagesIndexes.indexOf(n)}function nt(n){var t=c(n),i;return t<0?"-100vw":(i=t>0?t*e.state.gap:0,"calc("+t+" * ((100% - ("+(e.state.showImagesIndexes.length-1)+" * "+e.state.gap+"px)) / "+e.state.showImagesIndexes.length+") + "+i+"px)")}function tt(){t.addEventListener("message",it)}function it(n){var t=n.data;typeof t!="undefined"&&t!==null&&(t.type==="showImages"?l(t.positions):t.type==="changeImage"&&(t.data.position=Number(t.data.position),t.data.index=Number(t.data.index),typeof e.state.showImagesIndexes[t.data.position]!="undefined"&&(e.state.showImagesIndexes[t.data.position]=t.data.index),l()))}function l(t){t&&(e.state.showImagesIndexes=t);for(var i in e.models)n.$broadcast("updateIndex",{position:e.state.showImagesIndexes.indexOf(Number(i)),model:Number(i)});$("canvas").trigger("click")}var e=this;e.models=[];e.albumAccessCode=null;e.state={showLogo:!1,showAnnos:!0,isAnnoListActive:!1,bindImages:!1,offsets:null,isMetaInitialized:!1,whenNotFound:!1,processing:!1,primaryImage:null,secondaryImages:[],isImagesBoundExists:!1,gap:0,showToolbar:!0,showImagesIndexes:[],overview:!0,scalebar:!0};e.style={mapWidth:0};e.init=a;e.bindImage=d;e.getMapWidth=g;e.getMapPositionIndex=c;e.getMapPosition=nt}angular.module("easyzoom.embed",["ngSanitize","ui.bootstrap","gettext","ngAnimate","ngTouch","ngCookies","angular-click-outside","perfect_scrollbar","angularModalService","youtube-embed","easyzoom.common","angularScreenfull"]).run(embedRun);embedRun.$inject=["gettextCatalog","$cookies"];angular.module("easyzoom.embed").service("HttpService",HttpService);HttpService.$inject=["$http"];angular.module("easyzoom.embed").controller("ZoomableImageController",ZoomableImageController);ZoomableImageController.$inject=["$scope","HttpService","$q","$http","gettextCatalog","ModalService","$timeout","$cookies"];angular.module("easyzoom.embed").controller("EmbeddedImageController",EmbeddedImageController);EmbeddedImageController.$inject=["$scope","$window","$rootScope","$sce","HttpService","$q"],function(){"use strict";function n(n,t){function r(){var n=new QRious({value:t,size:300,foreground:"#111"});i.props.qrCode=n.toDataURL()}function u(){n()}var i=this;i.props={qrCode:null};i.dismissModal=u;r()}angular.module("easyzoom.embed").controller("QRModalController",n);n.$inject=["close","url"]}()