@wellesley/uploads 1.0.390 → 1.0.391

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +2 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{api as W_,handleBasicResponse as Ur,usePostApiV1UploadsMutation as $_,useDeleteApiV1UploadsByIdMutation as H_,usePostApiV1UploadsByIdMetaMutation as Y_}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@1.0.505";import{useSelector as Ft}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{toast as $r}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{createAction as Au,createSelector as Ht,createSlice as K_}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import j,{useRef as Wn,useState as Be,useEffect as $n,forwardRef as xo,PureComponent as G_,createRef as su,useCallback as X_,useLayoutEffect as q_,createElement as vo}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{useIsMobile as k_,cn as Hr,Dialog as z_,DialogContent as Z_,Button as po}from"https://cdn.jsdelivr.net/npm/@wellesley/ui@1.0.467";const V_=W_.enhanceEndpoints({endpoints:{postApiV1UploadsByIdMeta:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e,"Updated")}},postApiV1UploadsList:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e)}},postApiV1UploadsBatch:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e,"Deleted")}},putApiV1UploadsByIdTags:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e)}}}}),{usePostApiV1UploadsByIdMetaMutation:Uw,usePostApiV1UploadsListMutation:Nw,usePutApiV1UploadsByIdTagsMutation:Bw,usePostApiV1UploadsBatchMutation:Fw}=V_;var un=(t=>(t.done="done",t.inprogress="inprogress",t))(un||{}),Wt=(t=>(t.image="image",t.video="video",t.audio="audio",t))(Wt||{}),Eu=(t=>(t.post="$post",t.album="$album",t.avatar="$avatar",t.header="$header",t))(Eu||{});const Kr=t=>{const e=t.toLowerCase().match(/\.([a-zA-Z0-9]{2,4})(\?|$)+/);return e?e[1]:void 0},J_=async({url:t,...e})=>{const n=await fetch(t,e);if(!n.ok)throw new Error(n.statusText);if("PUT"===e.method)return;const r=await n.json(),i=r;if(i.errorCode)throw new Error(i.message);return r},Q_=t=>t.replace(/\.[^.]*$/,""),Ru=()=>"object"!=typeof window,j_=()=>!Ru()&&/iPhone|iPod|iPad/gi.test(window.navigator.userAgent),Fn="8.48.0",gt=globalThis;function yo(t,e,n){const r=gt,i=r.__SENTRY__=r.__SENTRY__||{},o=i[Fn]=i[Fn]||{};return o[t]||(o[t]=e())}const bu=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,e0="Sentry Logger ",au=["debug","info","warn","error","log","assert","trace"],uu={};function t0(t){if(!("console"in gt))return t();const e=gt.console,n={},r=Object.keys(uu);r.forEach((t=>{const r=uu[t];n[t]=e[t],e[t]=r}));try{return t()}finally{r.forEach((t=>{e[t]=n[t]}))}}function n0(){let t=!1;const e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return bu?au.forEach((n=>{e[n]=(...e)=>{t&&t0((()=>{gt.console[n](`${e0}[${n}]:`,...e)}))}})):au.forEach((t=>{e[t]=()=>{}})),e}const Wr=yo("logger",n0);function So(){return Co(gt),gt}function Co(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||Fn,e[Fn]=e[Fn]||{}}const r0=Object.prototype.toString;function i0(t,e){return r0.call(t)===`[object ${e}]`}function o0(t){return i0(t,"Object")}function s0(t){return!(!t||!t.then||"function"!=typeof t.then)}function a0(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{bu&&Wr.log(`Failed to add non-enumerable property "${e}" to object`,t)}}const Lu=1e3;function Du(){return Date.now()/Lu}function u0(){const{performance:t}=gt;if(!t||!t.now)return Du;const e=Date.now()-t.now(),n=null==t.timeOrigin?e:t.timeOrigin;return()=>(n+t.now())/Lu}const c0=u0();function cn(){const t=gt,e=t.crypto||t.msCrypto;let n=()=>16*Math.random();try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{const t=new Uint8Array(1);return e.getRandomValues(t),t[0]})}catch{}return"10000000100040008000100000000000".replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}function l0(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||c0(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=32===e.sid.length?e.sid:cn()),void 0!==e.init&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),"number"==typeof e.started&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof e.duration)t.duration=e.duration;else{const e=t.timestamp-t.started;t.duration=e>=0?e:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),"number"==typeof e.errors&&(t.errors=e.errors),e.status&&(t.status=e.status)}function cu(){return cn()}function lu(){return cn().substring(16)}function Ou(t,e,n=2){if(!e||"object"!=typeof e||n<=0)return e;if(t&&e&&0===Object.keys(e).length)return t;const r={...t};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=Ou(r[t],e[t],n-1));return r}(()=>{const{performance:t}=gt;if(!t||!t.now)return;const e=36e5,n=t.now(),r=Date.now(),i=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,o=i<e,a=t.timing&&t.timing.navigationStart,u="number"==typeof a?Math.abs(a+n-r):e;(o||u<e)&&(i<=u&&t.timeOrigin)})();const mo="_sentrySpan";function fu(t,e){e?a0(t,mo,e):delete t[mo]}function hu(t){return t[mo]}const f0=100;class Io{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:cu(),spanId:lu()}}clone(){const t=new Io;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._requestSession=this._requestSession,t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,fu(t,hu(this)),t}setClient(t){this._client=t}setLastEventId(t){this._lastEventId=t}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(t){this._scopeListeners.push(t)}addEventProcessor(t){return this._eventProcessors.push(t),this}setUser(t){return this._user=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&l0(this._session,{user:t}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(t){return this._requestSession=t,this}setTags(t){return this._tags={...this._tags,...t},this._notifyScopeListeners(),this}setTag(t,e){return this._tags={...this._tags,[t]:e},this._notifyScopeListeners(),this}setExtras(t){return this._extra={...this._extra,...t},this._notifyScopeListeners(),this}setExtra(t,e){return this._extra={...this._extra,[t]:e},this._notifyScopeListeners(),this}setFingerprint(t){return this._fingerprint=t,this._notifyScopeListeners(),this}setLevel(t){return this._level=t,this._notifyScopeListeners(),this}setTransactionName(t){return this._transactionName=t,this._notifyScopeListeners(),this}setContext(t,e){return null===e?delete this._contexts[t]:this._contexts[t]=e,this._notifyScopeListeners(),this}setSession(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const e="function"==typeof t?t(this):t,[n,r]=e instanceof Hn?[e.getScopeData(),e.getRequestSession()]:o0(e)?[t,t.requestSession]:[],{tags:i,extra:o,user:a,contexts:u,level:s,fingerprint:c=[],propagationContext:l}=n||{};return this._tags={...this._tags,...i},this._extra={...this._extra,...o},this._contexts={...this._contexts,...u},a&&Object.keys(a).length&&(this._user=a),s&&(this._level=s),c.length&&(this._fingerprint=c),l&&(this._propagationContext=l),r&&(this._requestSession=r),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,fu(this,void 0),this._attachments=[],this.setPropagationContext({traceId:cu()}),this._notifyScopeListeners(),this}addBreadcrumb(t,e){const n="number"==typeof e?e:f0;if(n<=0)return this;const r={timestamp:Du(),...t},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(t){return this._attachments.push(t),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:hu(this)}}setSDKProcessingMetadata(t){return this._sdkProcessingMetadata=Ou(this._sdkProcessingMetadata,t,2),this}setPropagationContext(t){return this._propagationContext={spanId:lu(),...t},this}getPropagationContext(){return this._propagationContext}captureException(t,e){const n=e&&e.event_id?e.event_id:cn();if(!this._client)return Wr.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this._client.captureException(t,{originalException:t,syntheticException:r,...e,event_id:n},this),n}captureMessage(t,e,n){const r=n&&n.event_id?n.event_id:cn();if(!this._client)return Wr.warn("No client configured on scope - will not capture message!"),r;const i=new Error(t);return this._client.captureMessage(t,e,{originalException:t,syntheticException:i,...n,event_id:r},this),r}captureEvent(t,e){const n=e&&e.event_id?e.event_id:cn();return this._client?(this._client.captureEvent(t,{...e,event_id:n},this),n):(Wr.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((t=>{t(this)})),this._notifyingListeners=!1)}}const Hn=Io;function h0(){return yo("defaultCurrentScope",(()=>new Hn))}function d0(){return yo("defaultIsolationScope",(()=>new Hn))}class p0{constructor(t,e){let n,r;n=t||new Hn,r=e||new Hn,this._stack=[{scope:n}],this._isolationScope=r}withScope(t){const e=this._pushScope();let n;try{n=t(e)}catch(t){throw this._popScope(),t}return s0(n)?n.then((t=>(this._popScope(),t)),(t=>{throw this._popScope(),t})):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const t=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:t}),t}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}}function ln(){const t=Co(So());return t.stack=t.stack||new p0(h0(),d0())}function g0(t){return ln().withScope(t)}function _0(t,e){const n=ln();return n.withScope((()=>(n.getStackTop().scope=t,e(t))))}function du(t){return ln().withScope((()=>t(ln().getIsolationScope())))}function w0(){return{withIsolationScope:du,withScope:g0,withSetScope:_0,withSetIsolationScope:(t,e)=>du(e),getCurrentScope:()=>ln().getScope(),getIsolationScope:()=>ln().getIsolationScope()}}function Mu(t){const e=Co(t);return e.acs?e.acs:w0()}function Pu(){return Mu(So()).getCurrentScope()}function v0(){return Mu(So()).getIsolationScope()}function m0(t,e){return Pu().captureException(t,void 0)}function x0(t,e){const n={captureContext:e};return Pu().captureMessage(t,void 0,n)}function y0(t,e){v0().setExtra(t,e)}var Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const S0=(...t)=>{let e="";for(const n of t){if(n instanceof Error){const t=n;return y0("exceptionMessage",e),void m0(t)}if("object"!=typeof n)e+=n;else try{e+=" "+JSON.stringify(n)}catch{e+=" "+n}}x0(e)},C0="wlsy",Tu=()=>{try{return window.localStorage}catch(t){console.warn("Error getting window.localStorage storage",t)}},I0=()=>{const t=new Set,e=Tu();if(!e)return[];for(let n=0;n<(null==e?void 0:e.length);n+=1){const r=null==e?void 0:e.key(n);"string"==typeof r&&t.add(r)}return Array.from(t)},A0=t=>{const e=`${C0}`,n=t=>`${e}:${t}`,r=()=>I0().filter((t=>t.startsWith(`${e}:`))),i=t=>t.slice(e.length+1),o=Tu(),a=t=>{try{return null==o?void 0:o.getItem(n(t))}catch{return null}},u=(t,e)=>{try{null==o||o.setItem(n(t),String(e))}catch{return}};return{getItem:a,setItem:u,removeItem:t=>{try{null==o||o.removeItem(n(t))}catch{return}},clear:()=>{try{r().forEach((t=>null==o?void 0:o.removeItem(t)))}catch{return}},keys:()=>r().map(i),has:t=>null!==a(t),getJSON:t=>{const e=a(t);if(null==e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(t,e)=>{try{u(t,JSON.stringify(e))}catch{return}}}},pu=["debug","info","warn","error"],E0=(t,e)=>{const n=pu.indexOf(t);return pu.indexOf(e)>=n},Br=(t,e,n,...r)=>{E0(e,t)&&console.log(`[${t}] ${n}`,...r)},R0=()=>A0().getItem("logger_lvl"),b0=(t=(Ru()?"info":R0()||"warn"))=>{let e=t;return{debug:(t,...n)=>Br("debug",e,t,...n),info:(t,...n)=>Br("info",e,t,...n),warn:(t,...n)=>Br("warn",e,t,...n),error:(t,...n)=>(S0(t,...n),Br("error",e,t,...n)),setLevel:t=>{e=t},getLevel:()=>e}},Ao=b0(),Uu=({src:t,name:e=""})=>new Promise(((n,r)=>{const i=document.createElement("video");i.src=t;const o=()=>{const{duration:t,videoHeight:o,videoWidth:a,src:u}=i,s=Q_(e);(!t||!o||!a||!u)&&r(),n({src:u,name:s,width:a,height:o,duration:Math.floor(t)})},a=()=>{Ao.warn("Failed to load video"),n(null)};return j_()&&i.load(),i.addEventListener("error",a),i.addEventListener("loadeddata",o),()=>{i.removeEventListener("error",a),i.removeEventListener("loadeddata",o)}})),Eo=t=>new Promise(((e,n)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{e({width:r.naturalWidth,height:r.naturalHeight}),URL.revokeObjectURL(i)},r.onerror=()=>{Ao.warn("Failed to load image"),n(null),URL.revokeObjectURL(i)},r.src=i})),gu=t=>{if(!t)return;const e="number"==typeof t?t:parseInt(t,10);if(isNaN(e))throw new Error("Can not get number from income argument");const n=e/1048576;return`${Math.floor(n)} MB`},L0=async({media:t,docPolicy:e,imgPolicy:n,videoPolicy:r,audioPolicy:i})=>{if(!n||!r)return"Media policy is not defined";const o={IMAGE:n.extensions,VIDEO:r.extensions,AUDIO:i.extensions,DOCUMENT:e.extensions},a=Kr(t.file.name)||"",u=Object.keys(o).find((t=>{var e;return null==(e=o[t])?void 0:e.includes(a)}));if(!u)return`Extension ${a} is not supported`;const s="VIDEO"===u;if("IMAGE"===u){const e=await Eo(t.file),r=t.file.size>n.maxSize,i=e&&Math.max(e.width,e.height)>n.maxResolution,o=e&&e.width*e.height>n.maxMatrix;switch(!0){case r:return`Image is too big. Max size is ${gu(n.maxSize)}`;case i:return`Image resolution is too high. Max resolution is ${n.maxResolution} pixels`;case o:return`The uploaded image exceeds the maximum size allowed. Please choose an image with smaller dimensions or reduce the resolution and try again. Max resolution is ${n.maxMatrix} pixels`}}if(s){const e=await Uu({src:t.objectUrl}),n=e&&e.duration>r.maxDuration,i=e&&Math.max(e.width,e.height)>r.maxResolution,o=t.file.size>r.maxSize,a=e&&e.width*e.height>r.maxMatrix;switch(!0){case n:return`Video is too long. Max duration is ${r.maxDuration} seconds`;case o:return`Video is too big. Max size is ${gu(r.maxSize)}`;case i:return`Video resolution is too high. Max resolution is ${r.maxResolution} pixels`;case a:return`The uploaded video exceeds the maximum size allowed. Please choose a video with smaller dimensions or reduce the resolution and try again. Max resolution is ${r.maxMatrix} pixels`}}},D0=t=>{if("object"!=typeof t||null===t)return!1;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||null===Object.getPrototypeOf(t)},O0=t=>D0(t)&&"type"in t&&"string"==typeof t.type,G=t=>{const e=e=>({type:t,payload:e});return e.toString=()=>`${t}`,e.type=t,e.match=e=>O0(e)&&e.type===t,e};G("remoteReady"),G("reselectUser"),G("requestLogin"),G("requestLogout"),G("setConfirmLeavePage"),G("requestChangePath"),G("wsSubscribe"),G("wsUnSubscribe"),G("hostStoreConnect"),G("remoteLogin"),G("remoteLogout"),G("wsOnMessage"),G("setRouterPath"),G("setDeviceType"),G("setUserError"),G("setUserIsError"),G("setUserPending"),G("setUserSuccess"),G("setUserData"),G("updateAccountData"),G("updateUser"),G("addNotification"),G("markNotification"),G("setNotificationsError"),G("setNotificationsList"),G("setNotificationsPending"),G("setNotificationsTotalCount"),G("setNotificationsUnreadCount"),G("resetNotificationsState"),G("undoNotification"),G("setInstanceInfo"),G("setInstanceInfoPending"),G("setInstanceInfoError");const M0=G("setPlatformSettings");G("setProfileSettings"),G("setGroupData"),G("setGroupLoading"),G("showGroupBasicInfo"),Au("requestMicroFrontendFetch"),Au("sendMicroFrontendFetchResponse");const P0={sms:"wellesley.admin.sms",auth:"wellesley.admin.auth",openai:"wellesley.admin.openai",uploads:"wellesley.admin.uploads",captcha:"wellesley.admin.captcha",language:"wellesley.admin.language",mediacache:"wellesley.admin.mediacache",translation:"wellesley.admin.translation"},Nu={posts:"wellesley.posts",translation:"wellesley.translation",registration:"wellesley.registration",confirmationCode:"wellesley.confirmationCode",uploadsPolicyDoc:"wellesley.uploads.policy.doc",uploadsPolicyAudio:"wellesley.uploads.policy.audio",uploadsPolicyImage:"wellesley.uploads.policy.image",uploadsPolicyVideo:"wellesley.uploads.policy.video",captcha:"wellesley.captcha"},T0={data:null,isPending:!1},{posts:go,uploadsPolicyDoc:_u,uploadsPolicyAudio:_o,uploadsPolicyImage:Fr,uploadsPolicyVideo:Un,registration:U0,captcha:N0}=Nu,{captcha:B0,language:F0,translation:W0,openai:$0}=P0,fn=t=>t.data,H0=Ht(fn,(t=>{var e,n,r;return{max_characters:(null==(e=null==t?void 0:t[go])?void 0:e.max_characters)||0,max_media_attachments:(null==(n=null==t?void 0:t[go])?void 0:n.max_media_attachments)||0,max_pins:(null==(r=null==t?void 0:t[go])?void 0:r.max_pins)||0}})),Bu=Ht(fn,(t=>{var e,n,r;return{...null==t?void 0:t[Fr],maxSize:(null==(e=null==t?void 0:t[Fr])?void 0:e.maxSize)||0,maxMatrix:(null==(n=null==t?void 0:t[Fr])?void 0:n.maxMatrix)||0,maxResolution:(null==(r=null==t?void 0:t[Fr])?void 0:r.maxResolution)||0}})),Fu=Ht(fn,(t=>{var e,n,r,i;return{...null==t?void 0:t[Un],maxSize:(null==(e=null==t?void 0:t[Un])?void 0:e.maxSize)||0,maxMatrix:(null==(n=null==t?void 0:t[Un])?void 0:n.maxMatrix)||0,maxDuration:(null==(r=null==t?void 0:t[Un])?void 0:r.maxDuration)||0,maxResolution:(null==(i=null==t?void 0:t[Un])?void 0:i.maxResolution)||0}})),Wu=Ht(fn,(t=>{var e,n;return{...null==t?void 0:t[_o],maxSize:null==(e=null==t?void 0:t[_o])?void 0:e.maxSize,keepOriginal:(null==(n=null==t?void 0:t[_o])?void 0:n.keepOriginal)||0}})),$u=Ht(fn,(t=>{var e;return{...null==t?void 0:t[_u],maxSize:(null==(e=null==t?void 0:t[_u])?void 0:e.maxSize)||0}})),Hu=Ht([Bu,Fu,Wu,$u],((t,e,n,r)=>({IMAGE:null==t?void 0:t.extensions,VIDEO:null==e?void 0:e.extensions,AUDIO:null==n?void 0:n.extensions,DOCUMENT:null==r?void 0:r.extensions}))),Y0=Ht(Hu,(t=>Object.keys(t).reduce(((e,n)=>[...e,...t[n]||[]]),[]))),$t=K_({name:"platformSettings",initialState:T0,reducers:{setError:(t,e)=>{t.error=e.payload},setPending:(t,e)=>{t.isPending=e.payload}},extraReducers:t=>{t.addCase(M0,((t,{payload:e})=>{t.data={...t.data,...e}}))},selectors:{selectSettings:fn,selectPostConfig:H0,selectDocPolicy:$u,selectImagePolicy:Bu,selectVideoPolicy:Fu,selectAudioPolicy:Wu,selectSupportedExtensions:Hu,selectFullExtensionsList:Y0,selectRegistration:t=>{var e;return null==(e=t.data)?void 0:e[U0]},selectLanguageDetection:t=>{var e;return null==(e=t.data)?void 0:e[F0]},selectLanguageTranslation:t=>{var e;return null==(e=t.data)?void 0:e[W0]},selectOpenai:t=>{var e;return null==(e=t.data)?void 0:e[$0]},selectCaptcha:t=>{var e;return null==(e=t.data)?void 0:e[N0]},selectAdminCaptcha:t=>{var e;return null==(e=t.data)?void 0:e[B0]},selectPlatformTranslation:t=>{var e;return null==(e=t.data)?void 0:e[Nu.translation]}}}),Yu=()=>{const[t]=$_(),e=new AbortController,n=e.signal,r=Ft($t.selectors.selectImagePolicy),i=Ft($t.selectors.selectVideoPolicy),o=Ft($t.selectors.selectDocPolicy),a=Ft($t.selectors.selectAudioPolicy);return[async({media:e,tag:u,onError:s,onUpload:c})=>{var l;const f=Kr(e.file.name),h=await L0({imgPolicy:r,docPolicy:o,videoPolicy:i,audioPolicy:a,media:e});if(h)return $r.error(h),void(null==s||s());try{const r=await t({createUpload:{extension:f,tags:[u],meta:{name:e.file.name}}});if("error"in r)throw new Error(r.error);const i=null==(l=r.data)?void 0:l.uri;return await J_({url:i,method:"PUT",body:e.file,signal:n}),null==c||c(),r.data.upload.uploadId}catch(t){null==s||s(t),$r(`Could not upload file. ${t}`)}},()=>e.abort("Upload canceled")]};var wu,Bn={exports:{}},K0=Bn.exports;
1
+ import{api as W_,handleBasicResponse as Ur,usePostApiV1UploadsMutation as $_,useDeleteApiV1UploadsByIdMutation as H_,usePostApiV1UploadsByIdMetaMutation as Y_}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@1.0.506";import{useSelector as Ft}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{toast as $r}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{createAction as Au,createSelector as Ht,createSlice as K_}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import j,{useRef as Wn,useState as Be,useEffect as $n,forwardRef as xo,PureComponent as G_,createRef as su,useCallback as X_,useLayoutEffect as q_,createElement as vo}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{useIsMobile as k_,cn as Hr,Dialog as z_,DialogContent as Z_,Button as po}from"https://cdn.jsdelivr.net/npm/@wellesley/ui@1.0.468";const V_=W_.enhanceEndpoints({endpoints:{postApiV1UploadsByIdMeta:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e,"Updated")}},postApiV1UploadsList:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e)}},postApiV1UploadsBatch:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e,"Deleted")}},putApiV1UploadsByIdTags:{async onQueryStarted(t,{queryFulfilled:e}){await Ur(e)}}}}),{usePostApiV1UploadsByIdMetaMutation:Uw,usePostApiV1UploadsListMutation:Nw,usePutApiV1UploadsByIdTagsMutation:Bw,usePostApiV1UploadsBatchMutation:Fw}=V_;var un=(t=>(t.done="done",t.inprogress="inprogress",t))(un||{}),Wt=(t=>(t.image="image",t.video="video",t.audio="audio",t))(Wt||{}),Eu=(t=>(t.post="$post",t.album="$album",t.avatar="$avatar",t.header="$header",t))(Eu||{});const Kr=t=>{const e=t.toLowerCase().match(/\.([a-zA-Z0-9]{2,4})(\?|$)+/);return e?e[1]:void 0},J_=async({url:t,...e})=>{const n=await fetch(t,e);if(!n.ok)throw new Error(n.statusText);if("PUT"===e.method)return;const r=await n.json(),i=r;if(i.errorCode)throw new Error(i.message);return r},Q_=t=>t.replace(/\.[^.]*$/,""),Ru=()=>"object"!=typeof window,j_=()=>!Ru()&&/iPhone|iPod|iPad/gi.test(window.navigator.userAgent),Fn="8.48.0",gt=globalThis;function yo(t,e,n){const r=gt,i=r.__SENTRY__=r.__SENTRY__||{},o=i[Fn]=i[Fn]||{};return o[t]||(o[t]=e())}const bu=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,e0="Sentry Logger ",au=["debug","info","warn","error","log","assert","trace"],uu={};function t0(t){if(!("console"in gt))return t();const e=gt.console,n={},r=Object.keys(uu);r.forEach((t=>{const r=uu[t];n[t]=e[t],e[t]=r}));try{return t()}finally{r.forEach((t=>{e[t]=n[t]}))}}function n0(){let t=!1;const e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return bu?au.forEach((n=>{e[n]=(...e)=>{t&&t0((()=>{gt.console[n](`${e0}[${n}]:`,...e)}))}})):au.forEach((t=>{e[t]=()=>{}})),e}const Wr=yo("logger",n0);function So(){return Co(gt),gt}function Co(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||Fn,e[Fn]=e[Fn]||{}}const r0=Object.prototype.toString;function i0(t,e){return r0.call(t)===`[object ${e}]`}function o0(t){return i0(t,"Object")}function s0(t){return!(!t||!t.then||"function"!=typeof t.then)}function a0(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{bu&&Wr.log(`Failed to add non-enumerable property "${e}" to object`,t)}}const Lu=1e3;function Du(){return Date.now()/Lu}function u0(){const{performance:t}=gt;if(!t||!t.now)return Du;const e=Date.now()-t.now(),n=null==t.timeOrigin?e:t.timeOrigin;return()=>(n+t.now())/Lu}const c0=u0();function cn(){const t=gt,e=t.crypto||t.msCrypto;let n=()=>16*Math.random();try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{const t=new Uint8Array(1);return e.getRandomValues(t),t[0]})}catch{}return"10000000100040008000100000000000".replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}function l0(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||c0(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=32===e.sid.length?e.sid:cn()),void 0!==e.init&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),"number"==typeof e.started&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof e.duration)t.duration=e.duration;else{const e=t.timestamp-t.started;t.duration=e>=0?e:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),"number"==typeof e.errors&&(t.errors=e.errors),e.status&&(t.status=e.status)}function cu(){return cn()}function lu(){return cn().substring(16)}function Ou(t,e,n=2){if(!e||"object"!=typeof e||n<=0)return e;if(t&&e&&0===Object.keys(e).length)return t;const r={...t};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=Ou(r[t],e[t],n-1));return r}(()=>{const{performance:t}=gt;if(!t||!t.now)return;const e=36e5,n=t.now(),r=Date.now(),i=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,o=i<e,a=t.timing&&t.timing.navigationStart,u="number"==typeof a?Math.abs(a+n-r):e;(o||u<e)&&(i<=u&&t.timeOrigin)})();const mo="_sentrySpan";function fu(t,e){e?a0(t,mo,e):delete t[mo]}function hu(t){return t[mo]}const f0=100;class Io{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:cu(),spanId:lu()}}clone(){const t=new Io;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._requestSession=this._requestSession,t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,fu(t,hu(this)),t}setClient(t){this._client=t}setLastEventId(t){this._lastEventId=t}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(t){this._scopeListeners.push(t)}addEventProcessor(t){return this._eventProcessors.push(t),this}setUser(t){return this._user=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&l0(this._session,{user:t}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(t){return this._requestSession=t,this}setTags(t){return this._tags={...this._tags,...t},this._notifyScopeListeners(),this}setTag(t,e){return this._tags={...this._tags,[t]:e},this._notifyScopeListeners(),this}setExtras(t){return this._extra={...this._extra,...t},this._notifyScopeListeners(),this}setExtra(t,e){return this._extra={...this._extra,[t]:e},this._notifyScopeListeners(),this}setFingerprint(t){return this._fingerprint=t,this._notifyScopeListeners(),this}setLevel(t){return this._level=t,this._notifyScopeListeners(),this}setTransactionName(t){return this._transactionName=t,this._notifyScopeListeners(),this}setContext(t,e){return null===e?delete this._contexts[t]:this._contexts[t]=e,this._notifyScopeListeners(),this}setSession(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const e="function"==typeof t?t(this):t,[n,r]=e instanceof Hn?[e.getScopeData(),e.getRequestSession()]:o0(e)?[t,t.requestSession]:[],{tags:i,extra:o,user:a,contexts:u,level:s,fingerprint:c=[],propagationContext:l}=n||{};return this._tags={...this._tags,...i},this._extra={...this._extra,...o},this._contexts={...this._contexts,...u},a&&Object.keys(a).length&&(this._user=a),s&&(this._level=s),c.length&&(this._fingerprint=c),l&&(this._propagationContext=l),r&&(this._requestSession=r),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,fu(this,void 0),this._attachments=[],this.setPropagationContext({traceId:cu()}),this._notifyScopeListeners(),this}addBreadcrumb(t,e){const n="number"==typeof e?e:f0;if(n<=0)return this;const r={timestamp:Du(),...t},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(t){return this._attachments.push(t),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:hu(this)}}setSDKProcessingMetadata(t){return this._sdkProcessingMetadata=Ou(this._sdkProcessingMetadata,t,2),this}setPropagationContext(t){return this._propagationContext={spanId:lu(),...t},this}getPropagationContext(){return this._propagationContext}captureException(t,e){const n=e&&e.event_id?e.event_id:cn();if(!this._client)return Wr.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this._client.captureException(t,{originalException:t,syntheticException:r,...e,event_id:n},this),n}captureMessage(t,e,n){const r=n&&n.event_id?n.event_id:cn();if(!this._client)return Wr.warn("No client configured on scope - will not capture message!"),r;const i=new Error(t);return this._client.captureMessage(t,e,{originalException:t,syntheticException:i,...n,event_id:r},this),r}captureEvent(t,e){const n=e&&e.event_id?e.event_id:cn();return this._client?(this._client.captureEvent(t,{...e,event_id:n},this),n):(Wr.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((t=>{t(this)})),this._notifyingListeners=!1)}}const Hn=Io;function h0(){return yo("defaultCurrentScope",(()=>new Hn))}function d0(){return yo("defaultIsolationScope",(()=>new Hn))}class p0{constructor(t,e){let n,r;n=t||new Hn,r=e||new Hn,this._stack=[{scope:n}],this._isolationScope=r}withScope(t){const e=this._pushScope();let n;try{n=t(e)}catch(t){throw this._popScope(),t}return s0(n)?n.then((t=>(this._popScope(),t)),(t=>{throw this._popScope(),t})):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const t=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:t}),t}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}}function ln(){const t=Co(So());return t.stack=t.stack||new p0(h0(),d0())}function g0(t){return ln().withScope(t)}function _0(t,e){const n=ln();return n.withScope((()=>(n.getStackTop().scope=t,e(t))))}function du(t){return ln().withScope((()=>t(ln().getIsolationScope())))}function w0(){return{withIsolationScope:du,withScope:g0,withSetScope:_0,withSetIsolationScope:(t,e)=>du(e),getCurrentScope:()=>ln().getScope(),getIsolationScope:()=>ln().getIsolationScope()}}function Mu(t){const e=Co(t);return e.acs?e.acs:w0()}function Pu(){return Mu(So()).getCurrentScope()}function v0(){return Mu(So()).getIsolationScope()}function m0(t,e){return Pu().captureException(t,void 0)}function x0(t,e){const n={captureContext:e};return Pu().captureMessage(t,void 0,n)}function y0(t,e){v0().setExtra(t,e)}var Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const S0=(...t)=>{let e="";for(const n of t){if(n instanceof Error){const t=n;return y0("exceptionMessage",e),void m0(t)}if("object"!=typeof n)e+=n;else try{e+=" "+JSON.stringify(n)}catch{e+=" "+n}}x0(e)},C0="wlsy",Tu=()=>{try{return window.localStorage}catch(t){console.warn("Error getting window.localStorage storage",t)}},I0=()=>{const t=new Set,e=Tu();if(!e)return[];for(let n=0;n<(null==e?void 0:e.length);n+=1){const r=null==e?void 0:e.key(n);"string"==typeof r&&t.add(r)}return Array.from(t)},A0=t=>{const e=`${C0}`,n=t=>`${e}:${t}`,r=()=>I0().filter((t=>t.startsWith(`${e}:`))),i=t=>t.slice(e.length+1),o=Tu(),a=t=>{try{return null==o?void 0:o.getItem(n(t))}catch{return null}},u=(t,e)=>{try{null==o||o.setItem(n(t),String(e))}catch{return}};return{getItem:a,setItem:u,removeItem:t=>{try{null==o||o.removeItem(n(t))}catch{return}},clear:()=>{try{r().forEach((t=>null==o?void 0:o.removeItem(t)))}catch{return}},keys:()=>r().map(i),has:t=>null!==a(t),getJSON:t=>{const e=a(t);if(null==e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(t,e)=>{try{u(t,JSON.stringify(e))}catch{return}}}},pu=["debug","info","warn","error"],E0=(t,e)=>{const n=pu.indexOf(t);return pu.indexOf(e)>=n},Br=(t,e,n,...r)=>{E0(e,t)&&console.log(`[${t}] ${n}`,...r)},R0=()=>A0().getItem("logger_lvl"),b0=(t=(Ru()?"info":R0()||"warn"))=>{let e=t;return{debug:(t,...n)=>Br("debug",e,t,...n),info:(t,...n)=>Br("info",e,t,...n),warn:(t,...n)=>Br("warn",e,t,...n),error:(t,...n)=>(S0(t,...n),Br("error",e,t,...n)),setLevel:t=>{e=t},getLevel:()=>e}},Ao=b0(),Uu=({src:t,name:e=""})=>new Promise(((n,r)=>{const i=document.createElement("video");i.src=t;const o=()=>{const{duration:t,videoHeight:o,videoWidth:a,src:u}=i,s=Q_(e);(!t||!o||!a||!u)&&r(),n({src:u,name:s,width:a,height:o,duration:Math.floor(t)})},a=()=>{Ao.warn("Failed to load video"),n(null)};return j_()&&i.load(),i.addEventListener("error",a),i.addEventListener("loadeddata",o),()=>{i.removeEventListener("error",a),i.removeEventListener("loadeddata",o)}})),Eo=t=>new Promise(((e,n)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{e({width:r.naturalWidth,height:r.naturalHeight}),URL.revokeObjectURL(i)},r.onerror=()=>{Ao.warn("Failed to load image"),n(null),URL.revokeObjectURL(i)},r.src=i})),gu=t=>{if(!t)return;const e="number"==typeof t?t:parseInt(t,10);if(isNaN(e))throw new Error("Can not get number from income argument");const n=e/1048576;return`${Math.floor(n)} MB`},L0=async({media:t,docPolicy:e,imgPolicy:n,videoPolicy:r,audioPolicy:i})=>{if(!n||!r)return"Media policy is not defined";const o={IMAGE:n.extensions,VIDEO:r.extensions,AUDIO:i.extensions,DOCUMENT:e.extensions},a=Kr(t.file.name)||"",u=Object.keys(o).find((t=>{var e;return null==(e=o[t])?void 0:e.includes(a)}));if(!u)return`Extension ${a} is not supported`;const s="VIDEO"===u;if("IMAGE"===u){const e=await Eo(t.file),r=t.file.size>n.maxSize,i=e&&Math.max(e.width,e.height)>n.maxResolution,o=e&&e.width*e.height>n.maxMatrix;switch(!0){case r:return`Image is too big. Max size is ${gu(n.maxSize)}`;case i:return`Image resolution is too high. Max resolution is ${n.maxResolution} pixels`;case o:return`The uploaded image exceeds the maximum size allowed. Please choose an image with smaller dimensions or reduce the resolution and try again. Max resolution is ${n.maxMatrix} pixels`}}if(s){const e=await Uu({src:t.objectUrl}),n=e&&e.duration>r.maxDuration,i=e&&Math.max(e.width,e.height)>r.maxResolution,o=t.file.size>r.maxSize,a=e&&e.width*e.height>r.maxMatrix;switch(!0){case n:return`Video is too long. Max duration is ${r.maxDuration} seconds`;case o:return`Video is too big. Max size is ${gu(r.maxSize)}`;case i:return`Video resolution is too high. Max resolution is ${r.maxResolution} pixels`;case a:return`The uploaded video exceeds the maximum size allowed. Please choose a video with smaller dimensions or reduce the resolution and try again. Max resolution is ${r.maxMatrix} pixels`}}},D0=t=>{if("object"!=typeof t||null===t)return!1;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||null===Object.getPrototypeOf(t)},O0=t=>D0(t)&&"type"in t&&"string"==typeof t.type,G=t=>{const e=e=>({type:t,payload:e});return e.toString=()=>`${t}`,e.type=t,e.match=e=>O0(e)&&e.type===t,e};G("remoteReady"),G("reselectUser"),G("requestLogin"),G("requestLogout"),G("setConfirmLeavePage"),G("requestChangePath"),G("wsSubscribe"),G("wsUnSubscribe"),G("hostStoreConnect"),G("remoteLogin"),G("remoteLogout"),G("wsOnMessage"),G("setRouterPath"),G("setDeviceType"),G("setUserError"),G("setUserIsError"),G("setUserPending"),G("setUserSuccess"),G("setUserData"),G("updateAccountData"),G("updateUser"),G("addNotification"),G("markNotification"),G("setNotificationsError"),G("setNotificationsList"),G("setNotificationsPending"),G("setNotificationsTotalCount"),G("setNotificationsUnreadCount"),G("resetNotificationsState"),G("undoNotification"),G("setInstanceInfo"),G("setInstanceInfoPending"),G("setInstanceInfoError");const M0=G("setPlatformSettings");G("setProfileSettings"),G("setGroupData"),G("setGroupLoading"),G("showGroupBasicInfo"),Au("requestMicroFrontendFetch"),Au("sendMicroFrontendFetchResponse");const P0={sms:"wellesley.admin.sms",auth:"wellesley.admin.auth",openai:"wellesley.admin.openai",uploads:"wellesley.admin.uploads",captcha:"wellesley.admin.captcha",language:"wellesley.admin.language",mediacache:"wellesley.admin.mediacache",translation:"wellesley.admin.translation"},Nu={posts:"wellesley.posts",translation:"wellesley.translation",registration:"wellesley.registration",confirmationCode:"wellesley.confirmationCode",uploadsPolicyDoc:"wellesley.uploads.policy.doc",uploadsPolicyAudio:"wellesley.uploads.policy.audio",uploadsPolicyImage:"wellesley.uploads.policy.image",uploadsPolicyVideo:"wellesley.uploads.policy.video",captcha:"wellesley.captcha"},T0={data:null,isPending:!1},{posts:go,uploadsPolicyDoc:_u,uploadsPolicyAudio:_o,uploadsPolicyImage:Fr,uploadsPolicyVideo:Un,registration:U0,captcha:N0}=Nu,{captcha:B0,language:F0,translation:W0,openai:$0}=P0,fn=t=>t.data,H0=Ht(fn,(t=>{var e,n,r;return{max_characters:(null==(e=null==t?void 0:t[go])?void 0:e.max_characters)||0,max_media_attachments:(null==(n=null==t?void 0:t[go])?void 0:n.max_media_attachments)||0,max_pins:(null==(r=null==t?void 0:t[go])?void 0:r.max_pins)||0}})),Bu=Ht(fn,(t=>{var e,n,r;return{...null==t?void 0:t[Fr],maxSize:(null==(e=null==t?void 0:t[Fr])?void 0:e.maxSize)||0,maxMatrix:(null==(n=null==t?void 0:t[Fr])?void 0:n.maxMatrix)||0,maxResolution:(null==(r=null==t?void 0:t[Fr])?void 0:r.maxResolution)||0}})),Fu=Ht(fn,(t=>{var e,n,r,i;return{...null==t?void 0:t[Un],maxSize:(null==(e=null==t?void 0:t[Un])?void 0:e.maxSize)||0,maxMatrix:(null==(n=null==t?void 0:t[Un])?void 0:n.maxMatrix)||0,maxDuration:(null==(r=null==t?void 0:t[Un])?void 0:r.maxDuration)||0,maxResolution:(null==(i=null==t?void 0:t[Un])?void 0:i.maxResolution)||0}})),Wu=Ht(fn,(t=>{var e,n;return{...null==t?void 0:t[_o],maxSize:null==(e=null==t?void 0:t[_o])?void 0:e.maxSize,keepOriginal:(null==(n=null==t?void 0:t[_o])?void 0:n.keepOriginal)||0}})),$u=Ht(fn,(t=>{var e;return{...null==t?void 0:t[_u],maxSize:(null==(e=null==t?void 0:t[_u])?void 0:e.maxSize)||0}})),Hu=Ht([Bu,Fu,Wu,$u],((t,e,n,r)=>({IMAGE:null==t?void 0:t.extensions,VIDEO:null==e?void 0:e.extensions,AUDIO:null==n?void 0:n.extensions,DOCUMENT:null==r?void 0:r.extensions}))),Y0=Ht(Hu,(t=>Object.keys(t).reduce(((e,n)=>[...e,...t[n]||[]]),[]))),$t=K_({name:"platformSettings",initialState:T0,reducers:{setError:(t,e)=>{t.error=e.payload},setPending:(t,e)=>{t.isPending=e.payload}},extraReducers:t=>{t.addCase(M0,((t,{payload:e})=>{t.data={...t.data,...e}}))},selectors:{selectSettings:fn,selectPostConfig:H0,selectDocPolicy:$u,selectImagePolicy:Bu,selectVideoPolicy:Fu,selectAudioPolicy:Wu,selectSupportedExtensions:Hu,selectFullExtensionsList:Y0,selectRegistration:t=>{var e;return null==(e=t.data)?void 0:e[U0]},selectLanguageDetection:t=>{var e;return null==(e=t.data)?void 0:e[F0]},selectLanguageTranslation:t=>{var e;return null==(e=t.data)?void 0:e[W0]},selectOpenai:t=>{var e;return null==(e=t.data)?void 0:e[$0]},selectCaptcha:t=>{var e;return null==(e=t.data)?void 0:e[N0]},selectAdminCaptcha:t=>{var e;return null==(e=t.data)?void 0:e[B0]},selectPlatformTranslation:t=>{var e;return null==(e=t.data)?void 0:e[Nu.translation]}}}),Yu=()=>{const[t]=$_(),e=new AbortController,n=e.signal,r=Ft($t.selectors.selectImagePolicy),i=Ft($t.selectors.selectVideoPolicy),o=Ft($t.selectors.selectDocPolicy),a=Ft($t.selectors.selectAudioPolicy);return[async({media:e,tag:u,onError:s,onUpload:c})=>{var l;const f=Kr(e.file.name),h=await L0({imgPolicy:r,docPolicy:o,videoPolicy:i,audioPolicy:a,media:e});if(h)return $r.error(h),void(null==s||s());try{const r=await t({createUpload:{extension:f,tags:[u],meta:{name:e.file.name}}});if("error"in r)throw new Error(r.error);const i=null==(l=r.data)?void 0:l.uri;return await J_({url:i,method:"PUT",body:e.file,signal:n}),null==c||c(),r.data.upload.uploadId}catch(t){null==s||s(t),$r(`Could not upload file. ${t}`)}},()=>e.abort("Upload canceled")]};var wu,Bn={exports:{}},K0=Bn.exports;
2
2
  /**
3
3
  * @license
4
4
  * Lodash <https://lodash.com/>
@@ -15,7 +15,7 @@ import{api as W_,handleBasicResponse as Ur,usePostApiV1UploadsMutation as $_,use
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */function rw(){if(mu)return Nn;mu=1;var t=j,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(t,n,a){var u,s={},c=null,l=null;for(u in void 0!==a&&(c=""+a),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(l=n.ref),n)r.call(n,u)&&!o.hasOwnProperty(u)&&(s[u]=n[u]);if(t&&t.defaultProps)for(u in n=t.defaultProps)void 0===s[u]&&(s[u]=n[u]);return{$$typeof:e,type:t,key:c,ref:l,props:s,_owner:i.current}}return Nn.Fragment=n,Nn.jsx=a,Nn.jsxs=a,Nn}function iw(){return xu||(xu=1,wo.exports=rw()),wo.exports}var ne=iw();const qu=xo((({accept:t,onChange:e},n)=>ne.jsx("input",{ref:n,"data-testid":"input-file",accept:t,type:"file",onChange:({target:t})=>{if(!t.files)return;const n=Array.from(t.files).map((t=>({file:t,objectUrl:URL.createObjectURL(t)})));e(n),t.value=""},id:"inputFile",className:"hidden"})));qu.displayName="UploadButton";const Kw=()=>{const{extensions:t}=Ft($t.selectors.selectImagePolicy),[e]=Yu(),n=(t||[]).map((t=>`.${t}`)).join(),[r,i]=Be({width:0,height:0}),[o,a]=Be(""),[u,s]=Be(!1),c=async t=>{try{const[e]=t,n=await Eo(e.file);n&&i(n),a(e.objectUrl)}catch(t){$r.error("Upload image error"),Ao.error(`Upload image error: ${t}`)}};return{sizes:r,preview:o,acceptList:n,isModalOpen:u,uploadFile:e,onClose:()=>{s(!1),a("")},onUpload:t=>{c(t),s(!0)},handleFileChange:c}},Yr={x:0,y:0,width:0,height:0,unit:"px"},on=(t,e,n)=>Math.min(Math.max(t,e),n),ow=(...t)=>t.filter((t=>t&&"string"==typeof t)).join(" "),yu=(t,e)=>t===e||t.width===e.width&&t.height===e.height&&t.x===e.x&&t.y===e.y&&t.unit===e.unit;function sn(t,e,n){return"%"===t.unit?{...Yr,...t,unit:"%"}:{unit:"%",x:t.x?t.x/e*100:0,y:t.y?t.y/n*100:0,width:t.width?t.width/e*100:0,height:t.height?t.height/n*100:0}}function At(t,e,n){return t.unit?"px"===t.unit?{...Yr,...t,unit:"px"}:{unit:"px",x:t.x?t.x*e/100:0,y:t.y?t.y*n/100:0,width:t.width?t.width*e/100:0,height:t.height?t.height*n/100:0}:{...Yr,...t,unit:"px"}}function Su(t,e,n,r,i,o=0,a=0,u=r,s=i){const c={...t};let l=Math.min(o,r),f=Math.min(a,i),h=Math.min(u,r),p=Math.min(s,i);e&&(e>1?(l=a?a*e:l,f=l/e,h=u*e):(f=o?o/e:f,l=f*e,p=s/e)),c.y<0&&(c.height=Math.max(c.height+c.y,f),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,l),c.x=0);const d=r-(c.x+c.width);d<0&&(c.x=Math.min(c.x,r-l),c.width+=d);const g=i-(c.y+c.height);if(g<0&&(c.y=Math.min(c.y,i-f),c.height+=g),c.width<l&&(("sw"===n||"nw"==n)&&(c.x-=l-c.width),c.width=l),c.height<f&&(("nw"===n||"ne"==n)&&(c.y-=f-c.height),c.height=f),c.width>h&&(("sw"===n||"nw"==n)&&(c.x-=h-c.width),c.width=h),c.height>p&&(("nw"===n||"ne"==n)&&(c.y-=p-c.height),c.height=p),e){const t=c.width/c.height;if(t<e){const t=Math.max(c.width/e,f);("nw"===n||"ne"==n)&&(c.y-=t-c.height),c.height=t}else if(t>e){const t=Math.max(c.height*e,l);("sw"===n||"nw"==n)&&(c.x-=t-c.width),c.width=t}}return c}function sw(t,e,n,r){const i={...t};return"ArrowLeft"===e?"nw"===r?(i.x-=n,i.y-=n,i.width+=n,i.height+=n):"w"===r?(i.x-=n,i.width+=n):"sw"===r?(i.x-=n,i.width+=n,i.height+=n):"ne"===r?(i.y+=n,i.width-=n,i.height-=n):"e"===r?i.width-=n:"se"===r&&(i.width-=n,i.height-=n):"ArrowRight"===e&&("nw"===r?(i.x+=n,i.y+=n,i.width-=n,i.height-=n):"w"===r?(i.x+=n,i.width-=n):"sw"===r?(i.x+=n,i.width-=n,i.height-=n):"ne"===r?(i.y-=n,i.width+=n,i.height+=n):"e"===r?i.width+=n:"se"===r&&(i.width+=n,i.height+=n)),"ArrowUp"===e?"nw"===r?(i.x-=n,i.y-=n,i.width+=n,i.height+=n):"n"===r?(i.y-=n,i.height+=n):"ne"===r?(i.y-=n,i.width+=n,i.height+=n):"sw"===r?(i.x+=n,i.width-=n,i.height-=n):"s"===r?i.height-=n:"se"===r&&(i.width-=n,i.height-=n):"ArrowDown"===e&&("nw"===r?(i.x+=n,i.y+=n,i.width-=n,i.height-=n):"n"===r?(i.y+=n,i.height-=n):"ne"===r?(i.y+=n,i.width-=n,i.height-=n):"sw"===r?(i.x-=n,i.width+=n,i.height+=n):"s"===r?i.height+=n:"se"===r&&(i.width+=n,i.height+=n)),i}const an={capture:!0,passive:!1};let aw=0;const Et=class t extends G_{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=su(),this.mediaRef=su(),this.initChangeCalled=!1,this.instanceId="rc-"+aw++,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=t=>{const{crop:e,disabled:n}=this.props,r=this.getBox();if(!e)return;const i=At(e,r.width,r.height);if(n)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.target.dataset.ord,a=!!o;let u=t.clientX,s=t.clientY,c=i.x,l=i.y;if(o){const e=t.clientX-r.x,n=t.clientY-r.y;let a=0,f=0;"ne"===o||"e"==o?(a=e-(i.x+i.width),f=n-i.y,c=i.x,l=i.y+i.height):"se"===o||"s"===o?(a=e-(i.x+i.width),f=n-(i.y+i.height),c=i.x,l=i.y):"sw"===o||"w"==o?(a=e-i.x,f=n-(i.y+i.height),c=i.x+i.width,l=i.y):("nw"===o||"n"==o)&&(a=e-i.x,f=n-i.y,c=i.x+i.width,l=i.y+i.height),u=c+r.x+a,s=l+r.y+f}this.evData={startClientX:u,startClientY:s,startCropX:c,startCropY:l,clientX:t.clientX,clientY:t.clientY,isResize:a,ord:o},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=t=>{const{crop:e,disabled:n,locked:r,keepSelection:i,onChange:o}=this.props,a=this.getBox();if(n||r||i&&e)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.clientX-a.x,s=t.clientY-a.y,c={unit:"px",x:u,y:s,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:u,startCropY:s,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(At(c,a.width,a.height),sn(c,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=t=>{const{crop:e,disabled:n,onChange:r,onDragStart:i}=this.props,o=this.getBox();if(n||!e||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,i&&i(t));const{evData:a}=this;let u;a.clientX=t.clientX,a.clientY=t.clientY,u=a.isResize?this.resizeCrop():this.dragCrop(),yu(e,u)||r(At(u,o.width,o.height),sn(u,o.width,o.height))},this.onComponentKeyDown=e=>{const{crop:n,disabled:r,onChange:i,onComplete:o}=this.props;if(r)return;const a=e.key;let u=!1;if(!n)return;const s=this.getBox(),c=this.makePixelCrop(s),l=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?t.nudgeStepLarge:e.shiftKey?t.nudgeStepMedium:t.nudgeStep;if("ArrowLeft"===a?(c.x-=l,u=!0):"ArrowRight"===a?(c.x+=l,u=!0):"ArrowUp"===a?(c.y-=l,u=!0):"ArrowDown"===a&&(c.y+=l,u=!0),u){e.cancelable&&e.preventDefault(),c.x=on(c.x,0,s.width-c.width),c.y=on(c.y,0,s.height-c.height);const t=At(c,s.width,s.height),n=sn(c,s.width,s.height);i(t,n),o&&o(t,n)}},this.onHandlerKeyDown=(e,n)=>{const{aspect:r=0,crop:i,disabled:o,minWidth:a=0,minHeight:u=0,maxWidth:s,maxHeight:c,onChange:l,onComplete:f}=this.props,h=this.getBox();if(o||!i)return;if("ArrowUp"!==e.key&&"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.stopPropagation(),e.preventDefault();const p=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?t.nudgeStepLarge:e.shiftKey?t.nudgeStepMedium:t.nudgeStep,d=Su(sw(At(i,h.width,h.height),e.key,p,n),r,n,h.width,h.height,a,u,s,c);if(!yu(i,d)){const t=sn(d,h.width,h.height);l(d,t),f&&f(d,t)}},this.onDocPointerDone=t=>{const{crop:e,disabled:n,onComplete:r,onDragEnd:i}=this.props,o=this.getBox();this.unbindDocMove(),!n&&e&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,i&&i(t),r&&r(At(e,o.width,o.height),sn(e,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var t;null==(t=this.componentRef.current)||t.scrollTo(0,0)}}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:e,y:n,width:r,height:i}=t.getBoundingClientRect();return{x:e,y:n,width:r,height:i}}componentDidUpdate(t){const{crop:e,onComplete:n}=this.props;if(n&&!t.crop&&e){const{width:t,height:r}=this.getBox();t&&r&&n(At(e,t,r),sn(e,t,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,an),this.document.addEventListener("pointerup",this.onDocPointerDone,an),this.document.addEventListener("pointercancel",this.onDocPointerDone,an),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,an),this.document.removeEventListener("pointerup",this.onDocPointerDone,an),this.document.removeEventListener("pointercancel",this.onDocPointerDone,an),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,e=this.getBox(),n=this.makePixelCrop(e),r=t.clientX-t.startClientX,i=t.clientY-t.startClientY;return n.x=on(t.startCropX+r,0,e.width-n.width),n.y=on(t.startCropY+i,0,e.height-n.height),n}getPointRegion(t,e,n,r){const{evData:i}=this,o=i.clientX-t.x,a=i.clientY-t.y;let u,s;return u=r&&e?"nw"===e||"n"===e||"ne"===e:a<i.startCropY,s=n&&e?"nw"===e||"w"===e||"sw"===e:o<i.startCropX,s?u?"nw":"sw":u?"ne":"se"}resolveMinDimensions(t,e,n=0,r=0){const i=Math.min(n,t.width),o=Math.min(r,t.height);return e&&(i||o)?e>1?i?[i,i/e]:[o*e,o]:o?[o*e,o]:[i,i/e]:[i,o]}resizeCrop(){const{evData:e}=this,{aspect:n=0,maxWidth:r,maxHeight:i}=this.props,o=this.getBox(),[a,u]=this.resolveMinDimensions(o,n,this.props.minWidth,this.props.minHeight);let s=this.makePixelCrop(o);const c=this.getPointRegion(o,e.ord,a,u),l=e.ord||c;let f=e.clientX-e.startClientX,h=e.clientY-e.startClientY;(a&&"nw"===l||"w"===l||"sw"===l)&&(f=Math.min(f,-a)),(u&&"nw"===l||"n"===l||"ne"===l)&&(h=Math.min(h,-u));const p={unit:"px",x:0,y:0,width:0,height:0};"ne"===c?(p.x=e.startCropX,p.width=f,n?(p.height=p.width/n,p.y=e.startCropY-p.height):(p.height=Math.abs(h),p.y=e.startCropY-p.height)):"se"===c?(p.x=e.startCropX,p.y=e.startCropY,p.width=f,p.height=n?p.width/n:h):"sw"===c?(p.x=e.startCropX+f,p.y=e.startCropY,p.width=Math.abs(f),p.height=n?p.width/n:h):"nw"===c&&(p.x=e.startCropX+f,p.width=Math.abs(f),n?(p.height=p.width/n,p.y=e.startCropY-p.height):(p.height=Math.abs(h),p.y=e.startCropY+h));const d=Su(p,n,c,o.width,o.height,a,u,r,i);return n||t.xyOrds.indexOf(l)>-1?s=d:t.xOrds.indexOf(l)>-1?(s.x=d.x,s.width=d.width):t.yOrds.indexOf(l)>-1&&(s.y=d.y,s.height=d.height),s.x=on(s.x,0,o.width-s.width),s.y=on(s.y,0,o.height-s.height),s}renderCropSelection(){const{ariaLabels:e=t.defaultProps.ariaLabels,disabled:n,locked:r,renderSelectionAddon:i,ruleOfThirds:o,crop:a}=this.props,u=this.getCropStyle();if(a)return j.createElement("div",{style:u,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!n&&!r&&j.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},j.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"nw"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"n"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"ne"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"e"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"se"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"s"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"sw"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"w"),role:"button"})),i&&j.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:t=>t.stopPropagation()},i(this.state)),o&&j.createElement(j.Fragment,null,j.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),j.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){return At({...Yr,...this.props.crop||{}},t.width,t.height)}render(){const{aspect:t,children:e,circularCrop:n,className:r,crop:i,disabled:o,locked:a,style:u,ruleOfThirds:s}=this.props,{cropIsActive:c,newCropIsBeingDrawn:l}=this.state,f=i?this.renderCropSelection():null,h=ow("ReactCrop",r,c&&"ReactCrop--active",o&&"ReactCrop--disabled",a&&"ReactCrop--locked",l&&"ReactCrop--new-crop",i&&t&&"ReactCrop--fixed-aspect",i&&n&&"ReactCrop--circular-crop",i&&s&&"ReactCrop--rule-of-thirds",!this.dragStarted&&i&&!i.width&&!i.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return j.createElement("div",{ref:this.componentRef,className:h,style:u},j.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},e),i?j.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},j.createElement("defs",null,j.createElement("mask",{id:`hole-${this.instanceId}`},j.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?j.createElement("ellipse",{cx:`${i.x+i.width/2}${i.unit}`,cy:`${i.y+i.height/2}${i.unit}`,rx:`${i.width/2}${i.unit}`,ry:`${i.height/2}${i.unit}`,fill:"black"}):j.createElement("rect",{x:`${i.x}${i.unit}`,y:`${i.y}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`,fill:"black"}))),j.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};Et.xOrds=["e","w"],Et.yOrds=["n","s"],Et.xyOrds=["nw","ne","se","sw"],Et.nudgeStep=1,Et.nudgeStepMedium=10,Et.nudgeStepLarge=100,Et.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};let uw=Et;const cw=async(t,e,n="image/jpeg",r=1,i=0,o=0)=>{if(!e.width||!e.height)throw new Error("Crop size is invalid");const a=document.createElement("canvas"),u=t.naturalWidth/t.width,s=t.naturalHeight/t.height;a.width=e.width,a.height=e.height;const c=a.getContext("2d");if(!c)throw new Error("2D context not available");const l=t.width/2,f=t.height/2,h=((e.x-i-l)/r+l)*u,p=((e.y-o-f)/r+f)*s,d=e.width/r*u,g=e.height/r*s;return c.drawImage(t,h,p,d,g,0,0,e.width,e.height),new Promise(((t,e)=>{a.toBlob((n=>{n?t(n):e(new Error("Failed to generate cropped image"))}),n)}))},lw=({onChange:t,zoom:e=1,pan:n})=>{const[r,i]=Be(),o=Wn(null),[a,u]=Be("");return $n((()=>((async()=>{if(!r||!o.current)return;const i=await cw(o.current,r,"image/jpeg",e,(null==n?void 0:n.x)??0,(null==n?void 0:n.y)??0),a=URL.createObjectURL(i);u(a),null==t||t(a)})(),()=>{a&&URL.revokeObjectURL(a)})),[r,o.current,t,e,null==n?void 0:n.x,null==n?void 0:n.y]),[o,i]},fw=560,Cu=400,Iu=.8,hw=(t,e,n)=>{const r=n,i=560/t.width,o=r/t.height,a=Math.min(1,i,o),u=t.width*a,s=t.height*a,c=Math.min(u,s*e),l=Math.min(u*Iu,Cu),f=Math.min(s*Iu,Cu),h=Math.min(l,f*e,c),p=h/e;return{unit:"px",x:(u-h)/2,y:(s-p)/2,width:h,height:p}},dw=({aspect:t=1,sizes:e,imgMaxHeight:n})=>{const[r,i]=Be();return $n((()=>{(null==e?void 0:e.width)&&e.height&&n&&i(hw(e,t,n))}),[null==e?void 0:e.height,null==e?void 0:e.width,n,t]),[r,i]},pw=({zoom:t,initialPan:e})=>{const[n,r]=Be(e??{x:0,y:0}),i=Wn(!1),o=Wn(null),a=X_((e=>{e.preventDefault();const a=e.clientX,u=e.clientY;i.current=!0,o.current={x:a,y:u,panX:n.x,panY:n.y};const s=e=>{if(!o.current)return;const n=(e.clientX-o.current.x)/t,i=(e.clientY-o.current.y)/t;r({x:o.current.panX+n,y:o.current.panY+i})},c=()=>{i.current=!1,o.current=null,window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)};window.addEventListener("pointermove",s),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)}),[n.x,n.y,t]);return{pan:n,setPan:r,onPointerDown:a,isDragging:i.current}},gw=({src:t,sizes:e,aspect:n=1,circularCrop:r,zoom:i=1,pan:o,imgMaxHeight:a,className:u,onChange:s})=>{const[c]=dw({sizes:e,aspect:n,imgMaxHeight:a}),[l,f]=Be(0),[h,p]=Be(!1),{pan:d,onPointerDown:g,isDragging:v}=pw({zoom:i,initialPan:o}),_=o??d,[y,w]=lw({onChange:s,zoom:i,pan:_}),m={"--cropRadius":`${l}px`},x=()=>{p(!0),c&&(w(c),f((c.width??0)/3))};return $n((()=>{!h||!c||(w(c),f((c.width??0)/3))}),[h,c,w]),$n((()=>{p(!1)}),[t]),ne.jsx("div",{style:m,children:h?ne.jsx(uw,{crop:c,aspect:n,circularCrop:r,keepSelection:!0,locked:!0,onChange:t=>{f(t.width/3)},onComplete:w,children:ne.jsx("img",{src:t,ref:y,crossOrigin:"anonymous",style:{maxHeight:a?`${a}px`:"auto",transform:`translate(${_.x}px, ${_.y}px) scale(${i})`,transformOrigin:"center center",cursor:v?"grabbing":"grab"},className:Hr("mx-auto my-0",u),onLoad:x,onPointerDown:g})}):ne.jsx("img",{src:t,ref:y,crossOrigin:"anonymous",style:{maxHeight:a?`${a}px`:"auto"},className:Hr("mx-auto my-0",u),onLoad:x})})},_w=({open:t,modal:e,children:n,onCloseModal:r,className:i,...o})=>ne.jsx(z_,{open:t,modal:e,onOpenChange:t=>{t||null==r||r()},children:ne.jsx(Z_,{className:Hr(i),closeSize:"small",closeVariant:"insideCard",onCloseModal:r,...o,childrenClassName:Hr("overflow-auto",o.title?"max-h-[635px]":"max-h-[700px]",o.childrenClassName),children:n})}),ww=40,vw=165,mw=.8,xw=()=>{const t=Wn(null),[e,n]=Be(0);return q_((()=>{const t=()=>{const t=window.innerHeight*mw-40,e=Math.max(0,t-vw);n(e)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}),[]),[t,e]},yw=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ku=(...t)=>t.filter(((t,e,n)=>!!t&&""!==t.trim()&&n.indexOf(t)===e)).join(" ").trim()
18
+ */function rw(){if(mu)return Nn;mu=1;var t=j,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(t,n,a){var u,s={},c=null,l=null;for(u in void 0!==a&&(c=""+a),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(l=n.ref),n)r.call(n,u)&&!o.hasOwnProperty(u)&&(s[u]=n[u]);if(t&&t.defaultProps)for(u in n=t.defaultProps)void 0===s[u]&&(s[u]=n[u]);return{$$typeof:e,type:t,key:c,ref:l,props:s,_owner:i.current}}return Nn.Fragment=n,Nn.jsx=a,Nn.jsxs=a,Nn}function iw(){return xu||(xu=1,wo.exports=rw()),wo.exports}var ne=iw();const qu=xo((({accept:t,onChange:e},n)=>ne.jsx("input",{ref:n,"data-testid":"input-file",accept:t,type:"file",onChange:({target:t})=>{if(!t.files)return;const n=Array.from(t.files).map((t=>({file:t,objectUrl:URL.createObjectURL(t)})));e(n),t.value=""},id:"inputFile",className:"hidden"})));qu.displayName="UploadButton";const Kw=()=>{const{extensions:t}=Ft($t.selectors.selectImagePolicy),[e]=Yu(),n=(t||[]).map((t=>`.${t}`)).join(),[r,i]=Be({width:0,height:0}),[o,a]=Be(""),[u,s]=Be(!1),c=async t=>{try{const[e]=t,n=await Eo(e.file);n&&i(n),a(e.objectUrl)}catch(t){$r.error("Upload image error"),Ao.error(`Upload image error: ${t}`)}};return{sizes:r,preview:o,acceptList:n,isModalOpen:u,uploadFile:e,onClose:()=>{s(!1),a("")},onUpload:t=>{c(t),s(!0)},handleFileChange:c}},Yr={x:0,y:0,width:0,height:0,unit:"px"},on=(t,e,n)=>Math.min(Math.max(t,e),n),ow=(...t)=>t.filter((t=>t&&"string"==typeof t)).join(" "),yu=(t,e)=>t===e||t.width===e.width&&t.height===e.height&&t.x===e.x&&t.y===e.y&&t.unit===e.unit;function sn(t,e,n){return"%"===t.unit?{...Yr,...t,unit:"%"}:{unit:"%",x:t.x?t.x/e*100:0,y:t.y?t.y/n*100:0,width:t.width?t.width/e*100:0,height:t.height?t.height/n*100:0}}function At(t,e,n){return t.unit?"px"===t.unit?{...Yr,...t,unit:"px"}:{unit:"px",x:t.x?t.x*e/100:0,y:t.y?t.y*n/100:0,width:t.width?t.width*e/100:0,height:t.height?t.height*n/100:0}:{...Yr,...t,unit:"px"}}function Su(t,e,n,r,i,o=0,a=0,u=r,s=i){const c={...t};let l=Math.min(o,r),f=Math.min(a,i),h=Math.min(u,r),p=Math.min(s,i);e&&(e>1?(l=a?a*e:l,f=l/e,h=u*e):(f=o?o/e:f,l=f*e,p=s/e)),c.y<0&&(c.height=Math.max(c.height+c.y,f),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,l),c.x=0);const d=r-(c.x+c.width);d<0&&(c.x=Math.min(c.x,r-l),c.width+=d);const g=i-(c.y+c.height);if(g<0&&(c.y=Math.min(c.y,i-f),c.height+=g),c.width<l&&(("sw"===n||"nw"==n)&&(c.x-=l-c.width),c.width=l),c.height<f&&(("nw"===n||"ne"==n)&&(c.y-=f-c.height),c.height=f),c.width>h&&(("sw"===n||"nw"==n)&&(c.x-=h-c.width),c.width=h),c.height>p&&(("nw"===n||"ne"==n)&&(c.y-=p-c.height),c.height=p),e){const t=c.width/c.height;if(t<e){const t=Math.max(c.width/e,f);("nw"===n||"ne"==n)&&(c.y-=t-c.height),c.height=t}else if(t>e){const t=Math.max(c.height*e,l);("sw"===n||"nw"==n)&&(c.x-=t-c.width),c.width=t}}return c}function sw(t,e,n,r){const i={...t};return"ArrowLeft"===e?"nw"===r?(i.x-=n,i.y-=n,i.width+=n,i.height+=n):"w"===r?(i.x-=n,i.width+=n):"sw"===r?(i.x-=n,i.width+=n,i.height+=n):"ne"===r?(i.y+=n,i.width-=n,i.height-=n):"e"===r?i.width-=n:"se"===r&&(i.width-=n,i.height-=n):"ArrowRight"===e&&("nw"===r?(i.x+=n,i.y+=n,i.width-=n,i.height-=n):"w"===r?(i.x+=n,i.width-=n):"sw"===r?(i.x+=n,i.width-=n,i.height-=n):"ne"===r?(i.y-=n,i.width+=n,i.height+=n):"e"===r?i.width+=n:"se"===r&&(i.width+=n,i.height+=n)),"ArrowUp"===e?"nw"===r?(i.x-=n,i.y-=n,i.width+=n,i.height+=n):"n"===r?(i.y-=n,i.height+=n):"ne"===r?(i.y-=n,i.width+=n,i.height+=n):"sw"===r?(i.x+=n,i.width-=n,i.height-=n):"s"===r?i.height-=n:"se"===r&&(i.width-=n,i.height-=n):"ArrowDown"===e&&("nw"===r?(i.x+=n,i.y+=n,i.width-=n,i.height-=n):"n"===r?(i.y+=n,i.height-=n):"ne"===r?(i.y+=n,i.width-=n,i.height-=n):"sw"===r?(i.x-=n,i.width+=n,i.height+=n):"s"===r?i.height+=n:"se"===r&&(i.width+=n,i.height+=n)),i}const an={capture:!0,passive:!1};let aw=0;const Et=class t extends G_{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=su(),this.mediaRef=su(),this.initChangeCalled=!1,this.instanceId="rc-"+aw++,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=t=>{const{crop:e,disabled:n}=this.props,r=this.getBox();if(!e)return;const i=At(e,r.width,r.height);if(n)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.target.dataset.ord,a=!!o;let u=t.clientX,s=t.clientY,c=i.x,l=i.y;if(o){const e=t.clientX-r.x,n=t.clientY-r.y;let a=0,f=0;"ne"===o||"e"==o?(a=e-(i.x+i.width),f=n-i.y,c=i.x,l=i.y+i.height):"se"===o||"s"===o?(a=e-(i.x+i.width),f=n-(i.y+i.height),c=i.x,l=i.y):"sw"===o||"w"==o?(a=e-i.x,f=n-(i.y+i.height),c=i.x+i.width,l=i.y):("nw"===o||"n"==o)&&(a=e-i.x,f=n-i.y,c=i.x+i.width,l=i.y+i.height),u=c+r.x+a,s=l+r.y+f}this.evData={startClientX:u,startClientY:s,startCropX:c,startCropY:l,clientX:t.clientX,clientY:t.clientY,isResize:a,ord:o},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=t=>{const{crop:e,disabled:n,locked:r,keepSelection:i,onChange:o}=this.props,a=this.getBox();if(n||r||i&&e)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.clientX-a.x,s=t.clientY-a.y,c={unit:"px",x:u,y:s,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:u,startCropY:s,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(At(c,a.width,a.height),sn(c,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=t=>{const{crop:e,disabled:n,onChange:r,onDragStart:i}=this.props,o=this.getBox();if(n||!e||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,i&&i(t));const{evData:a}=this;let u;a.clientX=t.clientX,a.clientY=t.clientY,u=a.isResize?this.resizeCrop():this.dragCrop(),yu(e,u)||r(At(u,o.width,o.height),sn(u,o.width,o.height))},this.onComponentKeyDown=e=>{const{crop:n,disabled:r,onChange:i,onComplete:o}=this.props;if(r)return;const a=e.key;let u=!1;if(!n)return;const s=this.getBox(),c=this.makePixelCrop(s),l=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?t.nudgeStepLarge:e.shiftKey?t.nudgeStepMedium:t.nudgeStep;if("ArrowLeft"===a?(c.x-=l,u=!0):"ArrowRight"===a?(c.x+=l,u=!0):"ArrowUp"===a?(c.y-=l,u=!0):"ArrowDown"===a&&(c.y+=l,u=!0),u){e.cancelable&&e.preventDefault(),c.x=on(c.x,0,s.width-c.width),c.y=on(c.y,0,s.height-c.height);const t=At(c,s.width,s.height),n=sn(c,s.width,s.height);i(t,n),o&&o(t,n)}},this.onHandlerKeyDown=(e,n)=>{const{aspect:r=0,crop:i,disabled:o,minWidth:a=0,minHeight:u=0,maxWidth:s,maxHeight:c,onChange:l,onComplete:f}=this.props,h=this.getBox();if(o||!i)return;if("ArrowUp"!==e.key&&"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.stopPropagation(),e.preventDefault();const p=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?t.nudgeStepLarge:e.shiftKey?t.nudgeStepMedium:t.nudgeStep,d=Su(sw(At(i,h.width,h.height),e.key,p,n),r,n,h.width,h.height,a,u,s,c);if(!yu(i,d)){const t=sn(d,h.width,h.height);l(d,t),f&&f(d,t)}},this.onDocPointerDone=t=>{const{crop:e,disabled:n,onComplete:r,onDragEnd:i}=this.props,o=this.getBox();this.unbindDocMove(),!n&&e&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,i&&i(t),r&&r(At(e,o.width,o.height),sn(e,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var t;null==(t=this.componentRef.current)||t.scrollTo(0,0)}}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:e,y:n,width:r,height:i}=t.getBoundingClientRect();return{x:e,y:n,width:r,height:i}}componentDidUpdate(t){const{crop:e,onComplete:n}=this.props;if(n&&!t.crop&&e){const{width:t,height:r}=this.getBox();t&&r&&n(At(e,t,r),sn(e,t,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,an),this.document.addEventListener("pointerup",this.onDocPointerDone,an),this.document.addEventListener("pointercancel",this.onDocPointerDone,an),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,an),this.document.removeEventListener("pointerup",this.onDocPointerDone,an),this.document.removeEventListener("pointercancel",this.onDocPointerDone,an),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,e=this.getBox(),n=this.makePixelCrop(e),r=t.clientX-t.startClientX,i=t.clientY-t.startClientY;return n.x=on(t.startCropX+r,0,e.width-n.width),n.y=on(t.startCropY+i,0,e.height-n.height),n}getPointRegion(t,e,n,r){const{evData:i}=this,o=i.clientX-t.x,a=i.clientY-t.y;let u,s;return u=r&&e?"nw"===e||"n"===e||"ne"===e:a<i.startCropY,s=n&&e?"nw"===e||"w"===e||"sw"===e:o<i.startCropX,s?u?"nw":"sw":u?"ne":"se"}resolveMinDimensions(t,e,n=0,r=0){const i=Math.min(n,t.width),o=Math.min(r,t.height);return e&&(i||o)?e>1?i?[i,i/e]:[o*e,o]:o?[o*e,o]:[i,i/e]:[i,o]}resizeCrop(){const{evData:e}=this,{aspect:n=0,maxWidth:r,maxHeight:i}=this.props,o=this.getBox(),[a,u]=this.resolveMinDimensions(o,n,this.props.minWidth,this.props.minHeight);let s=this.makePixelCrop(o);const c=this.getPointRegion(o,e.ord,a,u),l=e.ord||c;let f=e.clientX-e.startClientX,h=e.clientY-e.startClientY;(a&&"nw"===l||"w"===l||"sw"===l)&&(f=Math.min(f,-a)),(u&&"nw"===l||"n"===l||"ne"===l)&&(h=Math.min(h,-u));const p={unit:"px",x:0,y:0,width:0,height:0};"ne"===c?(p.x=e.startCropX,p.width=f,n?(p.height=p.width/n,p.y=e.startCropY-p.height):(p.height=Math.abs(h),p.y=e.startCropY-p.height)):"se"===c?(p.x=e.startCropX,p.y=e.startCropY,p.width=f,p.height=n?p.width/n:h):"sw"===c?(p.x=e.startCropX+f,p.y=e.startCropY,p.width=Math.abs(f),p.height=n?p.width/n:h):"nw"===c&&(p.x=e.startCropX+f,p.width=Math.abs(f),n?(p.height=p.width/n,p.y=e.startCropY-p.height):(p.height=Math.abs(h),p.y=e.startCropY+h));const d=Su(p,n,c,o.width,o.height,a,u,r,i);return n||t.xyOrds.indexOf(l)>-1?s=d:t.xOrds.indexOf(l)>-1?(s.x=d.x,s.width=d.width):t.yOrds.indexOf(l)>-1&&(s.y=d.y,s.height=d.height),s.x=on(s.x,0,o.width-s.width),s.y=on(s.y,0,o.height-s.height),s}renderCropSelection(){const{ariaLabels:e=t.defaultProps.ariaLabels,disabled:n,locked:r,renderSelectionAddon:i,ruleOfThirds:o,crop:a}=this.props,u=this.getCropStyle();if(a)return j.createElement("div",{style:u,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!n&&!r&&j.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},j.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),j.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"nw"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"n"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"ne"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"e"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"se"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"s"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"sw"),role:"button"}),j.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:t=>this.onHandlerKeyDown(t,"w"),role:"button"})),i&&j.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:t=>t.stopPropagation()},i(this.state)),o&&j.createElement(j.Fragment,null,j.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),j.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){return At({...Yr,...this.props.crop||{}},t.width,t.height)}render(){const{aspect:t,children:e,circularCrop:n,className:r,crop:i,disabled:o,locked:a,style:u,ruleOfThirds:s}=this.props,{cropIsActive:c,newCropIsBeingDrawn:l}=this.state,f=i?this.renderCropSelection():null,h=ow("ReactCrop",r,c&&"ReactCrop--active",o&&"ReactCrop--disabled",a&&"ReactCrop--locked",l&&"ReactCrop--new-crop",i&&t&&"ReactCrop--fixed-aspect",i&&n&&"ReactCrop--circular-crop",i&&s&&"ReactCrop--rule-of-thirds",!this.dragStarted&&i&&!i.width&&!i.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return j.createElement("div",{ref:this.componentRef,className:h,style:u},j.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},e),i?j.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},j.createElement("defs",null,j.createElement("mask",{id:`hole-${this.instanceId}`},j.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?j.createElement("ellipse",{cx:`${i.x+i.width/2}${i.unit}`,cy:`${i.y+i.height/2}${i.unit}`,rx:`${i.width/2}${i.unit}`,ry:`${i.height/2}${i.unit}`,fill:"black"}):j.createElement("rect",{x:`${i.x}${i.unit}`,y:`${i.y}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`,fill:"black"}))),j.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};Et.xOrds=["e","w"],Et.yOrds=["n","s"],Et.xyOrds=["nw","ne","se","sw"],Et.nudgeStep=1,Et.nudgeStepMedium=10,Et.nudgeStepLarge=100,Et.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};let uw=Et;const cw=async(t,e,n="image/jpeg",r=1,i=0,o=0)=>{if(!e.width||!e.height)throw new Error("Crop size is invalid");const a=document.createElement("canvas"),u=t.naturalWidth/t.width,s=t.naturalHeight/t.height;a.width=e.width,a.height=e.height;const c=a.getContext("2d");if(!c)throw new Error("2D context not available");const l=t.width/2,f=t.height/2,h=((e.x-i-l)/r+l)*u,p=((e.y-o-f)/r+f)*s,d=e.width/r*u,g=e.height/r*s;return c.drawImage(t,h,p,d,g,0,0,e.width,e.height),new Promise(((t,e)=>{a.toBlob((n=>{n?t(n):e(new Error("Failed to generate cropped image"))}),n)}))},lw=({onChange:t,zoom:e=1,pan:n})=>{const[r,i]=Be(),o=Wn(null),[a,u]=Be("");return $n((()=>((async()=>{if(!r||!o.current)return;const i=await cw(o.current,r,"image/jpeg",e,(null==n?void 0:n.x)??0,(null==n?void 0:n.y)??0),a=URL.createObjectURL(i);u(a),null==t||t(a)})(),()=>{a&&URL.revokeObjectURL(a)})),[r,o.current,t,e,null==n?void 0:n.x,null==n?void 0:n.y]),[o,i]},fw=560,Cu=400,Iu=.8,hw=(t,e,n)=>{const r=n,i=560/t.width,o=r/t.height,a=Math.min(1,i,o),u=t.width*a,s=t.height*a,c=Math.min(u,s*e),l=Math.min(u*Iu,Cu),f=Math.min(s*Iu,Cu),h=Math.min(l,f*e,c),p=h/e;return{unit:"px",x:(u-h)/2,y:(s-p)/2,width:h,height:p}},dw=({aspect:t=1,sizes:e,imgMaxHeight:n})=>{const[r,i]=Be();return $n((()=>{(null==e?void 0:e.width)&&e.height&&n&&i(hw(e,t,n))}),[null==e?void 0:e.height,null==e?void 0:e.width,n,t]),[r,i]},pw=({zoom:t,initialPan:e})=>{const[n,r]=Be(e??{x:0,y:0}),i=Wn(!1),o=Wn(null),a=X_((e=>{e.preventDefault();const a=e.clientX,u=e.clientY;i.current=!0,o.current={x:a,y:u,panX:n.x,panY:n.y};const s=e=>{if(!o.current)return;const n=(e.clientX-o.current.x)/t,i=(e.clientY-o.current.y)/t;r({x:o.current.panX+n,y:o.current.panY+i})},c=()=>{i.current=!1,o.current=null,window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c)};window.addEventListener("pointermove",s),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)}),[n.x,n.y,t]);return{pan:n,setPan:r,onPointerDown:a,isDragging:i.current}},gw=({src:t,sizes:e,aspect:n=1,circularCrop:r,zoom:i=1,pan:o,imgMaxHeight:a,className:u,onChange:s})=>{const[c]=dw({sizes:e,aspect:n,imgMaxHeight:a}),[l,f]=Be(0),[h,p]=Be(!1),{pan:d,onPointerDown:g,isDragging:v}=pw({zoom:i,initialPan:o}),_=o??d,[y,w]=lw({onChange:s,zoom:i,pan:_}),m={"--cropRadius":`${l}px`},x=()=>{p(!0),c&&(w(c),f((c.width??0)/3))};return $n((()=>{!h||!c||(w(c),f((c.width??0)/3))}),[h,c,w]),$n((()=>{p(!1)}),[t]),ne.jsx("div",{style:m,children:h?ne.jsx(uw,{crop:c,aspect:n,circularCrop:r,keepSelection:!0,locked:!0,onChange:t=>{f(t.width/3)},onComplete:w,children:ne.jsx("img",{src:t,ref:y,crossOrigin:"anonymous",style:{maxHeight:a?`${a}px`:"auto",transform:`translate(${_.x}px, ${_.y}px) scale(${i})`,transformOrigin:"center center",cursor:v?"grabbing":"grab"},className:Hr("mx-auto my-0",u),onLoad:x,onPointerDown:g})}):ne.jsx("img",{src:t,ref:y,crossOrigin:"anonymous",style:{maxHeight:a?`${a}px`:"auto"},className:Hr("mx-auto my-0",u),onLoad:x})})},_w=({open:t,modal:e,children:n,onCloseModal:r,className:i,...o})=>ne.jsx(z_,{open:t,modal:e,onOpenChange:t=>{t||null==r||r()},children:ne.jsx(Z_,{className:Hr(i),closeSize:"small",closeVariant:"insideCard",onCloseModal:r,...o,childrenClassName:Hr("overflow-auto",o.title?"max-h-[calc(90vh-65px)]":"max-h-[90vh]",o.childrenClassName),children:n})}),ww=40,vw=165,mw=.8,xw=()=>{const t=Wn(null),[e,n]=Be(0);return q_((()=>{const t=()=>{const t=window.innerHeight*mw-40,e=Math.max(0,t-vw);n(e)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}),[]),[t,e]},yw=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ku=(...t)=>t.filter(((t,e,n)=>!!t&&""!==t.trim()&&n.indexOf(t)===e)).join(" ").trim()
19
19
  /**
20
20
  * @license lucide-react v0.471.2 - ISC
21
21
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wellesley/uploads",
3
3
  "license": "UNLICENSED",
4
4
  "main": "index.mjs",
5
- "version": "1.0.390",
5
+ "version": "1.0.391",
6
6
  "module": "index.ts",
7
7
  "files": [
8
8
  "*",