| Server IP : 193.86.120.172 / Your IP : 216.73.216.67 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /volume1/@appstore/SynologyPhotos/ui/ |
Upload File : |
"use strict";(self.webpackChunkFotoExternalSharedAlbumReactLibrary=self.webpackChunkFotoExternalSharedAlbumReactLibrary||[]).push([["922"],{40489:function(e,t,n){n.r(t),n.d(t,{default:function(){return ek},LightboxEditFaceModeContext:function(){return eA}});var o=n(76150),a=n(24460),r=n(28395),i=n(23930),c=n.n(i),l=n(45697),u=n.n(l),s=n(67294),d=n(94184),f=n.n(d),m=n(15593),g=n(96904),p=n(47407),h=n(79113),b=n(79905),v=function(e){var t=e.hasDiff,n=e.onCancel,o=e.onSave;return s.createElement("div",{className:"synofoto-lightbox-face-editor-toolbar"},s.createElement("div",{className:"synofoto-lightbox-face-editor-toolbar-left"},s.createElement(p.Z,{className:"synofoto-lightbox-face-editor-close-btn",iconCls:"cancel-dark-btn-icon",handler:n}),s.createElement("div",{className:"synofoto-lightbox-face-editor-title"},(0,b.n6)("lightbox","editing_face_toolbar_title"))),s.createElement("div",{className:"synofoto-lightbox-face-editor-toolbar-right"},s.createElement(h.Z,{text:(0,b.n6)("setting","save"),className:"synofoto-lightbox-face-editor-save-btn",disabled:!t,handler:o})))};v.propTypes={hasDiff:u().bool,onCancel:u().func,onSave:u().func},v.defaultProps={hasDiff:!1,onCancel:function(){},onSave:function(){}};var E=n(18939),I=n(22902),y=n(7409),N=n(35369),_=n(95281),C=n(37771),w=n(27412),x=n(99282),P=n(98848),D=n(34670),S=n(39308),O=n(10513),R=function(e){var t=e.highlightDefault,n=e.innerRef,o=e.onChange,a=e.isDisabled,r=e.value,i=(0,P._)(e,["highlightDefault","innerRef","onChange","isDisabled","value"]),c=(0,s.useRef)(null);return(0,s.useEffect)(function(){r&&o({currentTarget:{value:r}})},[]),s.createElement(D.c.Input,(0,y._)({innerRef:function(e){n(e),c.current||!e||a||setTimeout(function(){c.current=e,t&&(c.current.focus(),c.current.setSelectionRange(0,e.value.length))},0)},value:r,onChange:o,isDisabled:a,"data-testid":"synofoto-react-select-input"},i))};R.propTypes={innerRef:u().func.isRequired,onChange:u().func.isRequired,value:u().string.isRequired,isDisabled:u().bool,highlightDefault:u().bool},R.defaultProps={isDisabled:!1,highlightDefault:!1};var T=function(e){var t=e.highlightDefault;return function(e){return s.createElement(R,(0,x._)((0,y._)({},e),{highlightDefault:t}))}},B={innerProps:u().shape({onMouseDown:u().func}),children:u().node},F=function(e){var t=e.innerProps,n=e.children,o=(0,P._)(e,["innerProps","children"]);return s.createElement(D.c.Control,(0,y._)({innerProps:(0,x._)((0,y._)({},t),{onMouseDown:function(e){var n=o.isFocused,a=o.menuIsOpen;n&&a||t.onMouseDown(e),"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName&&e.preventDefault()}})},o),n)};F.propTypes=B,F.defaultProps={innerProps:{onMouseDown:function(){}},children:null};var M=n(21132),A=n(69253),L=n(22287),k=n(6992);function J(){return{type:k.j.InitPersonSuggestion}}var V=n(27154),Z=n(34774),H=function(e,t,n,o,a,r){return s.createElement(C.Z,{key:"face-image-".concat(n),className:e,imageHeight:t,imageWidth:t,imageUrl:(0,Z.AJ)(n,o,a,(0,L.$E)(),void 0,r),isCover:!0,isPerson:!0})},G={library:u().string.isRequired,blurInputOnSelect:u().bool,isDisabled:u().bool,setSelectPersonHandler:u().func,avoidPersonId:u().number,className:u().string,menuPortalTarget:u().instanceOf(Element),onBlur:u().func,onKeyDown:u().func,menuIsOpen:u().bool,menuPlacement:u().string,defaultInputValue:u().string,highlightDefault:u().bool,fixOptionPrefix:u().string,focusInputOnControlMouseDown:u().bool,placeholder:u().string,allowEmptyName:u().bool,showClearIndicator:u().bool},W={blurInputOnSelect:!0,isDisabled:!1,avoidPersonId:-1,setSelectPersonHandler:function(){},className:"",menuPortalTarget:null,onBlur:function(){},onKeyDown:function(){},menuIsOpen:void 0,menuPlacement:"auto",defaultInputValue:"",highlightDefault:!1,focusInputOnControlMouseDown:!1,fixOptionPrefix:(0,b.n6)("action","create"),placeholder:(0,b.n6)("app","set_name_placeholder"),allowEmptyName:!1,showClearIndicator:!1},U=function(e){var t=e.blurInputOnSelect,n=e.isDisabled,o=e.setSelectPersonHandler,r=e.library,i=e.avoidPersonId,c=e.className,l=e.menuPortalTarget,u=e.onKeyDown,d=e.onBlur,p=e.menuIsOpen,h=e.menuPlacement,b=e.defaultInputValue,v=e.highlightDefault,E=e.fixOptionPrefix,N=e.focusInputOnControlMouseDown,_=e.placeholder,C=e.allowEmptyName,R=e.showClearIndicator,B=(0,a._)((0,s.useState)(null),2),L=B[0],k=B[1],Z=(0,s.useRef)(null),G=(0,s.useRef)(""),W=(0,m.I0)(),U=(0,m.v9)(function(e){return e.getIn(["autoSmartAlbum","person","suggestion"])});(0,s.useEffect)(function(){W(J())},[]);var j=(0,A.f)(W,r,V.on,V.RP),q=(0,s.useCallback)(function(e){k(e),o(e)},[k,o]),z=(0,I.Z)(function(e){e.length>0?(j(e),q(null)):W(J())},100),K=(0,s.useCallback)(function(e){q({id:e.id,name:e.id,isNewPerson:!0}),Z.current&&Z.current.blur()},[Z,q]),X=(0,s.useCallback)(function(e){Z.current&&Z.current.setState({focusedOption:e})},[Z]),Y=(0,s.useCallback)(function(e){var t=e.data,n=e.innerProps,o=(0,P._)(e,["data","innerProps"]);if((null==t?void 0:t.additional)!==void 0){var a=t.id,i=t.additional.thumbnail,c=g.ZP.ALBUM_TYPE.PERSON,l=(0,y._)({innerProps:n,data:t},o);return s.createElement("div",(0,y._)({"data-tooltip-id":g.ZP.GLOBAL_TOOLTIP_ID,"data-tooltip-content":t.name,key:"suggestion-".concat(a),"data-testid":"synofoto-person-option-".concat(a)},n),s.createElement(D.c.Option,(0,x._)((0,y._)({},l),{className:"synofoto-person-option"}),H("synofoto-person-name-menu-image",40,a,i,c,r),s.createElement("div",{className:"synofoto-person-name-menu-caption"},t.name)))}return null},[r]),$=(0,s.useCallback)(function(e){var t=e.children,n=e.options,o=e.focusedOption,a=(0,P._)(e,["children","options","focusedOption"]),r=n.length,i=n[r-1],c=i&&i.createOption,l=c&&(1===r||r!==t.length),u=i.id===(null==o?void 0:o.id);return s.createElement(s.Fragment,null,s.createElement(O.Z,(0,y._)({className:"synofoto-person-menu-list",focusedOption:o,options:n},a),t),c&&s.createElement("div",{className:f()({"synofoto-person-menu-footer":!0,onlyCreate:l})},!l&&s.createElement("div",{className:"synofoto-person-create-separator"}),s.createElement("div",{key:"create-new-person",className:f()({"synofoto-person-create-name":!0,focused:u}),onClick:function(){return K(i)},onMouseEnter:function(){return X(i)},"data-testid":"synofoto-fixed-option"},i.name)))},[K,X]),Q=(0,s.useCallback)(function(e){var t=e.data;if(null===t||!t.name)return null;var n=[s.createElement("div",{key:"target-person-name",className:"synofoto-person-value-name"},t.name)];return void 0!==t.additional?n.unshift(H("synofoto-person-value-image",24,t.id,t.additional.thumbnail,g.ZP.ALBUM_TYPE.PERSON,r)):n.unshift(s.createElement("div",{key:"face-image-new",className:"synofoto-person-value-new-name"},s.createElement(M.Z,{text:t.name[0],classSuffix:"size24"}))),s.createElement("div",{"data-tooltip-id":g.ZP.GLOBAL_TOOLTIP_ID,"data-tooltip-content":t.name,className:"synofoto-person-value-target"},n)},[r]),ee=f()((0,w._)({"synofoto-person-suggestion-select":!0},c,c)),et=N?function(e){var t,n,o,a,r,i,c;null==Z||null===(n=Z.current)||void 0===n||null===(t=n.inputRef)||void 0===t||t.focus(),null==Z||null===(c=Z.current)||void 0===c||null===(i=c.inputRef)||void 0===i||i.setSelectionRange(0,null==Z?void 0:null===(r=Z.current)||void 0===r?void 0:null===(a=r.inputRef)||void 0===a?void 0:null===(o=a.value)||void 0===o?void 0:o.length),e.preventDefault()}:void 0,en=(0,s.useMemo)(function(){return T({highlightDefault:v})},[v]);return s.createElement(S.Z,{innerRef:Z,autoFocus:!0,className:ee,isCreatable:!0,isClearable:R,isSearchable:!0,isMenuPortal:!0,blurInputOnSelect:t,defaultInputValue:b,menuPortalTarget:l,showClearIndicator:R,showDropdownIndicator:!1,customizeComponents:{Control:F,Input:en,MenuList:$,Option:Y,SingleValue:Q},isDisabled:n,getOptionLabel:function(e){return e.name},getOptionValue:function(e){return e.id},isValidNewOption:function(e){return""!==e.trim()},onChange:q,onInputChange:function(e){return G.current=e,z(e),e},onControlMouseDown:et,onCreateOption:function(e){var t={};t.id=e.trim(),t.name=t.id,t.isNewPerson=!0,q(t)},onBlur:d,getNewOptionData:function(e){return{id:e,name:"".concat(E," ").concat(e),createOption:!0}},value:L,placeholder:_,options:U.filter(function(e){return e.get("id")!==i}).setSize().toJS(),noOptionsMessage:"",onKeyDown:function(e){e.stopPropagation(),e.key===g.VD.ENTER&&0===G.current.length&&C&&K({id:G.current}),u(e)},menuIsOpen:p,menuPlacement:h})};U.propTypes=G,U.defaultProps=W;var j=n(95853),q=(0,j.q$)({SetFaceBoundingBoxList:"SET_FACE_BOUNDING_BOX_LIST",AddFaceBoundingBox:"ADD_FACE_BOUNDING_BOX",DeleteFaceBoundingBox:"DELETE_FACE_BOUNDING_BOX",ReassignFaceBoundingBox:"REASSIGN_FACE_BOUNDING_BOX",ClearEditFace:"CLEAR_EDIT_FACE"}),z=(0,j.Ky)({LoadFaceBoundingBoxList:"LOAD_FACE_BOUNDING_BOX_LIST",SaveFaceBoundingBoxResult:"SAVE_FACE_BOUNDING_BOX_RESULT"}),K=n(98837),X=n(869),Y=function(e){var t=e.dbName,n=e.storeName,a=void 0===n?"":n,i=e.dbVersion,c=void 0===i?1:i,l=e.upgradeCallback,u=void 0===l?function(){}:l;return(0,o._)(function(){return(0,r.Jh)(this,function(e){switch(e.label){case 0:return[4,(0,X.X3)(t,c,{upgrade:function(e){u(e,a)}}).catch(function(e){console.error("openDB error",e)})];case 1:return[2,e.sent()]}})})()},$=function(e,t){e&&!e.objectStoreNames.contains(t)&&e.createObjectStore(t)},Q=function(e){var t=e.dbName,n=e.storeName,a=e.dbVersion,i=void 0===a?1:a;return(0,o._)(function(){var e;return(0,r.Jh)(this,function(o){switch(o.label){case 0:return[4,Y({dbName:t,storeName:n,dbVersion:i,upgradeCallback:$})];case 1:if(!((e=o.sent())&&!e.objectStoreNames.contains(n)))return[3,4];return[4,e.close()];case 2:return o.sent(),[4,(0,X.Lj)(t)];case 3:return o.sent(),[2,Y({dbName:t,storeName:n,dbVersion:i,upgradeCallback:$})];case 4:return[2,e]}})})()},ee=function(e){var t=e.dbName,n=e.storeName,a=e.key,i=e.value,c=e.dbVersion,l=void 0===c?1:c;return(0,o._)(function(){var e,o;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return[4,Q({dbName:t,dbVersion:l,storeName:n})];case 1:if(!((e=r.sent())&&e.objectStoreNames.contains(n)))return[3,3];return(o=e.transaction(n,"readwrite")).objectStore(n).put(i,a),[4,o.done];case 2:r.sent(),e.close(),r.label=3;case 3:return[2]}})})()},et=function(e){var t=e.dbName,n=e.storeName,a=e.key,i=e.dbVersion,c=void 0===i?1:i;return(0,o._)(function(){var e,o,i;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return[4,Q({dbName:t,dbVersion:c,storeName:n})];case 1:if(!((e=r.sent())&&e.objectStoreNames.contains(n)))return[3,4];return[4,(o=e.transaction(n,"readonly")).objectStore(n).get(a)];case 2:return i=r.sent(),[4,o.done];case 3:return r.sent(),e.close(),[2,i];case 4:return[2,null]}})})()},en=function(e){var t=e.dbName,n=e.storeName,a=e.deleteKey,i=e.dbVersion,c=void 0===i?1:i;return(0,o._)(function(){var e,o,i,l;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return[4,Q({dbName:t,dbVersion:c,storeName:n})];case 1:if(!((e=r.sent())&&e.objectStoreNames.contains(n)))return[3,3];return i=(o=e.transaction(n,"readwrite")).objectStore(n),l=IDBKeyRange.lowerBound(a),i.delete(l),[4,o.done];case 2:r.sent(),e.close(),r.label=3;case 3:return[2]}})})()},eo="synofoto",ea="cropped_faces",er=function(e){return(0,o._)(function(){return(0,r.Jh)(this,function(t){switch(t.label){case 0:return[4,en({dbName:eo,deleteKey:"".concat(e,"-"),storeName:ea}).catch(function(e){console.error("deleteCroppedFaceByItem error",e)})];case 1:return t.sent(),[2]}})})()},ei="synofoto-lightbox-person-select",ec=function(e){var t=document.body.getBoundingClientRect();return t.bottom-e.bottom>294&&t.right-e.left>223?{className:"".concat(ei,"-bottom-left"),menuPlacement:"bottom"}:t.bottom-e.top>294&&e.left>223?{className:"".concat(ei,"-left-top"),menuPlacement:"bottom"}:e.bottom>294&&e.left>223?{className:"".concat(ei,"-left-bottom"),menuPlacement:"top"}:t.bottom-e.top>294&&t.right-e.right>223?{className:"".concat(ei,"-right-top"),menuPlacement:"bottom"}:e.bottom>294&&t.right-e.right>223?{className:"".concat(ei,"-right-bottom"),menuPlacement:"top"}:{className:"".concat(ei,"-bottom-left"),menuPlacement:"bottom"}},el=function(e){var t,n,i,c,l,u=e.faceId,d=e.library,h=e.name,v=e.bottomRight,E=e.topLeft,I=e.personId,N=e.personThumbnail,w=e.defaultHovering,x=(0,m.I0)(),P=(0,s.useRef)(w),D=(0,a._)((0,s.useState)(P.current),2),S=D[0],O=D[1],R=(0,s.useCallback)(function(e){P.current=e,O(e)},[]),T=(0,a._)((0,s.useState)(!1),2),B=T[0],F=T[1],M=(0,a._)((0,s.useState)(""),2),A=M[0],k=M[1],J=(0,s.useContext)(eA),V=J.editFaceModeState,H=J.setEditFaceModeState,G=J.setNewCreatedFaceId,W=(0,s.useRef)(null),j=(0,s.useRef)(null),z=(0,s.useCallback)(function(){F(!0),H(g.J4.EDITING_NAME)},[F,H]),X=(0,s.useCallback)(function(){P.current?H(g.J4.HOVERING):H(g.J4.VIEW_MODE)},[H]);(0,s.useEffect)(function(){R(w)},[R,w]),(0,s.useEffect)(function(){V!==g.J4.EDITING_NAME&&B&&F(!1),V===g.J4.CREATING_CROP&&S&&(R(!1),G(null))},[V,F,B,S,R,G]);var Y=(0,s.useCallback)(function(){if(!j.current){var e;j.current=ec(null===(e=W.current)||void 0===e?void 0:e.getBoundingClientRect())}return j.current},[]);(0,s.useEffect)(function(){var e=function(){j.current=null};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);var $=(0,s.useCallback)(function(){return(0,o._)(function(){var e;return(0,r.Jh)(this,function(t){switch(t.label){case 0:return[4,(0,o._)(function(){var e,t;return(0,r.Jh)(this,function(n){switch(n.label){case 0:return[4,et({dbName:eo,storeName:ea,key:u}).catch(function(e){console.error("getCroppedFace error",e)})];case 1:if(!(e=n.sent()))return[3,3];return[4,(0,K.J)(e)];case 2:return[2,(t=n.sent()).slice(0,t.size,"image/jpeg")];case 3:return[2,null]}})})()];case 1:return(e=t.sent())?k(URL.createObjectURL(e).toString()):k(""),[2]}})})()},[u]),Q=(0,s.useCallback)(function(){k((0,Z.AJ)(I,N.toJS(),g.ZP.ALBUM_TYPE.PERSON,(0,L.$E)(),void 0,d))},[I,N,d]);(0,s.useEffect)(function(){I?Q():$()},[I,Q,$]);var ee=(0,s.useCallback)(function(e){if(e){var t,n,o,a,r,i=e.isNewPerson?{personName:e.name}:{personId:e.id,personName:e.name,additional:e.additional};x((n=(t=(0,y._)({targetedFaceId:u},i)).targetedFaceId,o=t.personId,a=t.personName,r=t.additional,{type:q.ReassignFaceBoundingBox,targetedFaceId:n,personId:o,personName:a,additional:r})),X()}},[x,u,X]),en=(0,s.useCallback)(function(e){e.key===g.VD.ESC&&X()},[X]),er=(0,s.useMemo)(function(){if(!B)return null;var e=Y(),t=e.className,n=e.menuPlacement;return s.createElement("div",{className:t,onPointerDown:function(e){e.stopPropagation()}},s.createElement("div",{className:"synofoto-lightbox-crop-image-person-select-gap",onMouseDown:function(e){e.preventDefault()}}),s.createElement(U,{focusInputOnControlMouseDown:!0,blurInputOnSelect:!1,library:d,setSelectPersonHandler:ee,className:"synofoto-lightbox-crop-image-person-select",onBlur:X,onKeyDown:en,menuPlacement:n,defaultInputValue:h,highlightDefault:!0}))},[B,d,h,Y,ee,X,en]),ei=(0,s.useCallback)(function(){x({type:q.DeleteFaceBoundingBox,targetedFaceId:u}),H(g.J4.VIEW_MODE)},[x,u,H]),el={top:"".concat(100*E.get("y",0),"%"),left:"".concat(100*E.get("x",0),"%"),width:"".concat((v.get("x",0)-E.get("x",0))*100,"%"),height:"".concat((v.get("y",0)-E.get("y",0))*100,"%")},eu=f()("synofoto-face-bounding-box",{highlighted:S||B,"hidden-without-event":V===g.J4.CREATING_CROP||V===g.J4.EDITING_NAME&&!B,hidden:V===g.J4.HOVERING&&!S}),es=(0,s.useCallback)(function(){V===g.J4.VIEW_MODE||V===g.J4.HOVERING?(R(!0),H(g.J4.HOVERING)):V===g.J4.EDITING_NAME&&R(!0)},[V,R,H]),ed=(0,s.useCallback)(function(){(V===g.J4.HOVERING||V===g.J4.EDITING_NAME)&&(R(!1),G(null)),V===g.J4.HOVERING&&H(g.J4.VIEW_MODE)},[R,H,V,G]);return s.createElement("div",{className:eu,style:el,onClick:function(e){return e.stopPropagation()},onMouseEnter:es,onMouseLeave:ed,onPointerDown:function(e){var t=document.getElementById("synofoto-lightbox-image-crop-img");t&&t.dispatchEvent(new PointerEvent("pointerdown",e))},ref:W,"data-testid":"face-bounding-box-".concat(u)},(S||B)&&(t=Y().className,n=f()("synofoto-lightbox-crop-image-delete-icon",{"left-top":t.includes("right")}),i=f()("synofoto-face-bounding-box-delete-icon-background",{"left-top":t.includes("right")}),s.createElement(s.Fragment,null,s.createElement("div",{className:i}),s.createElement(p.Z,{className:n,iconCls:"close-btn-icon",handler:ei}))),S&&V===g.J4.HOVERING&&(c=Y().className,l=f()("synofoto-face-bounding-box-person-name",{unamended:!h}),s.createElement("div",{className:c,onPointerDown:function(e){e.stopPropagation()}},s.createElement("div",{className:"synofoto-lightbox-crop-image-person-select-gap"}),s.createElement("div",{className:"synofoto-face-bounding-box-person",onClick:z},A?s.createElement(C.Z,{className:"synofoto-face-bounding-box-person-image",imageHeight:40,imageWidth:40,imageUrl:A,isCover:!0,isPerson:!0}):s.createElement(_.Z,{name:h,classSuffix:"size40",className:"synofoto-face-bounding-box-person-image"}),s.createElement("div",{className:l},""===h?(0,b.n6)("app","who_is_this"):h)))),er)};el.propTypes={faceId:u().oneOfType([u().number,u().string]).isRequired,library:u().string.isRequired,name:u().string,bottomRight:c().mapContains({x:u().number,y:u().number}),topLeft:c().mapContains({x:u().number,y:u().number}),personId:u().oneOfType([u().string,u().number]),personThumbnail:c().mapContains({cache_key:u().string}),defaultHovering:u().bool},el.defaultProps={name:"",bottomRight:N.default.Map({x:0,y:0}),topLeft:N.default.Map({x:0,y:0}),personId:void 0,personThumbnail:N.default.Map({cache_key:""}),defaultHovering:!1};var eu=function(e){return e.getIn(["editFace","list"])},es=function(e){var t;return(null===(t=e.getIn(["editFace","diff"]))||void 0===t?void 0:t.size)>0},ed=function(e){var t=e.ctx,n=e.x,o=e.y,a=e.width,r=e.height,i=e.canvasWidth,c=e.canvasHeight;t.beginPath(),t.moveTo(0,0),t.lineTo(0,c),t.lineTo(i,c),t.lineTo(i,0),t.lineTo(0,0),t.lineTo(n+8,o),t.arcTo(n+a,o,n+a,o+r,8),t.arcTo(n+a,o+r,n,o+r,8),t.arcTo(n,o+r,n,o,8),t.arcTo(n,o,n+a,o,8),t.clip()},ef=function(e){var t=e.library,n=(0,s.useContext)(eA),o=n.editFaceModeState,r=n.newCreatedFaceId,i=(0,s.useRef)(null),c=(0,m.v9)(eu),l=f()("synofoto-lightbox-face-editor-canvas",{hidden:o!==g.J4.VIEW_MODE}),u=(0,s.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.boundingBoxList,n=e.contentWidth,o=void 0===n?i.current.width:n,a=e.contentHeight,r=void 0===a?i.current.height:a;if(null==i?void 0:i.current){var c=i.current.getContext("2d");if(o!==i.current.width||r!==i.current.height?(i.current.width=Math.floor(o),i.current.height=Math.floor(r)):c.reset(),0!==t.size){var l=i.current,u=l.width,s=l.height;t.forEach(function(e){var t=e.get("face_bounding_box").toJS(),n=t.bottom_right,o=t.top_left,a=o.x,r=o.y;ed({ctx:c,x:Math.floor(a*u),y:Math.floor(r*s),width:Math.floor((n.x-a)*u),height:Math.floor((n.y-r)*s),canvasWidth:u,canvasHeight:s})}),c.fillStyle="rgba(0, 0, 0, 0.4)",c.fillRect(0,0,u,s)}}},[i]),d=(0,I.Z)(function(e){var t=e.entry;t&&u({boundingBoxList:c,contentWidth:t.width,contentHeight:t.height})});return(0,s.useEffect)(function(){u({boundingBoxList:c})},[u,c]),s.createElement("div",{className:"synofoto-lightbox-face-collection"},s.createElement("canvas",{className:l,ref:i}),s.createElement(E.Z,{onResize:d},function(e){var n=e.measureRef;return s.createElement("div",{className:"synofoto-lightbox-face-collection-wrapper",ref:n},c.entrySeq().map(function(e){var n=(0,a._)(e,2),o=n[0],i=n[1];return s.createElement(el,{key:o,faceId:o,name:i.get("name"),library:t,personId:i.get("person_id"),personThumbnail:i.getIn(["additional","thumbnail"]),bottomRight:i.getIn(["face_bounding_box","bottom_right"]),topLeft:i.getIn(["face_bounding_box","top_left"]),defaultHovering:r===o})}))}))};ef.propTypes={library:u().string.isRequired};var em=n(33344),eg=n(82260),ep=n(22758),eh=function(e){var t=e.x,n=e.y;return{top_left:{x:t/100,y:n/100},bottom_right:{x:(t+e.width)/100,y:(n+e.height)/100}}},eb=n(62916),ev=function(e,t){var n=eh(e),o=n.top_left,a=n.bottom_right,r=t.current.getBoundingClientRect();return{top:o.y*r.height+r.top,left:o.x*r.width+r.left,bottom:a.y*r.height+r.top,right:a.x*r.width+r.left}},eE={imgSrc:u().string.isRequired,library:u().string.isRequired,item:c().map.isRequired,setIsImgLoaded:u().func.isRequired},eI=function(e){var t=e.image,n=e.canvas,o=e.crop,a=n.getContext("2d");if(!a)throw Error("Canvas context is null");var r=window.devicePixelRatio;n.width=Math.floor(t.naturalWidth*o.width/100*r),n.height=Math.floor(t.naturalHeight*o.height/100*r),a.scale(r,r),a.imageSmoothingQuality="high";var i=t.naturalWidth*o.x/100,c=t.naturalHeight*o.y/100,l=t.naturalWidth/2,u=t.naturalHeight/2;a.save(),a.translate(-i,-c),a.translate(l,u),a.translate(-l,-u),a.drawImage(t,0,0,t.naturalWidth,t.naturalHeight,0,0,t.naturalWidth,t.naturalHeight),a.restore()},ey=function(e){var t=e.imgSrc,n=e.library,i=e.item,c=e.setIsImgLoaded,l=(0,a._)((0,s.useState)(),2),u=l[0],d=l[1],h=(0,a._)((0,s.useState)(),2),b=h[0],v=h[1],E=(0,a._)((0,s.useState)(0),2),I=E[0],N=E[1],_=(0,a._)((0,s.useState)(0),2),C=_[0],w=_[1],P=(0,a._)((0,s.useState)(!0),2),D=P[0],S=P[1],O=(0,s.useRef)(null),R=(0,s.useRef)(null),T=(0,s.useRef)(null),B=(0,m.I0)(),F=i.get("id"),M=(0,s.useContext)(eA),A=M.editFaceModeState,L=M.setEditFaceModeState,k=M.setNewCreatedFaceId;(0,s.useEffect)(function(){b&&R.current&&O.current&&eI({image:O.current,canvas:R.current,crop:b})},[b]),(0,s.useEffect)(function(){return er(F),function(){er(F)}},[F]);var J=function(){d(null),v(null)},V=(0,s.useCallback)(function(e){return(0,o._)(function(){var t,n,a,i,c;return(0,r.Jh)(this,function(l){var u,s,f,m,p,h,E;switch(l.label){case 0:if(!e)return[3,3];return t="".concat(F,"-").concat(I),a=eh(n=(0,y._)({},b)),v(null),[4,(0,eg.Z)({image:O.current,crop:n})];case 1:return i=l.sent(),[4,(u=t,(0,o._)(function(){return(0,r.Jh)(this,function(e){switch(e.label){case 0:return[4,(0,K.w)(i)];case 1:return[4,ee({dbName:eo,storeName:ea,key:u,value:e.sent()}).catch(function(e){console.error("storeCroppedFace error",e)})];case 2:return e.sent(),[2]}})})())];case 2:l.sent(),c=e.isNewPerson?{personName:e.name}:{personId:e.id,personName:e.name,additional:e.additional},B((f=(s=(0,x._)((0,y._)({tempFaceId:t},c),{faceBoundingBox:a})).tempFaceId,m=s.personId,p=s.personName,h=s.faceBoundingBox,E=s.additional,{type:q.AddFaceBoundingBox,tempFaceId:f,personId:m,personName:p,faceBoundingBox:h,additional:E})),d(null),N(I+1),k(t),L(g.J4.HOVERING),l.label=3;case 3:return[2]}})})()},[b,I,B,F,k,L]);(0,s.useEffect)(function(){A!==g.J4.CREATING_CROP&&(null==u?void 0:u.width)>0&&(null==u?void 0:u.height)>0?L(g.J4.CREATING_CROP):A!==g.J4.CREATING_CROP||(null==u?void 0:u.width)||(null==u?void 0:u.height)||L(g.J4.VIEW_MODE)},[u,A,L,k]);var Z=function(){L(g.J4.VIEW_MODE),J()},H=function(){Z(),S(!1)},G=function(e){e.key===g.VD.ESC&&Z()};return s.createElement("div",{ref:T,className:"synofoto-lightbox-crop-image-outer-wrapper"},s.createElement(em.ZP,{crop:u,aspect:1,onChange:function(e,t){return d(t)},onComplete:function(e,t){if((null==e?void 0:e.width)>1&&(null==e?void 0:e.width)<36){J();return}v(t)},onDragStart:function(){S(!1)},onDragEnd:function(){S(!0)},className:"synofoto-lightbox-crop-image-wrapper",maxHeight:C,minHeight:36,renderSelectionAddon:function(e){if(!T.current||e.newCropIsBeingDrawn||!(null==b?void 0:b.width))return null;var t=ec(ev(u,O)),o=t.className,a=t.menuPlacement,r=f()("synofoto-lightbox-crop-image-delete-icon",{"left-top":o.includes("right")});return s.createElement("div",{onPointerDown:function(e){return e.stopPropagation()},className:o},s.createElement(p.Z,{className:r,iconCls:"close-btn-icon",handler:J}),s.createElement("div",{className:"synofoto-lightbox-crop-image-person-select-gap",onMouseDown:function(e){e.preventDefault()}}),s.createElement(U,{focusInputOnControlMouseDown:!0,library:n,setSelectPersonHandler:V,className:"synofoto-lightbox-crop-image-person-select",menuPortalTarget:T.current,menuPlacement:a,onBlur:H,onKeyDown:G,menuIsOpen:D}))}},s.createElement("img",{id:"synofoto-lightbox-image-crop-img","data-testid":"lightbox-image-crop-img",className:"synofoto-lightbox-crop-image",alt:"lightbox-crop-preload",src:t,ref:O,onLoad:function(){w(.6*O.current.height),c(!0)}})),(0,eb.Sx)()&&(null==O?void 0:O.current)&&!!b&&s.createElement("div",{className:"synofoto-debug-lightbox-crop-canvas"},s.createElement("canvas",{ref:R,style:{width:200,height:200}})))};ey.propTypes=eE;var eN=(0,ep.Z)(ey),e_=n(8768),eC=n(3799),ew=n(74620),ex=n(61403),eP=n(88093);function eD(e){return{type:z.LoadFaceBoundingBoxList,ItemAPI:eP.Z.Foto.Browse.Item,itemId:e}}function eS(e){return{type:z.LoadFaceBoundingBoxList,ItemAPI:eP.Z.FotoTeam.Browse.Item,itemId:e}}function eO(){return{type:z.SaveFaceBoundingBoxResult,uploadFaceAPIUrl:"SYNO.Foto.Upload.Face",PersonAPI:eP.Z.Foto.Browse.Person,ItemAPI:eP.Z.Foto.Browse.Item}}function eR(){return{type:z.SaveFaceBoundingBoxResult,uploadFaceAPIUrl:"SYNO.FotoTeam.Upload.Face",PersonAPI:eP.Z.FotoTeam.Browse.Person,ItemAPI:eP.Z.FotoTeam.Browse.Item}}var eT=n(83861),eB=n(92632),eF=n(48134),eM=n(82183),eA=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g.J4.VIEW_MODE,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){};return(0,s.createContext)({editFaceModeState:e,setEditFaceModeState:t,newCreatedFaceId:n,setNewCreatedFaceId:o})}(),eL=function(e){var t,n=e.item,i=e.albumType,c=e.passphrase,l=e.albumId,u=e.library,d=e.initImgLoaded,p=(0,s.useRef)(null),h=(0,m.I0)(),E=(0,m.v9)(es),I=(0,ew.Z)(),y=I.location,N=I.navigate,_=(0,a._)((0,s.useState)(g.J4.VIEW_MODE),2),C=_[0],w=_[1],x=(0,a._)((0,s.useState)(d),2),P=x[0],D=x[1],S=(0,a._)((0,s.useState)(null),2),O=S[0],R=S[1],T=(0,s.useMemo)(function(){return{editFaceModeState:C,setEditFaceModeState:w,newCreatedFaceId:O,setNewCreatedFaceId:R}},[C,w,O,R]),B=(0,m.v9)(eT.Z.getId);(0,s.useEffect)(function(){return function(){h({type:q.ClearEditFace})}},[h]),(0,s.useEffect)(function(){P&&eC.Z.openTopToast({id:g.yX.EDIT_FACE,message:(0,b.n6)("lightbox","editing_face_top_toast"),callback:function(){(null==p?void 0:p.current)&&p.current.focus()}})},[P]),(0,s.useEffect)(function(){0!==n.get("id")&&(0,A.f)(h,u,eD,eS)(n.get("id"))},[h,n,u]);var F=function(){var e=y.pathname.replace("/".concat(e_.Z.EDIT_FACE),""),t=y.state||{};t.editFace&&delete t.editFace,sessionStorage.setItem(g.OE,"true"),h((0,eM.kl)(!0)),N(e,{replace:!0,state:t})},M=function(){(0,A.f)(h,u,eO,eR)(),sessionStorage.setItem(g.OE,"true")},L=function(){return(0,o._)(function(){var e;return(0,r.Jh)(this,function(t){switch(t.label){case 0:if(!E)return F(),[2];return[4,(0,eF.Z)()];case 1:return(e=t.sent().type)===g.uE.LEAVE?F():e===g.uE.SAVE_AND_CLOSE&&M(),[2]}})})()},k=(0,s.useCallback)(function(){C===g.J4.EDITING_NAME&&w(g.J4.VIEW_MODE)},[C,w]),J=f()("synofoto-lightbox-face-editor",{"overwrite-background":C!==g.J4.VIEW_MODE});return s.createElement("div",{className:J,onClick:k},s.createElement(v,{hasDiff:E,onCancel:L,onSave:M}),s.createElement("div",{className:"synofoto-lightbox-face-editor-wrapper-container"},s.createElement("div",{className:"synofoto-lightbox-face-editor-wrapper",ref:p,tabIndex:-1,"data-testid":"face-editor-wrapper"},s.createElement(ex.Z,{onKeyDown:function(e){e.key===g.VD.ESC&&(B===g.yX.EDIT_FACE&&eC.Z.cleanupTopToast(),L())}}),s.createElement(eA.Provider,{value:T},P?s.createElement(ef,{library:u}):null,s.createElement(eN,{item:n,albumKey:(t={},(i===g.ZP.ALBUM_TYPE.ALBUM||i===g.ZP.ALBUM_TYPE.SHARING)&&((0,eB.CB)()?t.passphrase=c:l&&(t.albumId=l)),t),library:u,setIsImgLoaded:D})))))};eL.propTypes={item:c().map.isRequired,albumType:u().string,passphrase:u().string,albumId:u().number,library:u().string.isRequired,initImgLoaded:u().bool},eL.defaultProps={albumType:void 0,passphrase:"",albumId:void 0,initImgLoaded:!1};var ek=function(e){var t=(0,ew.Z)(),n=t.location,o=t.navigate,r=(0,a._)((0,s.useState)(n.state&&n.state.editFace),2),i=r[0],c=r[1];return(0,s.useEffect)(function(){i||(o(n.pathname.replace("/".concat(e_.Z.EDIT_FACE),""),{replace:!0,state:null}),c(!1))},[i,o,n.pathname]),i?s.createElement(eL,e):null}},82260:function(e,t,n){n.d(t,{a:function(){return i}});var o=n(76150),a=n(28395),r=n(96904),i=function(e){var t=e.image,n=e.crop,r=e.outputType,i=e.maxSize;return(0,o._)(function(){var e,o,c,l,u,s,d,f,m,g;return(0,a.Jh)(this,function(a){switch(a.label){case 0:if(!t||!1===t.complete)throw Error("Image is not ready");if(e=window.devicePixelRatio,o=t.naturalWidth*n.x/100,c=t.naturalHeight*n.y/100,l=Math.round(t.naturalWidth*n.width*e/100),u=Math.round(t.naturalHeight*n.height*e/100),s=1,(l>i||u>i)&&(s=Math.min(i/l,i/u)),!(g=(m=new OffscreenCanvas(d=Math.round(l*s),f=Math.round(u*s))).getContext("2d")))throw Error("Canvas context is null");return g.scale(e,e),g.imageSmoothingQuality="high",g.drawImage(t,o,c,l,u,0,0,d,f),[4,m.convertToBlob({type:r||"image/jpeg"})];case 1:return[2,a.sent()]}})})()};t.Z=function(e){var t=e.image,n=e.crop;return(0,o._)(function(){return(0,a.Jh)(this,function(e){return[2,i({image:t,crop:n,outputType:"image/jpeg",maxSize:r.K4})]})})()}},48134:function(e,t,n){n.d(t,{Z:function(){return d}});var o=n(67294),a=n(73935),r=n(15593),i=n(42376),c=n(47524),l=n(96904),u=n(79905),s=n(94057);function d(){var e=c.Z.getStore(),t=document.body.appendChild(document.createElement("div"));return new Promise(function(n){var c={showClose:!0,showCancel:!0,showConfirm:!0,isOpen:!0,role:"alertdialog",message:(0,u.n6)("app","confirm_not_saved_leave"),closeText:(0,u.n6)("action","leave"),cancelText:(0,u.n6)("action","cancel"),confirmText:(0,u.n6)("action","save_and_close"),closeHandler:function(){n({type:l.uE.LEAVE})},cancelHandler:function(){n({type:l.uE.CANCEL})},confirmHandler:function(){n({type:l.uE.SAVE_AND_CLOSE})}};a.render(o.createElement(r.zt,{store:e},o.createElement(i.Z,c)),t)}).finally(function(){(0,s.P)(t)})}}}]);