@emailmaker/emailmaker 1.1.36 → 1.1.39
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.
- package/{emailmaker-core.4a2946bd.js → emailmaker-core.01bd5ee4.js} +1 -1
- package/emailmaker-esm.js +4 -4
- package/emailmaker.d.ts +4 -2
- package/emailmaker.js +6 -6
- package/iframe/js/amp.DieSnBUu.js +1 -1
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.CNqvmp_P.js +1 -1
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{61af40b8.js → 148a45c1.js} +3 -3
- package/static/core/{548145dc.js → 5a6dd152.js} +2 -2
- package/static/core/{77441b5e.js → 63a369c8.js} +4 -4
- package/static/core/705bfcaa.js +78 -0
- package/static/core/717cae7b.js +1 -0
- package/static/core/{6d27d0a8.js → 76c2567d.js} +2 -2
- package/static/core/{369b60a1.js → 7e6432e5.js} +1 -1
- package/static/core/{d856ee32.js → 83390cf7.js} +2 -2
- package/static/core/{539179022.js → a5b58fe12.js} +1 -1
- package/static/core/{af40ecaa.js → b894d0d2.js} +2 -2
- package/static/core/{b6d3de9a.js → ba228aa1.js} +41 -41
- package/static/core/{f47646dc.js → d91d49e9.js} +2 -2
- package/static/core/{e5d13a1c.js → ee79c467.js} +1 -1
- package/two_step_headless_plugin.html +1 -1
- package/static/core/8f709c0d.js +0 -1
- package/static/core/bc0b6b3f.js +0 -78
- /package/iframe/{iframe-eblock.4a2946bd.html → iframe-eblock.01bd5ee4.html} +0 -0
- /package/iframe/{iframe.4a2946bd.html → iframe.01bd5ee4.html} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.blocks-app .image-preview{text-align:center;min-height:100px;position:relative}.blocks-app .image-preview .image-editor-modal{border:1px solid red}.blocks-app .image-preview__edit-button{position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-preview img{border:1px solid var(--colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .image-editor-modal .ant-modal-container{flex-direction:column;min-height:100vh;display:flex;border-radius:0!important}.blocks-app .image-editor-modal .ant-modal-body{flex-grow:1;display:flex}.blocks-app .image-editor-modal .ant-modal-body #pixie-editor{flex-grow:1;height:calc(100vh - 70px);min-height:calc(100vh - 70px);overflow:hidden}.blocks-app .image-editor-modal .pi .text-on-primary{background:var(--colorPrimary);border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--colorPrimaryHover);border-color:var(--colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--borderRadius) * 1px)}.blocks-app .image-editor-modal .pi .shadow-xl{box-shadow:none}.blocks-app .image-editor-modal .w-\\[4ch\\].text-sm.text-center{width:5ch}.blocks-app .image-editor-modal .pi .border-white{border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--colorWhite)}.blocks-app .serach-results .ant-row{align-items:center}.blocks-app .serach-results .blocks-search__divider-wrapper{margin-top:12px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{border-top:1px solid var(--colorBorderSecondary);background:0 0;width:100%;height:1px;min-height:0;margin:0;position:static}.blocks-app .slideshow-container{width:524px;height:350px;margin:auto;position:relative;overflow:hidden}.blocks-app .slideshow-image{opacity:0;width:100%;height:100%;position:absolute;top:0;left:0}.blocks-app .image-ai .slideshow-image{width:auto;height:auto}.blocks-app .image-ai__image-item{text-align:center;border-radius:6px;justify-content:center;align-items:center;min-height:100px;display:flex;position:relative}.blocks-app .image-ai__image-item .buttons{justify-content:space-between;display:flex;position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-ai .text-area-input-hybrid{border:none;outline:none;min-height:0;padding:0 0 0 1px}.blocks-app .image-ai .text-area-input-hybrid textarea{height:32px;min-height:32px;padding:3px 11px;line-height:26px}.blocks-app .image-ai__loading{justify-content:center;align-items:center;min-height:150px;display:flex}.blocks-app .image-ai__loading .spin{flex-direction:column;justify-content:center;align-items:center;height:150px;display:flex}.blocks-app .image-ai__loading .status{margin:3px 0 0}.blocks-app .image-ai__preview{border-radius:6px;margin-top:24px;overflow:hidden}.blocks-app .image-ai__preview .image-ai__image-item img{border-radius:calc(var(--borderRadius) * 1px);object-fit:contain;max-height:100%;transition:height 1s;top:50%;left:50%;overflow:hidden;transform:translate(-50%,-50%)}.blocks-app .image-ai .small{width:302px;height:202px}.blocks-app .image-ai .large{width:524px;height:350px}.blocks-app .image-ai .image-ai__row{padding:0 2px}.blocks-app .image-ai .image-ai__input-affix-wrapper{border-style:solid;border-width:calc(var(--borderWidth) * 1px);border-color:var(--colorFillSecondaryDarken);border-radius:calc(var(--borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--colorPrimaryBorder)}.blocks-app .image-ai .image-ai__textarea{font-size:16px}.blocks-app .image-ai .image-ai__input-icon{font-size:16px;top:0;right:0}.dark .blocks-app .image-ai .image-ai__preview .image-ai__image-item img{background:#2b2b2b;border:1px solid #434343}.dark .blocks-app .image-ai .ant-btn{background:#1f1f1f}.dark .blocks-app .image-ai .ant-btn:hover{color:var(--colorPrimary)}.blocks-app .stock-tab img{border-radius:0;max-width:none;max-height:none}.blocks-app .stock-tab .stock-search-input{padding:0 2px}.blocks-app .stock-tab .my-masonry-grid{text-align:center;width:auto;display:flex}.blocks-app .stock-tab .my-masonry-grid_column{background-clip:padding-box}.blocks-app .stock-tab .list-item{cursor:pointer;background:#f0f2f5;border:1px solid #f0f2f5;border-radius:6px;min-height:100px;max-height:100px;margin-bottom:20px;transition:all .3s;display:inline-block;position:relative;overflow:hidden}.blocks-app .stock-tab .list-item .overlay-image{opacity:0;background-size:cover;width:110px;height:40px;transition:opacity .5s;position:absolute;bottom:10px;right:10px}.blocks-app .stock-tab .list-item .ant-spin{color:#f0f2f5;font-size:20px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.blocks-app .stock-tab .list-item img{object-fit:cover;opacity:0;border-radius:6px;height:auto;transition:opacity .5s ease-in-out;display:block}.blocks-app .stock-tab .list-item.loaded{border:1px solid #d9d9d9;max-height:1000px}.blocks-app .stock-tab .list-item.loaded img{opacity:1;height:100%}.blocks-app .stock-tab .list-item.loaded .loaded-image{opacity:.5}.blocks-app .stock-tab .list-item:hover{box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #00000017}.blocks-app .stock-tab .list-item:hover p.creator-info,.blocks-app .stock-tab .list-item:hover .overlay-image{opacity:1}.blocks-app .stock-tab .list-item p.creator-info{color:#fff;opacity:0;background-color:#00000080;border-radius:0 0 6px;margin:0;padding:5px;font-size:10px;line-height:1.2;position:absolute;bottom:0;right:0}.blocks-app .stock-tab .list-item p.creator-info:hover a{color:#fff;text-decoration:underline}.blocks-app .stock-tab .list-item p.creator-info a{color:#fff;text-decoration:none}.blocks-app .stock-color-filter{display:flex}.blocks-app .stock-color-filter label{border-width:1px;width:24px;height:24px;margin:4px;padding:0;font-size:0;border-radius:6px!important}.blocks-app .stock-color-filter label.all-colors{background-image:linear-gradient(135deg,red,#ff7f00,#ff0,#0f0,#00f,#8b00ff)}.blocks-app .stock-color-filter label.black-color{background:#222}.blocks-app .stock-color-filter label.bw-color{background-image:linear-gradient(135deg,#222 50%,#fff 50%)}.blocks-app .stock-color-filter label.white-color{background:#fff}.blocks-app .stock-color-filter label.orange-color{background:#fa8c16}.blocks-app .stock-color-filter label.red-color{background:#f5222d}.blocks-app .stock-color-filter label.purple-color{background:#722ed1}.blocks-app .stock-color-filter label.magenta-color{background:#eb2f96}.blocks-app .stock-color-filter label.green-color{background:#52c41a}.blocks-app .stock-color-filter label.teal-color{background:#43c3c3}.blocks-app .stock-color-filter label.blue-color{background:#1677ff}.blocks-app .stock-color-filter .ant-radio-button-wrapper:not(:first-child):before{display:none}.blocks-app .serach-results{padding-top:6px}.blocks-app .serach-results .stock-search-input{width:322px;padding:0 2px}.blocks-app .serach-results .blocks-search__divider-wrapper{width:calc(100% + 48px);margin-top:12px;margin-left:-24px;margin-right:-24px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{pointer-events:none;border-top:1px solid var(--colorBorderSecondary);background:linear-gradient(180deg, var(--colorBgContainerDisabled), transparent 40%);border-bottom:none;width:100%;height:20px;min-height:20px;margin:0;position:relative;bottom:auto;left:auto;right:auto}.dark .blocks-app .image-center .stock-tab .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{background:linear-gradient(180deg, var(--colorBgBase), transparent 40%)}.dark .blocks-app .stock-tab .list-item{background:#2b2b2b;border:1px solid #2b2b2b}.dark .blocks-app .stock-tab .list-item.loaded{border:1px solid #434343}.blocks-app .image-center .image-center-image-preview{justify-content:center;align-items:center;display:flex}.blocks-app .image-center .ant-divider-horizontal{pointer-events:none;z-index:1;background:linear-gradient(180deg, var(--colorBgContainerDisabled), transparent 40%);width:calc(100% + 48px);height:20px;margin:24px -24px 0;position:absolute;bottom:-19px}.dark .blocks-app .image-center .ant-divider-horizontal{background:linear-gradient(180deg, var(--colorBgBase), transparent 40%)}.blocks-app .image-center .ant-divider-horizontal.ant-divider-with-text{background:0 0;width:calc(100% + 38px);margin:0 -24px 20px;position:relative;top:0}.blocks-app .image-center img{border-radius:4px;max-width:524px;max-height:352px}.blocks-app .image-center .image-size{justify-content:center;margin-top:6px;font-size:14px;line-height:22px;display:flex}.blocks-app .image-center .ant-upload.ant-upload-drag{border-radius:6px}.blocks-app .image-center .ant-modal-body .stock-search-input{margin-bottom:0}.blocks-app .image-center .ant-modal-body .serach-results .stock-search-input{margin-bottom:10px}.blocks-app .image-center .ant-modal-body .ant-form:not(.serach-results) .ant-form-item:last-child{margin-bottom:0}.blocks-app .image-center .ant-modal-body .ant-tabs{transition:all .7s cubic-bezier(.075,.82,.165,1)}.blocks-app .image-center .ant-modal-body .ant-tabs .ant-tabs-content-holder{overflow-y:clip}.blocks-app .ant-modal{transition:width .7s ease-in-out}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/61af40b8.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/77441b5e.js`,`static/core/7865066d.js`,`static/core/539179022.js`,`static/core/d856ee32.js`,`static/core/6d27d0a8.js`,`static/core/548145dc.js`,`react`,`prop-types`,`react-router-dom`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./77441b5e.js"),a=e("./548145dc.js"),o=e("./d856ee32.js"),s=e("./7865066d.js"),c=e("./539179022.js"),l=e("./6d27d0a8.js"),u=e("react");u=r.l(u);let d=e("prop-types");d=r.l(d);let f=e("react-router-dom"),p=e("react/jsx-runtime");function m(e,t){return{[e]:{Filter:t(`Filter`),filter:t(`filter`),Resize:t(`Resize`),resize:t(`resize`),Crop:t(`Crop`),Width:t(`Width`),width:t(`width`),Height:t(`Height`),height:t(`height`),"Background color":t(`Background color`),Cancel:t(`Cancel`),Create:t(`Create`),Objects:t(`Objects`),Quality:t(`Quality`),Save:t(`Save`),"Loading Canvas":t(`Loading Canvas`),"Loading Image":t(`Loading Image`),"Loading State":t(`Loading State`),"Processing Image":t(`Processing Image`),Close:t(`Close`),Apply:t(`Apply`),Font:t(`Font`),Color:t(`Color`),Background:t(`Background`),Image:t(`Image`),Opacity:t(`Opacity`),Outline:t(`Outline`),Shadow:t(`Shadow`),Gradient:t(`Gradient`),Texture:t(`Texture`),"Replace Image":t(`Replace Image`),"Outline Color":t(`Outline Color`),"Shadow Color":t(`Shadow Color`),"Font Size":t(`Font Size`),Radius:t(`Radius`),"Brush Color":t(`Brush Color`),"Brush Type":t(`Brush Type`),"Brush Size":t(`Brush Size`),History:t(`History`),"Maintain aspect ratio":t(`Maintain aspect ratio`),"New Text":t(`New Text`),Size:t(`Size`),Draw:t(`Draw`),Text:t(`Text`),Stickers:t(`Stickers`),Frame:t(`Frame`),Shapes:t(`Shapes`),Corners:t(`Corners`),corners:t(`corners`),Done:t(`Done`),"Applied Filters":t(`Applied Filters`),"Resized Image":t(`Resized Image`),"Cropped Image":t(`Cropped Image`),"Added Drawing":t(`Added Drawing`),"Added Text":t(`Added Text`),"Added Shape":t(`Added Shape`),"Added Sticker":t(`Added Sticker`),"Added Frame":t(`Added Frame`),"Merged Objects":t(`Merged Objects`),"Rounded Corner":t(`Rounded Corner`),"Replaced Background Image":t(`Replaced Background Image`),"Added Image":t(`Added Image`),Initial:t(`Initial`),"Loaded State":t(`Loaded State`),"Changed Style":t(`Changed Style`),"Deleted object":t(`Deleted object`),Merge:t(`Merge`),Emoticons:t(`Emoticons`),Doodles:t(`Doodles`),Landmarks:t(`Landmarks`),Bubbles:t(`Bubbles`),Transportation:t(`Transportation`),Beach:t(`Beach`),PencilBrush:t(`PencilBrush`),SprayBrush:t(`SprayBrush`),CircleBrush:t(`CircleBrush`),DiamondBrush:t(`DiamondBrush`),VLineBrush:t(`VLineBrush`),HLineBrush:t(`HLineBrush`),SquareBrush:t(`SquareBrush`),Square:t(`Square`),square:t(`square`)}}}var h={text:{replaceDefault:!0,defaultCategory:`handwriting`,items:[{family:`Montserrat Light`,src:`customFonts/Montserrat-Light.woff2`},{family:`Montserrat Regular`,src:`customFonts/Montserrat-Regular.woff2`},{family:`Montserrat Bold`,src:`customFonts/Montserrat-Bold.woff2`},{family:`Montserrat Black`,src:`customFonts/Montserrat-Black.woff2`},{family:`Roboto Light`,src:`customFonts/Roboto-Light.woff2`},{family:`Roboto Regular`,src:`customFonts/Roboto-Regular.woff2`},{family:`Roboto Bold`,src:`customFonts/Roboto-Bold.woff2`},{family:`Roboto Black`,src:`customFonts/Roboto-Black.woff2`},{family:`Lato Light`,src:`customFonts/Lato-Light.woff2`},{family:`Lato Regular`,src:`customFonts/Lato-Regular.woff2`},{family:`Lato Bold`,src:`customFonts/Lato-Bold.woff2`},{family:`Lato Black`,src:`customFonts/Lato-Black.woff2`},{family:`Rubik Light`,src:`customFonts/Rubik-Light.woff2`},{family:`Rubik Regular`,src:`customFonts/Rubik-Regular.woff2`},{family:`Rubik Bold`,src:`customFonts/Rubik-Bold.woff2`},{family:`Rubik Black`,src:`customFonts/Rubik-Black.woff2`},{family:`Bebas Neue Light`,src:`customFonts/BebasNeueLight.woff2`},{family:`Bebas Neue Regular`,src:`customFonts/BebasNeueRegular.woff2`},{family:`Bebas Neue Book`,src:`customFonts/BebasNeueBook.woff2`},{family:`Bebas Neue Bold`,src:`customFonts/BebasNeueBold.woff2`},{family:`Arial`,src:`customFonts/ArialMT.woff2`},{family:`Arial Bold`,src:`customFonts/Arial-BoldMT.woff2`}]}},g=(e,t=`application/octet-stream`)=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function _(e,t){if(e===`json`)return new Blob([t],{type:`application/json`});if(e===`svg`)return new Blob([t],{type:`image/svg+xml`});let n=`image/${e}`;return t=t.replace(/data:image\/([a-z]*)?;base64,/,``),g(t,n)}var v=({currentImageLink:e,prefetchedBlobUrl:t,newLink:n,onSave:r,uploadImageResultIsLoading:d})=>{let f=l.h(),[g,v]=(0,u.useState)(),[y,b]=(0,u.useState)(),{__:x}=o.h(),S=i.Oi(),C=i.ki(),w=i.sn(),T=i.Di(i.n),E=i.Di(a.u),D=i.Di(i.ct),O=(0,u.useMemo)(()=>{if(!w?.icons)return;let e={};for(let[t,n]of Object.entries(w.icons))typeof n==`string`&&(e[t]=c.h(n));return Object.keys(e).length>0?e:void 0},[w?.icons]),k=(0,u.useRef)(!1),[A,j]=(0,u.useState)(),M=i.q(i.Co.FILE_PROXY_EVENT_ID);(0,u.useEffect)(()=>{(async()=>{let n=e;if(!n&&!t)return;let r;if(t)try{let e=await fetch(t);e.ok&&(r=await e.blob())}catch{r=void 0}if(!r&&n)try{r=await(await fetch(n)).blob()}catch{if(r=await M.fire({url:n,project:D}).filter(e=>e instanceof Blob)[0],!r){let e=f.get(i.Vi.em_token)||await i.Si.getInstance(C,a.E);r=await(await fetch(`https://app.emailmaker.ru/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(n)}`,{headers:{authorization:`Bearer ${e}`}})).blob()}}if(r){let e=new FileReader;e.onload=()=>{A?.tools.import.openBackgroundImage(g),e.result!==g&&(v(e.result),b(r.type))},e.readAsDataURL(r)}})().catch(e=>void 0)},[e,t,n,v,f,g,A,M,D,C]);let N=(0,u.useCallback)(()=>{v(null),b(null),S(a.n()),S(a.t(i.ba.UPLOAD_IMAGE_MODAL))},[S]),P=(0,u.useRef)();P.current=async function(e,t,n){let i=await _(n,e);r&&r(new File([i],t,{lastModified:new Date().getTime(),type:i.type}))};let F=(0,u.useCallback)(e=>{if(e&&!(k.current&&A)){k.current=!0;let e=T.locale?T.locale.replace(`_`,`-`):`ru-RU`,t=T.theme===`system`?matchMedia(`(prefers-color-scheme: dark)`).matches?i.Zi:i.ma:T.theme;s.O.init({selector:`#pixie-editor`,baseUrl:o.t(`assets/pixie`),image:g,activeLanguage:e,languages:m(e,x),tools:h,ui:{menubar:{replaceDefaultItems:!0,items:[{type:`undoWidget`,align:`left`},{type:`zoomWidget`,align:`center`,desktopOnly:!0},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`HistoryOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:e=>{e.togglePanel(`history`)}},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`CloseOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:()=>N()}]},nav:{position:`top`},activeTheme:t,mode:`inline`,forceOverlayModeOnMobile:!1},onSave:async function(e,t,n){P.current(e,t,n)}}).then(e=>{j(e)}).catch(e=>void 0)}},[T.theme,g,A,j,T.locale,x,N,O]),I=(0,u.useCallback)(()=>{A?.tools.export.save(e?.split(`/`).pop().split(`.`)[0],y?.split(`/`)[1])},[A,e,y]);return(0,p.jsxs)(o.Y,{afterOpenChange:F,width:`100%`,style:{maxWidth:`100%`,minHeight:`100vh`},className:`image-editor-modal`,centered:!0,closable:!1,zIndex:1100,mask:!1,open:E,footer:[(0,p.jsx)(o.Rt,{className:`em-analytics__profile-cancel`,onClick:N,children:x(`Cancel`)},`Cancel`),(0,p.jsx)(o.Rt,{className:`em-analytics__profile-updapixiete`,id:`save`,type:`primary`,onClick:I,children:x(`Update`)},`Ok`)],children:[d&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),(0,p.jsx)(`div`,{id:`pixie-editor`})]})},y=({currentImageLink:e,newLink:t,previewDisplayUrl:n,resolvedPreviewObjectUrl:r,onSave:i,uploadImageResultIsLoading:a})=>{let s=n||r;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{className:`image-preview`,children:[a&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),s&&(0,p.jsx)(`img`,{alt:`uploadedImage`,src:s})]})}),(0,p.jsx)(v,{currentImageLink:e,prefetchedBlobUrl:r,newLink:t,onSave:i,uploadImageResultIsLoading:a})]})},b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},b(e,t)};function x(e,t){b(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)};function C(e,t,n,r){var i,a=!1,o=0;function s(){i&&clearTimeout(i)}function c(){s(),a=!0}typeof t!=`boolean`&&(r=n,n=t,t=void 0);function l(){var c=this,l=Date.now()-o,u=arguments;if(a)return;function d(){o=Date.now(),n.apply(c,u)}function f(){i=void 0}r&&!i&&d(),s(),r===void 0&&l>e?d():t!==!0&&(i=setTimeout(r?f:d,r===void 0?e-l:e))}return l.cancel=c,l}var w={Pixel:`Pixel`,Percent:`Percent`},T={unit:w.Percent,value:.8};function E(e){return typeof e==`number`?{unit:w.Percent,value:e*100}:typeof e==`string`?e.match(/^(\d*(\.\d+)?)px$/)?{unit:w.Pixel,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:w.Percent,value:parseFloat(e)}:T:T}var D=function(e){x(t,e);function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:typeof n.props.scrollableTarget==`string`?document.getElementById(n.props.scrollableTarget):(n.props.scrollableTarget,null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange=`transform`,n._infScroll.style.transition=`transform 0.2s cubic-bezier(0,0,0.31,1)`))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),!(n.currentY<n.startY)&&(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),!(n.currentY-n.startY>n.maxPullDownDistance*1.5)&&n._infScroll&&(n._infScroll.style.overflow=`visible`,n._infScroll.style.transform=`translate3d(0px, `+(n.currentY-n.startY)+`px, 0px)`)))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow=`auto`,n._infScroll.style.transform=`none`,n._infScroll.style.willChange=`unset`)})},n.onScrollListener=function(e){typeof n.props.onScroll==`function`&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=C(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return t.prototype.componentDidMount=function(){if(this.props.dataLength===void 0)throw Error(`mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage`);if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener(`scroll`,this.throttledOnScrollListener),typeof this.props.initialScrollY==`number`&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener(`touchstart`,this.onStart),this.el.addEventListener(`touchmove`,this.onMove),this.el.addEventListener(`touchend`,this.onEnd),this.el.addEventListener(`mousedown`,this.onStart),this.el.addEventListener(`mousemove`,this.onMove),this.el.addEventListener(`mouseup`,this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),typeof this.props.refreshFunction!=`function`))throw Error(`Mandatory prop "refreshFunction" missing.
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.blocks-app .image-preview{text-align:center;min-height:100px;position:relative}.blocks-app .image-preview .image-editor-modal{border:1px solid red}.blocks-app .image-preview__edit-button{position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-preview img{border:1px solid var(--colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .image-editor-modal .ant-modal-container{flex-direction:column;min-height:100vh;display:flex;border-radius:0!important}.blocks-app .image-editor-modal .ant-modal-body{flex-grow:1;display:flex}.blocks-app .image-editor-modal .ant-modal-body #pixie-editor{flex-grow:1;height:calc(100vh - 70px);min-height:calc(100vh - 70px);overflow:hidden}.blocks-app .image-editor-modal .pi .text-on-primary{background:var(--colorPrimary);border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--colorPrimaryHover);border-color:var(--colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--borderRadius) * 1px)}.blocks-app .image-editor-modal .pi .shadow-xl{box-shadow:none}.blocks-app .image-editor-modal .w-\\[4ch\\].text-sm.text-center{width:5ch}.blocks-app .image-editor-modal .pi .border-white{border-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--colorWhite)}.blocks-app .serach-results .ant-row{align-items:center}.blocks-app .serach-results .blocks-search__divider-wrapper{margin-top:12px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{border-top:1px solid var(--colorBorderSecondary);background:0 0;width:100%;height:1px;min-height:0;margin:0;position:static}.blocks-app .slideshow-container{width:524px;height:350px;margin:auto;position:relative;overflow:hidden}.blocks-app .slideshow-image{opacity:0;width:100%;height:100%;position:absolute;top:0;left:0}.blocks-app .image-ai .slideshow-image{width:auto;height:auto}.blocks-app .image-ai__image-item{text-align:center;border-radius:6px;justify-content:center;align-items:center;min-height:100px;display:flex;position:relative}.blocks-app .image-ai__image-item .buttons{justify-content:space-between;display:flex;position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-ai .text-area-input-hybrid{border:none;outline:none;min-height:0;padding:0 0 0 1px}.blocks-app .image-ai .text-area-input-hybrid textarea{height:32px;min-height:32px;padding:3px 11px;line-height:26px}.blocks-app .image-ai__loading{justify-content:center;align-items:center;min-height:150px;display:flex}.blocks-app .image-ai__loading .spin{flex-direction:column;justify-content:center;align-items:center;height:150px;display:flex}.blocks-app .image-ai__loading .status{margin:3px 0 0}.blocks-app .image-ai__preview{border-radius:6px;margin-top:24px;overflow:hidden}.blocks-app .image-ai__preview .image-ai__image-item img{border-radius:calc(var(--borderRadius) * 1px);object-fit:contain;max-height:100%;transition:height 1s;top:50%;left:50%;overflow:hidden;transform:translate(-50%,-50%)}.blocks-app .image-ai .small{width:302px;height:202px}.blocks-app .image-ai .large{width:524px;height:350px}.blocks-app .image-ai .image-ai__row{padding:0 2px}.blocks-app .image-ai .image-ai__input-affix-wrapper{border-style:solid;border-width:calc(var(--borderWidth) * 1px);border-color:var(--colorFillSecondaryDarken);border-radius:calc(var(--borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--colorPrimaryBorder)}.blocks-app .image-ai .image-ai__textarea{font-size:16px}.blocks-app .image-ai .image-ai__input-icon{font-size:16px;top:0;right:0}.dark .blocks-app .image-ai .image-ai__preview .image-ai__image-item img{background:#2b2b2b;border:1px solid #434343}.dark .blocks-app .image-ai .ant-btn{background:#1f1f1f}.dark .blocks-app .image-ai .ant-btn:hover{color:var(--colorPrimary)}.blocks-app .stock-tab img{border-radius:0;max-width:none;max-height:none}.blocks-app .stock-tab .stock-search-input{padding:0 2px}.blocks-app .stock-tab .my-masonry-grid{text-align:center;width:auto;display:flex}.blocks-app .stock-tab .my-masonry-grid_column{background-clip:padding-box}.blocks-app .stock-tab .list-item{cursor:pointer;background:#f0f2f5;border:1px solid #f0f2f5;border-radius:6px;min-height:100px;max-height:100px;margin-bottom:20px;transition:all .3s;display:inline-block;position:relative;overflow:hidden}.blocks-app .stock-tab .list-item .overlay-image{opacity:0;background-size:cover;width:110px;height:40px;transition:opacity .5s;position:absolute;bottom:10px;right:10px}.blocks-app .stock-tab .list-item .ant-spin{color:#f0f2f5;font-size:20px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.blocks-app .stock-tab .list-item img{object-fit:cover;opacity:0;border-radius:6px;height:auto;transition:opacity .5s ease-in-out;display:block}.blocks-app .stock-tab .list-item.loaded{border:1px solid #d9d9d9;max-height:1000px}.blocks-app .stock-tab .list-item.loaded img{opacity:1;height:100%}.blocks-app .stock-tab .list-item.loaded .loaded-image{opacity:.5}.blocks-app .stock-tab .list-item:hover{box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #00000017}.blocks-app .stock-tab .list-item:hover p.creator-info,.blocks-app .stock-tab .list-item:hover .overlay-image{opacity:1}.blocks-app .stock-tab .list-item p.creator-info{color:#fff;opacity:0;background-color:#00000080;border-radius:0 0 6px;margin:0;padding:5px;font-size:10px;line-height:1.2;position:absolute;bottom:0;right:0}.blocks-app .stock-tab .list-item p.creator-info:hover a{color:#fff;text-decoration:underline}.blocks-app .stock-tab .list-item p.creator-info a{color:#fff;text-decoration:none}.blocks-app .stock-color-filter{display:flex}.blocks-app .stock-color-filter label{border-width:1px;width:24px;height:24px;margin:4px;padding:0;font-size:0;border-radius:6px!important}.blocks-app .stock-color-filter label.all-colors{background-image:linear-gradient(135deg,red,#ff7f00,#ff0,#0f0,#00f,#8b00ff)}.blocks-app .stock-color-filter label.black-color{background:#222}.blocks-app .stock-color-filter label.bw-color{background-image:linear-gradient(135deg,#222 50%,#fff 50%)}.blocks-app .stock-color-filter label.white-color{background:#fff}.blocks-app .stock-color-filter label.orange-color{background:#fa8c16}.blocks-app .stock-color-filter label.red-color{background:#f5222d}.blocks-app .stock-color-filter label.purple-color{background:#722ed1}.blocks-app .stock-color-filter label.magenta-color{background:#eb2f96}.blocks-app .stock-color-filter label.green-color{background:#52c41a}.blocks-app .stock-color-filter label.teal-color{background:#43c3c3}.blocks-app .stock-color-filter label.blue-color{background:#1677ff}.blocks-app .stock-color-filter .ant-radio-button-wrapper:not(:first-child):before{display:none}.blocks-app .serach-results{padding-top:6px}.blocks-app .serach-results .stock-search-input{width:322px;padding:0 2px}.blocks-app .serach-results .blocks-search__divider-wrapper{width:calc(100% + 48px);margin-top:12px;margin-left:-24px;margin-right:-24px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{pointer-events:none;border-top:1px solid var(--colorBorderSecondary);background:linear-gradient(180deg, var(--colorBgContainerDisabled), transparent 40%);border-bottom:none;width:100%;height:20px;min-height:20px;margin:0;position:relative;bottom:auto;left:auto;right:auto}.dark .blocks-app .image-center .stock-tab .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{background:linear-gradient(180deg, var(--colorBgBase), transparent 40%)}.dark .blocks-app .stock-tab .list-item{background:#2b2b2b;border:1px solid #2b2b2b}.dark .blocks-app .stock-tab .list-item.loaded{border:1px solid #434343}.blocks-app .image-center .image-center-image-preview{justify-content:center;align-items:center;display:flex}.blocks-app .image-center .ant-divider-horizontal{pointer-events:none;z-index:1;background:linear-gradient(180deg, var(--colorBgContainerDisabled), transparent 40%);width:calc(100% + 48px);height:20px;margin:24px -24px 0;position:absolute;bottom:-19px}.dark .blocks-app .image-center .ant-divider-horizontal{background:linear-gradient(180deg, var(--colorBgBase), transparent 40%)}.blocks-app .image-center .ant-divider-horizontal.ant-divider-with-text{background:0 0;width:calc(100% + 38px);margin:0 -24px 20px;position:relative;top:0}.blocks-app .image-center img{border-radius:4px;max-width:524px;max-height:352px}.blocks-app .image-center .image-size{justify-content:center;margin-top:6px;font-size:14px;line-height:22px;display:flex}.blocks-app .image-center .ant-upload.ant-upload-drag{border-radius:6px}.blocks-app .image-center .ant-modal-body .stock-search-input{margin-bottom:0}.blocks-app .image-center .ant-modal-body .serach-results .stock-search-input{margin-bottom:10px}.blocks-app .image-center .ant-modal-body .ant-form:not(.serach-results) .ant-form-item:last-child{margin-bottom:0}.blocks-app .image-center .ant-modal-body .ant-tabs{transition:all .7s cubic-bezier(.075,.82,.165,1)}.blocks-app .image-center .ant-modal-body .ant-tabs .ant-tabs-content-holder{overflow-y:clip}.blocks-app .ant-modal{transition:width .7s ease-in-out}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/148a45c1.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/63a369c8.js`,`static/core/7865066d.js`,`static/core/a5b58fe12.js`,`static/core/83390cf7.js`,`static/core/76c2567d.js`,`static/core/5a6dd152.js`,`react`,`prop-types`,`react-router-dom`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./63a369c8.js"),a=e("./5a6dd152.js"),o=e("./83390cf7.js"),s=e("./7865066d.js"),c=e("./a5b58fe12.js"),l=e("./76c2567d.js"),u=e("react");u=r.l(u);let d=e("prop-types");d=r.l(d);let f=e("react-router-dom"),p=e("react/jsx-runtime");function m(e,t){return{[e]:{Filter:t(`Filter`),filter:t(`filter`),Resize:t(`Resize`),resize:t(`resize`),Crop:t(`Crop`),Width:t(`Width`),width:t(`width`),Height:t(`Height`),height:t(`height`),"Background color":t(`Background color`),Cancel:t(`Cancel`),Create:t(`Create`),Objects:t(`Objects`),Quality:t(`Quality`),Save:t(`Save`),"Loading Canvas":t(`Loading Canvas`),"Loading Image":t(`Loading Image`),"Loading State":t(`Loading State`),"Processing Image":t(`Processing Image`),Close:t(`Close`),Apply:t(`Apply`),Font:t(`Font`),Color:t(`Color`),Background:t(`Background`),Image:t(`Image`),Opacity:t(`Opacity`),Outline:t(`Outline`),Shadow:t(`Shadow`),Gradient:t(`Gradient`),Texture:t(`Texture`),"Replace Image":t(`Replace Image`),"Outline Color":t(`Outline Color`),"Shadow Color":t(`Shadow Color`),"Font Size":t(`Font Size`),Radius:t(`Radius`),"Brush Color":t(`Brush Color`),"Brush Type":t(`Brush Type`),"Brush Size":t(`Brush Size`),History:t(`History`),"Maintain aspect ratio":t(`Maintain aspect ratio`),"New Text":t(`New Text`),Size:t(`Size`),Draw:t(`Draw`),Text:t(`Text`),Stickers:t(`Stickers`),Frame:t(`Frame`),Shapes:t(`Shapes`),Corners:t(`Corners`),corners:t(`corners`),Done:t(`Done`),"Applied Filters":t(`Applied Filters`),"Resized Image":t(`Resized Image`),"Cropped Image":t(`Cropped Image`),"Added Drawing":t(`Added Drawing`),"Added Text":t(`Added Text`),"Added Shape":t(`Added Shape`),"Added Sticker":t(`Added Sticker`),"Added Frame":t(`Added Frame`),"Merged Objects":t(`Merged Objects`),"Rounded Corner":t(`Rounded Corner`),"Replaced Background Image":t(`Replaced Background Image`),"Added Image":t(`Added Image`),Initial:t(`Initial`),"Loaded State":t(`Loaded State`),"Changed Style":t(`Changed Style`),"Deleted object":t(`Deleted object`),Merge:t(`Merge`),Emoticons:t(`Emoticons`),Doodles:t(`Doodles`),Landmarks:t(`Landmarks`),Bubbles:t(`Bubbles`),Transportation:t(`Transportation`),Beach:t(`Beach`),PencilBrush:t(`PencilBrush`),SprayBrush:t(`SprayBrush`),CircleBrush:t(`CircleBrush`),DiamondBrush:t(`DiamondBrush`),VLineBrush:t(`VLineBrush`),HLineBrush:t(`HLineBrush`),SquareBrush:t(`SquareBrush`),Square:t(`Square`),square:t(`square`)}}}var h={text:{replaceDefault:!0,defaultCategory:`handwriting`,items:[{family:`Montserrat Light`,src:`customFonts/Montserrat-Light.woff2`},{family:`Montserrat Regular`,src:`customFonts/Montserrat-Regular.woff2`},{family:`Montserrat Bold`,src:`customFonts/Montserrat-Bold.woff2`},{family:`Montserrat Black`,src:`customFonts/Montserrat-Black.woff2`},{family:`Roboto Light`,src:`customFonts/Roboto-Light.woff2`},{family:`Roboto Regular`,src:`customFonts/Roboto-Regular.woff2`},{family:`Roboto Bold`,src:`customFonts/Roboto-Bold.woff2`},{family:`Roboto Black`,src:`customFonts/Roboto-Black.woff2`},{family:`Lato Light`,src:`customFonts/Lato-Light.woff2`},{family:`Lato Regular`,src:`customFonts/Lato-Regular.woff2`},{family:`Lato Bold`,src:`customFonts/Lato-Bold.woff2`},{family:`Lato Black`,src:`customFonts/Lato-Black.woff2`},{family:`Rubik Light`,src:`customFonts/Rubik-Light.woff2`},{family:`Rubik Regular`,src:`customFonts/Rubik-Regular.woff2`},{family:`Rubik Bold`,src:`customFonts/Rubik-Bold.woff2`},{family:`Rubik Black`,src:`customFonts/Rubik-Black.woff2`},{family:`Bebas Neue Light`,src:`customFonts/BebasNeueLight.woff2`},{family:`Bebas Neue Regular`,src:`customFonts/BebasNeueRegular.woff2`},{family:`Bebas Neue Book`,src:`customFonts/BebasNeueBook.woff2`},{family:`Bebas Neue Bold`,src:`customFonts/BebasNeueBold.woff2`},{family:`Arial`,src:`customFonts/ArialMT.woff2`},{family:`Arial Bold`,src:`customFonts/Arial-BoldMT.woff2`}]}},g=(e,t=`application/octet-stream`)=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function _(e,t){if(e===`json`)return new Blob([t],{type:`application/json`});if(e===`svg`)return new Blob([t],{type:`image/svg+xml`});let n=`image/${e}`;return t=t.replace(/data:image\/([a-z]*)?;base64,/,``),g(t,n)}var v=({currentImageLink:e,prefetchedBlobUrl:t,newLink:n,onSave:r,uploadImageResultIsLoading:d})=>{let f=l.h(),[g,v]=(0,u.useState)(),[y,b]=(0,u.useState)(),{__:x}=o.h(),S=i.ki(),C=i.Ai(),w=i.cn(),T=i.Oi(i.n),E=i.Oi(a.u),D=i.Oi(i.ct),O=(0,u.useMemo)(()=>{if(!w?.icons)return;let e={};for(let[t,n]of Object.entries(w.icons))typeof n==`string`&&(e[t]=c.h(n));return Object.keys(e).length>0?e:void 0},[w?.icons]),k=(0,u.useRef)(!1),[A,j]=(0,u.useState)(),M=i.q(i.wo.FILE_PROXY_EVENT_ID);(0,u.useEffect)(()=>{(async()=>{let n=e;if(!n&&!t)return;let r;if(t)try{let e=await fetch(t);e.ok&&(r=await e.blob())}catch{r=void 0}if(!r&&n)try{r=await(await fetch(n)).blob()}catch{if(r=await M.fire({url:n,project:D}).filter(e=>e instanceof Blob)[0],!r){let e=f.get(i.Hi.em_token)||await i.Ci.getInstance(C,a.E);r=await(await fetch(`https://app.emailmaker.ru/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(n)}`,{headers:{authorization:`Bearer ${e}`}})).blob()}}if(r){let e=new FileReader;e.onload=()=>{A?.tools.import.openBackgroundImage(g),e.result!==g&&(v(e.result),b(r.type))},e.readAsDataURL(r)}})().catch(e=>void 0)},[e,t,n,v,f,g,A,M,D,C]);let N=(0,u.useCallback)(()=>{v(null),b(null),S(a.n()),S(a.t(i.xa.UPLOAD_IMAGE_MODAL))},[S]),P=(0,u.useRef)();P.current=async function(e,t,n){let i=await _(n,e);r&&r(new File([i],t,{lastModified:new Date().getTime(),type:i.type}))};let F=(0,u.useCallback)(e=>{if(e&&!(k.current&&A)){k.current=!0;let e=T.locale?T.locale.replace(`_`,`-`):`ru-RU`,t=T.theme===`system`?matchMedia(`(prefers-color-scheme: dark)`).matches?i.Qi:i.ha:T.theme;s.O.init({selector:`#pixie-editor`,baseUrl:o.t(`assets/pixie`),image:g,activeLanguage:e,languages:m(e,x),tools:h,ui:{menubar:{replaceDefaultItems:!0,items:[{type:`undoWidget`,align:`left`},{type:`zoomWidget`,align:`center`,desktopOnly:!0},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`HistoryOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:e=>{e.togglePanel(`history`)}},{type:`button`,icon:(0,p.jsx)(o.Lt,{icon:`CloseOutlined`,configIcons:O,style:{fontSize:20}}),align:`right`,desktopOnly:!0,action:()=>N()}]},nav:{position:`top`},activeTheme:t,mode:`inline`,forceOverlayModeOnMobile:!1},onSave:async function(e,t,n){P.current(e,t,n)}}).then(e=>{j(e)}).catch(e=>void 0)}},[T.theme,g,A,j,T.locale,x,N,O]),I=(0,u.useCallback)(()=>{A?.tools.export.save(e?.split(`/`).pop().split(`.`)[0],y?.split(`/`)[1])},[A,e,y]);return(0,p.jsxs)(o.Y,{afterOpenChange:F,width:`100%`,style:{maxWidth:`100%`,minHeight:`100vh`},className:`image-editor-modal`,centered:!0,closable:!1,zIndex:1100,mask:!1,open:E,footer:[(0,p.jsx)(o.Rt,{className:`em-analytics__profile-cancel`,onClick:N,children:x(`Cancel`)},`Cancel`),(0,p.jsx)(o.Rt,{className:`em-analytics__profile-updapixiete`,id:`save`,type:`primary`,onClick:I,children:x(`Update`)},`Ok`)],children:[d&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),(0,p.jsx)(`div`,{id:`pixie-editor`})]})},y=({currentImageLink:e,newLink:t,previewDisplayUrl:n,resolvedPreviewObjectUrl:r,onSave:i,uploadImageResultIsLoading:a})=>{let s=n||r;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{className:`image-preview`,children:[a&&(0,p.jsx)(`div`,{style:{position:`absolute`,height:`100%`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--colorBgLayout)`,zIndex:10,opacity:.7},children:(0,p.jsx)(o.K,{size:`large`})}),s&&(0,p.jsx)(`img`,{alt:`uploadedImage`,src:s})]})}),(0,p.jsx)(v,{currentImageLink:e,prefetchedBlobUrl:r,newLink:t,onSave:i,uploadImageResultIsLoading:a})]})},b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},b(e,t)};function x(e,t){b(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)};function C(e,t,n,r){var i,a=!1,o=0;function s(){i&&clearTimeout(i)}function c(){s(),a=!0}typeof t!=`boolean`&&(r=n,n=t,t=void 0);function l(){var c=this,l=Date.now()-o,u=arguments;if(a)return;function d(){o=Date.now(),n.apply(c,u)}function f(){i=void 0}r&&!i&&d(),s(),r===void 0&&l>e?d():t!==!0&&(i=setTimeout(r?f:d,r===void 0?e-l:e))}return l.cancel=c,l}var w={Pixel:`Pixel`,Percent:`Percent`},T={unit:w.Percent,value:.8};function E(e){return typeof e==`number`?{unit:w.Percent,value:e*100}:typeof e==`string`?e.match(/^(\d*(\.\d+)?)px$/)?{unit:w.Pixel,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:w.Percent,value:parseFloat(e)}:T:T}var D=function(e){x(t,e);function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:typeof n.props.scrollableTarget==`string`?document.getElementById(n.props.scrollableTarget):(n.props.scrollableTarget,null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange=`transform`,n._infScroll.style.transition=`transform 0.2s cubic-bezier(0,0,0.31,1)`))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),!(n.currentY<n.startY)&&(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),!(n.currentY-n.startY>n.maxPullDownDistance*1.5)&&n._infScroll&&(n._infScroll.style.overflow=`visible`,n._infScroll.style.transform=`translate3d(0px, `+(n.currentY-n.startY)+`px, 0px)`)))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow=`auto`,n._infScroll.style.transform=`none`,n._infScroll.style.willChange=`unset`)})},n.onScrollListener=function(e){typeof n.props.onScroll==`function`&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=C(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return t.prototype.componentDidMount=function(){if(this.props.dataLength===void 0)throw Error(`mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage`);if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener(`scroll`,this.throttledOnScrollListener),typeof this.props.initialScrollY==`number`&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener(`touchstart`,this.onStart),this.el.addEventListener(`touchmove`,this.onMove),this.el.addEventListener(`touchend`,this.onEnd),this.el.addEventListener(`mousedown`,this.onStart),this.el.addEventListener(`mousemove`,this.onMove),this.el.addEventListener(`mouseup`,this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),typeof this.props.refreshFunction!=`function`))throw Error(`Mandatory prop "refreshFunction" missing.
|
|
2
2
|
Pull Down To Refresh functionality will not work
|
|
3
|
-
as expected. Check README.md for usage'`)},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener(`scroll`,this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener(`touchstart`,this.onStart),this.el.removeEventListener(`touchmove`,this.onMove),this.el.removeEventListener(`touchend`,this.onEnd),this.el.removeEventListener(`mousedown`,this.onStart),this.el.removeEventListener(`mousemove`,this.onMove),this.el.removeEventListener(`mouseup`,this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength===t.prevDataLength?null:S(S({},t),{prevDataLength:e.dataLength})},t.prototype.isElementAtTop=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=S({height:this.props.height||`auto`,overflow:`auto`,WebkitOverflowScrolling:`touch`},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:`auto`}:{};return u.default.createElement(`div`,{style:r,className:`infinite-scroll-component__outerdiv`},u.default.createElement(`div`,{className:`infinite-scroll-component `+(this.props.className||``),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&u.default.createElement(`div`,{style:{position:`relative`},ref:function(t){return e._pullDown=t}},u.default.createElement(`div`,{style:{position:`absolute`,left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(u.Component);function O(e,t){if(e==null)return{};var n=k(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function k(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(this,arguments)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?j(Object(n),!0).forEach(function(t){N(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0},F=2,I=class extends u.default.Component{constructor(e){super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let t;t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||F,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener(`resize`,this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener(`resize`,this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){if(!window||!window.requestAnimationFrame){this.reCalculateColumnCount();return}window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})}reCalculateColumnCount(){let e=window&&window.innerWidth||1/0,t=this.props.breakpointCols;typeof t!=`object`&&(t={default:parseInt(t)||F});let n=1/0,r=t.default||F;for(let i in t){let a=parseInt(i);a>0&&e<=a&&a<n&&(n=a,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){let e=this.state.columnCount,t=Array(e),n=u.default.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){let i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){let{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),i=`${100/r.length}%`,a=n;a&&typeof a!=`string`&&(this.logDeprecated(`The property "columnClassName" requires a string`),a===void 0&&(a=`my-masonry-grid_column`));let o=M(M(M({},e),t),{},{style:M(M({},t.style),{},{width:i}),className:a});return r.map((e,t)=>u.default.createElement(`div`,A({},o,{key:t}),e))}logDeprecated(e){}render(){let e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:i,column:a,className:o}=e,s=O(e,[`children`,`breakpointCols`,`columnClassName`,`columnAttrs`,`column`,`className`]),c=o;return typeof o!=`string`&&(this.logDeprecated(`The property "className" requires a string`),o===void 0&&(c=`my-masonry-grid`)),u.default.createElement(`div`,A({},s,{className:c}),this.renderColumns())}};I.defaultProps=P;function L(e,t){return e?e.exhausted?{...e,src:null}:{...e,src:e.src||t||null}:null}function R({items:e,getItemId:t,getRequestUrl:n,createController:r}){let[i,a]=(0,u.useState)({}),o=(0,u.useRef)(new Map),s=(0,u.useCallback)(e=>{let i=t(e),a=n(e),s=`${i}:${a}`;if(o.current.has(s))return{itemId:i,requestUrl:a,cacheKey:s,controller:o.current.get(s)};let c=r(a);return o.current.set(s,c),{itemId:i,requestUrl:a,cacheKey:s,controller:c}},[r,t,n]);return(0,u.useEffect)(()=>{let t=new Set,n={},r=e.map(e=>{let{itemId:r,cacheKey:i,controller:o}=s(e);t.add(i),n[r]=o.src;let c=L(o.handleChangeSrc?.(),o.src);return c?.changed&&c.src&&(n[r]=c.src),o.subscribeToSrcChange?.(e=>{let t=L(e,o.src);!t?.changed||!t.src||a(e=>e[r]===t.src?e:{...e,[r]:t.src})})}).filter(Boolean);return o.current.forEach((e,n)=>{t.has(n)||o.current.delete(n)}),a(n),()=>{r.forEach(e=>e?.())}},[s,e]),{getDisplaySrc:(0,u.useCallback)(e=>{let{itemId:t,requestUrl:n,controller:r}=s(e);return i[t]||r.src||n},[i,s]),handleLoad:(0,u.useCallback)(e=>{s(e).controller.handleSuccess()},[s]),handleError:(0,u.useCallback)(e=>{let{itemId:t,controller:n}=s(e),r=L(n.handleError(),n.src);r?.changed&&r.src&&a(e=>({...e,[t]:r.src}))},[s])}}var z=`blocks`,B=({setCurrentImageLink:e,setModalHeight:t,setModalWidth:n,setImageStockList:r,imageStockList:s,currentReq:l,setCurrentReq:d,inputRef:f,setStockLink:m,customRequest:h})=>{let g=i.sn(),_=c.t(),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(2),{__:S}=o.h(),C=o.o(),[w]=a.S(),[T]=a.x(),E=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:S(`Failed to load stock images through the configured proxy chain.`),[S]),O=(0,u.useCallback)(e=>{C.error({id:`STOCK_IMAGES_SEARCH_FAILED`,title:S(`Failed to load stock images`),description:E(e)})},[S,E,C]),k=async()=>{v||(y(!0),T({query:l,page:b}).then(e=>{if(e?.error){O(e.error),y(!1);return}let t=e?.data?.results||[];r(e=>[...e,...t]),y(!1),x(e=>e+1)}).catch(()=>{y(!1)}))};(0,u.useEffect)(()=>{l.keywords!==``&&A()},[l.color,l.orientation]);let A=async()=>{let e=await T({query:l,page:1});if(e?.error){O(e.error),r([]);return}let i=e?.data?.results||[];i.length>0?(r(i),setTimeout(()=>{n(1060),t(`84vh`)},0)):r([])},[j,M]=(0,u.useState)(null),N=(0,u.useCallback)((e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}w=${t}&q=${n}`,[]),P=(0,u.useCallback)(e=>i.no(e,{config:g,standalone:_,resourceType:`stockImages`,intent:`display`}),[g,_]),{getDisplaySrc:F,handleLoad:L,handleError:B}=R({items:s,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>N(e.urls.raw,644,96),[N]),createController:P}),V=e=>t=>{L(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)},te=(t,n,r)=>{w(n.download_location),M(r),setTimeout(()=>M(null),2e3),m(`${t.raw}&w=1200&q=96`),e(`${t.raw}&w=1200&q=96`),h(`${t.raw}&w=1200&q=96`)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:A,className:s.length>0?`serach-results`:``,children:[(0,p.jsxs)(o.Ot,{gutter:24,children:[(0,p.jsx)(o.Dt,{span:s.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:A,allowClear:!0,size:s.length>0?`medium`:`large`,placeholder:S(`Search image`),value:l.keywords,onChange:e=>d(t=>({...t,keywords:e.target.value})),ref:f,spellCheck:`false`,enterButton:!1})})}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Dt,{children:(0,p.jsxs)(o._t.Group,{defaultValue:``,onChange:e=>d(t=>({...t,orientation:e.target.value})),children:[(0,p.jsx)(o.U,{title:S(`All`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:``,children:(0,p.jsx)(c.m,{icon:`MixedView`})})}),(0,p.jsx)(o.U,{title:S(`Landscape`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`landscape`,children:(0,p.jsx)(c.m,{icon:`LandscapeView`})})}),(0,p.jsx)(o.U,{title:S(`Portrait`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`portrait`,children:(0,p.jsx)(c.m,{icon:`PortraitView`})})}),(0,p.jsx)(o.U,{title:S(`Squarish`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`squarish`,children:(0,p.jsx)(c.m,{icon:`SquareView`})})})]})}),(0,p.jsx)(o.Dt,{children:(0,p.jsx)(o.A,{defaultValue:``,onChange:e=>d(t=>({...t,color:e.target.value})),options:[{value:``,colorClass:`all-colors`,label:S(`All`)},{value:`black`,colorClass:`black-color`,label:S(`Black`)},{value:`black_and_white`,colorClass:`bw-color`,label:S(`Black and White`)},{value:`white`,colorClass:`white-color`,label:S(`White`)},{value:`orange`,colorClass:`orange-color`,label:S(`Orange`)},{value:`red`,colorClass:`red-color`,label:S(`Red`)},{value:`purple`,colorClass:`purple-color`,label:S(`Purple`)},{value:`magenta`,colorClass:`magenta-color`,label:S(`Magenta`)},{value:`green`,colorClass:`green-color`,label:S(`Green`)},{value:`teal`,colorClass:`teal-color`,label:S(`Teal`)},{value:`blue`,colorClass:`blue-color`,label:S(`Blue`)}],tooltipPlacement:`top`})})]})]}),s.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:s.length>0&&(0,p.jsx)(`div`,{id:`scrollableDiv`,style:{width:`100%`,height:`calc(84vh - 148px)`,overflow:`auto`,paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:`0`,boxSizing:`unset`},children:(0,p.jsx)(D,{dataLength:s&&s.length,next:k,hasMore:s,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[S("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:null,children:(0,p.jsx)(I,{breakpointCols:{default:3},className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:s.map(e=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>te(e.urls,e.links,e.id),children:[(0,p.jsx)(`img`,{className:j===e.id?`loaded-image`:``,width:`322px`,src:F(e),alt:e.description,onLoad:V(e),onError:ee(e)}),(0,p.jsxs)(`p`,{className:`creator-info`,onClick:e=>e.stopPropagation(),children:[`Photo by`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`${e.user.links.html}?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:e.user.name}),` `,`on`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`https://unsplash.com/?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:`Unsplash`})]}),j===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id))})})})})]})},V=({images:e,transitionDuration:t=1e3})=>{let[n,r]=(0,u.useState)([]);return(0,u.useEffect)(()=>{if(e.length>0){let t=e[e.length-1];r(e=>[...e,{src:t,opacity:0}]),setTimeout(()=>{r(e=>e.map((t,n)=>n===e.length-1?{...t,opacity:1}:t))},1e3)}},[e]),(0,p.jsx)(`div`,{className:`slideshow-container`,children:n.map((e,n)=>(0,p.jsx)(`img`,{src:`data:image/jpeg;base64, ${e.src}`,alt:`Slide ${n+1}`,className:`slideshow-image`,style:{opacity:e.opacity,transition:`opacity ${t}ms linear`}},n))})};function ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:s,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,onPluginAiImageLimitExceeded:g,onImageGenerateLimitExceeded:_}){let{__:v}=o.h(),y=i.sn(),b=o.o(),x=i.wt(),{emailId:S,blockId:C,projectId:w}=(0,f.useParams)(),[T]=a.C(),[E,{data:D=[]}]=a.v(),[O]=a.g(),k=y?.sendAIImageRequest||T,A=y?.trigger||E,j=y?.handleLimitUsageEmitter||i.q(i.Co.ON_LIMIT_ID),[M,N]=(0,u.useState)(0),[P,F]=(0,u.useState)(null),[I,L]=(0,u.useState)(!1),[R,z]=(0,u.useState)(v(`Evaluating the task`)),[B,V]=(0,u.useState)(!1),ee=S||C,{limits:te}=y?.limits?y:{limits:{ai_img_limit:0}},{ai_img_limit:H}=te,U=H>0&&M>=H,W=!!(y.limits&&y.counters)&&i.Ta.isPlugin,G=(0,u.useCallback)(()=>{j.fire({name:`AiImgCount`,count:M+1})},[j,M]),K=(0,u.useMemo)(()=>!U&&(!W||H===0||M<H),[U,W,M,H]),ne=(0,u.useCallback)(async()=>{z(v(`Evaluating the task`)),l!==``&&!m&&(h(!0),V(!0),p([]),x({event:`submit_form`,action:`ai_image_generation`,entity_id:S,project_id:w}),k({body:{project_id:w,request:`create-image`,connection:`midjourney`,message:l}}).then(({data:e,error:t})=>{if(t)throw t;if(e.data.status===401)throw Error(i.la);e?.data.status===200?(e?.data.task.id&&(z(e.data.task.message),F(e.data.task.id)),e.message&&b.success({id:`AI_IMAGE_SEND_SUCCESS`,title:e.message,placement:`bottomRight`,data:l}),A({task_id:e?.data.task.id,entity_id:ee})):(h(!1),V(!1),b.error({id:`AI_IMAGE_SEND_ERROR`,title:e?.message||v(`Something went wrong, please try again`),placement:`bottomRight`,data:l,innerException:e}))}).catch(e=>{h(!1),V(!1),(e?.error||e?.data)&&b.fromError(`AI_IMAGE_SEND_ERROR`,l,e.error||e)}))},[l,m,h,V,p,x,S,w,k,b,A,ee,v]),re=(0,u.useCallback)(async()=>{if(K){if(!W){let e=c.l(`image_generate`,(await O(`image_generate`)).data?.stats);if(e){_?.(e);return}}W&&(N(e=>e+1),G()),ne()}else W&&(g?g():b.error({title:v(`The usage limit has been exceeded`),description:v(`The maximum number of requests for the current subscription period has been reached.
|
|
4
|
-
Select the appropriate plan to fulfil more requests`),placement:`bottomRight`}))},[K,W,O,_,N,G,ne,b,v,g]);(0,u.useEffect)(()=>{W&&N(y?.counters?.ai_img_counter||0)},[y,W]);let ie=(0,u.useCallback)(e=>{if(!r){s(!0);let n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;let r=n[1],i=n[2],a=atob(i),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let c=new Uint8Array(o),l=new Blob([c],{type:`image/${r}`});t({file:new File([l],`image.jpeg`,{type:l.type})})}},[r,s,t]),ae=(0,u.useCallback)(e=>{e.status!==`error`&&e.status!==`Canceled`?e.images?(z(e.status),e.progress===100&&(p(e.images),z(v(`Evaluating the task`)),F(null),V(!1))):(p([e.data]),h(!1)):(h(!1),V(!1),b.error({id:`AI_IMAGE_GET_ERROR`,title:v(`Something went wrong, please try again`),placement:`bottomRight`,data:P}))},[p,z,v,h,e,P,b,V]);return(0,u.useEffect)(()=>{D.length>1&&ae(D[D.length-1])},[D,ae]),(0,u.useEffect)(()=>{(m||d.length>0)&&setTimeout(()=>{let t=550;n.current&&(t=n.current.offsetHeight+68),e(t)},0)},[n,D,d.length,m,e]),{aiImageCounter:M,setAiImageCounter:N,currentAiImgLimits:H,isFieldsDisabled:U,canGenerateImage:K,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,loadingDuringGeneration:B,setLoadingDuringGeneration:V,requestStatus:R,setRequestStatus:z,handleGenerate:re,handleLimitAiImgCount:G,convertBase64ToFile:ie,isShiftPressed:I,setIsShiftPressed:L,currentReqId:P,setCurrentReqId:F,limitsInPlugin:W}}var te=({setModalHeight:e,customRequest:t,aiTabRef:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,setAiImageRequest:h,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y})=>{let b=(0,f.useNavigate)(),x=i.Oi(),{__:S,_n:C}=o.h(),w=i.sn(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),{aiImageCounter:k,currentAiImgLimits:A,loadingDuringGeneration:j,requestStatus:M,handleGenerate:N,convertBase64ToFile:P,isShiftPressed:F,setIsShiftPressed:I,limitsInPlugin:L}=ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y,onPluginAiImageLimitExceeded:()=>E(!0),onImageGenerateLimitExceeded:O}),R=T&&A>0?l.p(A):null,z=R?c.u(R.presetId):null,B=D?c.u(D.presetId):null,[te,H]=(0,u.useState)(!1),U=(0,u.useCallback)(()=>H(!0),[]),W=(0,u.useCallback)(()=>H(!1),[]),G=(0,u.useCallback)(e=>h(e.target.value),[h]),K=(0,u.useCallback)(e=>{e.key===`Shift`?I(!0):e.key===`Enter`&&!F&&(e.preventDefault(),N())},[F,N,I]),ne=(0,u.useCallback)(e=>{e.key===`Shift`&&I(!1)},[I]),re=g[g.length-1];return(0,p.jsxs)(`div`,{className:`image-ai`,children:[z&&R?(0,p.jsx)(c.f,{open:!0,onClose:()=>E(!1),title:S(z.titleKey),subtitle:S(z.subtitleKey),usageResource:z.usageResource,previousDisplay:c.d(R.previousLimit),nextDisplay:c.d(R.nextLimit),onChangePlan:()=>{E(!1),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.ba.SWITCH_TO_PLAN_MODAL))}}):null,B&&D?(0,p.jsx)(c.f,{open:!0,onClose:()=>O(null),title:S(B.titleKey),subtitle:S(B.subtitleKey),usageResource:B.usageResource,previousDisplay:c.d(D.previousLimit),nextDisplay:c.d(D.nextLimit),onChangePlan:()=>{O(null),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.ba.SWITCH_TO_PLAN_MODAL))}}):null,L&&(0,p.jsx)(o.P,{text:`${k} ${S(`of`)} ${A>0?A:`∞`} images ${C(`was used`,`were used`,k)}`,exceeded:A>0&&k>=A,style:{marginTop:-25},extra:(0,p.jsx)(`span`,{style:{textDecoration:`underline`,cursor:`pointer`},onClick:()=>b(w.billingPageUrl||i.Hi.billing),children:S(`Need more?`)})}),(0,p.jsx)(o.Ot,{gutter:24,className:`image-ai__row`,children:(0,p.jsx)(o.Dt,{span:24,children:(0,p.jsx)(o.Ft.Item,{style:{margin:0},children:(0,p.jsxs)(`span`,{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${te?` ant-input-affix-wrapper-focused`:``}`,children:[(0,p.jsx)(o.xt,{ref:r,onKeyDown:K,onKeyUp:ne,onFocus:U,onBlur:W,autoSize:!0,allowClear:!0,className:`text-area-input-hybrid image-ai__textarea`,placeholder:S(`Generate image`),value:m,onChange:G,spellCheck:`false`}),(0,p.jsx)(`span`,{className:`ant-input-suffix image-ai__input-suffix`,children:v||j?(0,p.jsx)(c.m,{icon:`LoadingOutlined`,className:`input-icon image-ai__input-icon`,spin:!0}):(0,p.jsx)(c.m,{icon:`AI`,className:`input-icon image-ai__input-icon`,onClick:N})})]})})})}),(v||g.length>0)&&(0,p.jsxs)(`div`,{className:`image-ai__preview`,children:[v&&g.length===0&&(0,p.jsx)(`div`,{className:`image-ai__loading`,children:(0,p.jsxs)(`div`,{className:`spin`,children:[(0,p.jsx)(c.m,{icon:`LoadingOutlined`,style:{fontSize:48},spin:!0}),(0,p.jsx)(`p`,{className:`status`,children:M})]})}),g.length>0&&(0,p.jsxs)(`div`,{className:`image-ai__image-item`,children:[(0,p.jsx)(V,{images:g}),(0,p.jsx)(`div`,{className:`buttons`,children:(0,p.jsx)(o.Rt,{onClick:()=>P(`data:image/jpeg;base64, ${re}`),icon:(0,p.jsx)(c.m,{icon:`CheckOutlined`}),children:S(`Use this one`)})})]})]})]})},H=({setNewLink:e,setCurrentImageLink:t,setModalHeight:n,setModalWidth:r,setImageGifList:s,imageGifList:l,currentReqGif:d,setCurrentReqGif:f,inputRef:m,setStockLink:h,customRequest:g})=>{let{__:_}=o.h(),v=i.sn(),y=c.t(),b=o.o(),[x,S]=(0,u.useState)(null),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)(25),[O]=a.b(),k=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:_(`Failed to load GIFs through the configured proxy chain.`),[_]),A=(0,u.useCallback)(e=>{b.error({id:`STOCK_GIFS_SEARCH_FAILED`,title:_(`Failed to load GIFs`),description:k(e)})},[_,k,b]),j=async()=>{C||(w(!0),O({query:d,page:T}).then(e=>{if(e?.error){A(e.error),w(!1);return}s(t=>[...t,...e.data.data]),w(!1),E(e=>e+25)}).catch(()=>{w(!1)}))},M=async()=>{let e=await O({query:d,page:0});if(e?.error){A(e.error),s([]);return}e?.data?.data?.length>0&&(s(e.data.data),setTimeout(()=>{n(`84vh`),r(1060)},0))},N=(e,n)=>{S(n),setTimeout(()=>{S(null)},2e3),h(`${e}`),t(`${e}`),g(`${e}`)},P={default:3},F=(0,u.useCallback)(e=>i.no(e,{config:v,standalone:y,resourceType:`generic`,intent:`display`}),[v,y]),{getDisplaySrc:L,handleLoad:z,handleError:B}=R({items:l,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>e.images.downsized.url,[]),createController:F}),V=e=>t=>{z(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:M,className:l.length>0?`serach-results`:``,children:[(0,p.jsx)(o.Ot,{gutter:24,children:(0,p.jsx)(o.Dt,{span:l.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:M,allowClear:!0,size:l.length>0?`medium`:`large`,placeholder:_(`Search GIFs`),value:d.keywords,onChange:e=>f(t=>({...t,keywords:e.target.value})),ref:m,spellCheck:`false`,enterButton:!1})})})}),l.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:l.length>0&&(0,p.jsx)(`div`,{id:`scrollableDiv`,style:{width:`100%`,height:`calc(84vh - 148px)`,overflow:`auto`,paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:`0`,boxSizing:`unset`},children:(0,p.jsx)(D,{dataLength:l&&l.length,next:j,hasMore:l,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[_("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:(0,p.jsx)(o.K,{size:`small`}),children:(0,p.jsx)(I,{breakpointCols:P,className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:l.map((e,t)=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>N(e.images.downsized.url,e.id),children:[(0,p.jsx)(`img`,{className:x===e.id?`loaded-image`:``,width:`322px`,src:L(e),alt:e.title,onLoad:V(e),onError:ee(e)}),(0,p.jsx)(`a`,{rel:`noreferrer`,href:`https://giphy.com/`,target:`_blank`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`overlay-image`,style:{backgroundImage:`url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAkCAYAAAB/up84AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABSBJREFUeNrsWjFv2zoQVoMW8BZ18xaN3qLRW9QtW9OtW92to98vaPoP3K1b1S1b3c2jvWlUNm3lw1s8Mpu3PAo4Iocr70jKlp0COuCQlpKPx/t43x1pv3h8fEwGeT5yNoTgeclLZvza6NgxXoNaGRktjE6MpjC2NVqh92bwt4HxBI1ro0s0dgN2tvD5a8a/9vkq0M+xYKdG81A7Gp6pyBjZddrnO6N36Hkbqyn8u4L3vYC0hjLHeAbPVhC4TwAK/ewNvLsEhyxgFXLK2l/D4tvnOVrUiPEh1k/JjvLYyWENdeTcKazBBr6AdY4AqBTmbkIzhO4gvMumYLxAYKzgPTvhBBajYNwCksHYhOyYiow1KONaKYlfO8bPEWyGEfi5Iu+Vjizg7EzB3xvwWTMxWkHG4mDnMF6BnSnYncLzHWGG4BqiwZkKQMC7I0cOVTCJhvRUKNgNCmCOxhNmrBEWzwGi0Y6rIihbsnOH/JgE2hshKrLZv4Px9yhj1twafRlid/UIGWvlFdlVLirIkIM12nETGLeO2tTPECBUZuT/a7JBMpSxUybYLjulUCN2iEpHQoyuGWZJUCa8R/VGSZvGB0iOdjAO9n8EtC2zUxICSIoW0ICTmA53DCDKQzWZg89XAXZ2B2iMavBnjDKpBX6B1tnAM5aqQgGhnU2D6GmHuqw7AkaOPmP/bsHpFC1kTLqVhglS6fFNgX1MCXUHO1zR1h5AFOoSc1jjmKx/An/1PoBQasBSoZZ3hpyaOrg0IW2sRkG8JsU8CaCaLckAhfi6AG0cmeuzkyMQMtL+SiySkY3oA/EgGeICK0UOZYQKVsQpDAjm2BpsaAGQLMKnMdok3yLtpKS70yT7OUBcm7UTHb5grk5y1Csrj40MqUbUpgW7NXo+RunckODkQvdXM37iwm7b1VA7lAaVB4jUUZOUIzNxfOougAwy3GUN0qWG2IJJ09V2NcvIFE8c54nQelEHFM6C6chUhI+WZjjffDQkrenPhqmlrAC9Naof/aLhXZeNNfMZOk+MtPOVRjNmTpfcCut0+biGZ3PBj1ywWTOfqV3v+yjLFuDPRs8Ddu05vLtmsuHQ0s73wehvR0t7aGkPevfCM5fcGr0MbOW9NSSFwF52cP5KcLIv+X4EUGbCemcOqpoz73/haE4CZNkRjAR20vwENXHRc2bWEMyQuUuGVe4hc6K6rBmg7pKN0XdGX7dts9E3Rr8afUATFl1PqgLAG6T3AoX1nSVtMP9l5r5FVyiu+D14/YssRHOheGVQYNMeinrhsMcV2WVPRR1rIRT4QmiA5r4G6oxp0y6ZzFh4LvhmB84MHz1xta9vWQMrcFR/3iF+7DmEu2YoyTshRbuMvGE9hnwGPQR1tdR04aCueKrqAIgiu/AqcCf1JXPhfuoYosGHn4Hgqa6AnCK4IfSkCa1eCJRxLGnn+mX0rfDOJok4AsQAUpwQlND2++HIgNiOVO1LVRIgtXDPs0bpunEU08vktHLMpoJS1/d9qEo6h6gAzq7RRaPV+QmBeICzUUh2fIHzk0s3HedXwkEy2ReQmjn4XDzDjqkN4D/J04/y/np5KbSrrtbwAyx+kTxdf9tfpvSZIW9O3FScHJAF8PEFc5F2lQzSi5wJheoG3U/t0xYOcgBAcOHuAkr7mY9ditoAiCz2q8uvEcD8gJpSDuGNl5hfnaTJ0/fpheMUr4CitHCO6fqdesj359xh1tWiqggfdUCmcz9ZivZ7+BnQM5P/BRgABx8sJWqTxoYAAAAASUVORK5CYII=)`}})}),x===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id+t))})})})})]})};function U(e){if(!(e==null||e===``))return e}async function W(e,t){if(e){if(e.url)return e.url;if(typeof t.getFileById==`function`&&e.id){let n=await t.getFileById(e.id);if(n?.url)return n.url;if(n?.thumbnailUrl)return n.thumbnailUrl;if(n?.thumbnail)return n.thumbnail}if(typeof t.getFileUrl==`function`&&e.folderId!==void 0&&e.name){let n=await t.getFileUrl(e.folderId||``,e.name);if(n)return n}if(typeof t.getUrl==`function`&&e.name){let n=await t.getUrl(e);if(n)return n}return e.thumbnail||e.thumbnailUrl}}function G(e){if(!(!e?.success||!Array.isArray(e.detailed)))return e.detailed.find(e=>e?.success&&e.data)?.data}function K(e,t,n){if(e)return{id:e.id,name:e.name||t.name,size:e.size??t.size,type:e.type||t.type,folderId:e.folderId??n??``,url:e.url,thumbnail:e.thumbnail,thumbnailUrl:e.thumbnailUrl,date:e.date,dimensions:e.dimensions,aspectRatio:e.aspectRatio,extension:e.extension,selected:e.selected,isFolder:e.isFolder,lastEdited:e.lastEdited,childrenCount:e.childrenCount}}async function ne(e,t,n){if(!t)return;let r=U(n??t.rootId),i;typeof t.uploadFiles==`function`?i=G(await t.uploadFiles({folderId:r,items:[{name:e.name,size:e.size,type:e.type,folderId:r,data:e}]})):typeof t.uploadFile==`function`&&(i=K(await t.uploadFile({name:e.name,size:e.size,type:e.type,folderId:r,data:e}),e,r));let a=await W(i,t);return a?{item:i,url:a}:void 0}var re=`IMG`,ie=`BACKGROUND`,ae=`GALLERY`,oe=`EDITOR`,q=`UPLOAD`,se=`STOCK`,ce=`GIF`,le=`AI`,{Dragger:ue}=o.gt,de=(e,t=`image`)=>{try{let n=new URL(e).pathname.split(`/`).pop();return n&&decodeURIComponent(n)||t}catch{return t}},fe=l.f,pe=(e,t)=>{let n=fe(t);return!n||e.includes(`.`)?e:`${e}.${n}`},me=(e,t)=>new File([e],pe(de(t),e.type),{type:e.type||`application/octet-stream`}),he=({dataProvider:e})=>{let t=i.sn(),n=c.t(),{__:r}=o.h(),s=i.Oi(),{projectId:d}=(0,f.useParams)(),[m]=a.y(),{modal:h}=o.Wt.useApp(),g=o.o(),_=i.Di(i.r),v=i.Di(i.n),b=i.Di(a.s),{request:x,resolveImagePicker:S}=c.r(),[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,M]=(0,u.useState)(q),[N,P]=(0,u.useState)({width:``,height:``,size:``,format:``}),[F,I]=(0,u.useState)(`success`),[L,R]=(0,u.useState)(!1),z=u.default.useRef(null),V=u.default.useRef(null),ee=u.default.useRef(null),U=u.default.useRef(null),W=u.default.useRef(null),G=u.default.useRef(null),K=u.default.useRef(null),de=u.default.useRef(null),pe=u.default.useRef(null),[he,J]=(0,u.useState)(`auto`),[ge,Y]=(0,u.useState)(572),[_e,ve]=(0,u.useState)(!1),[ye,be]=(0,u.useState)({keywords:``,color:``,orientation:``}),[xe,Se]=(0,u.useState)({keywords:``}),[Ce,we]=(0,u.useState)([]),[Te,Ee]=(0,u.useState)([]),[De,Oe]=(0,u.useState)([]),[ke,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(!1),[Fe,Ie]=(0,u.useState)(0),Le=i.Di(i.ct),Re=Le?.id===void 0?d||``:String(Le.id),ze=i.q(i.Co.UPLOAD_EVENT_ID),Be=u.default.useRef(l.u()),Ve=u.default.useRef(``),He=u.default.useRef(0),X=u.default.useRef(``),[Ue,We]=(0,u.useState)(``),[Ge,Ke]=(0,u.useState)(``),Z=(0,u.useCallback)(()=>{X.current&&=(URL.revokeObjectURL(X.current),``),We(``)},[]),Q=(0,u.useCallback)(()=>{Ke(``)},[]),$=!(_||v.id?.toString()!==Le?.members?.owner.ID),qe=e=>{E(e.target.value)},Je=(0,u.useCallback)((e,t,n=r(`The image could not be uploaded.`))=>{let i=t instanceof Error?t.message:n;g.error({id:`IMAGE_UPLOAD_ERROR`,data:e,title:r(`Upload failed`),description:i})},[r,g]),Ye=(0,u.useCallback)(async e=>c.o(await ze.fire({file:e,project:Re})),[Re,ze]),Xe=l.t(),Ze=async e=>{if(e)try{let t=await $e(e);t&&it(t)?await at({file:t}):t||Je({url:e},null,r(`Failed to download image from URL.`))}catch(t){Je({url:e},t,r(`Failed to process image URL.`))}},Qe=u.default.useRef(Ze);Qe.current=Ze,u.default.useEffect(()=>{if(j!==q||!k)return;let e=T.trim();if(!e||!e.toLowerCase().startsWith(`http`))return;let t=setTimeout(()=>{Qe.current(e)},1e3);return()=>{clearTimeout(t)}},[T,j,k]);let $e=async e=>{try{let t=l.l(e);return me(await Be.current.resolve(t,void 0,Xe),t)}catch{}};document.onpaste=function(e){let n=e.clipboardData?.items?.[0];if(j===q&&k){if(n?.type?.indexOf(`image`)===0&&t.imageCenterLocalUploadEnabled!==!1){let e=n.getAsFile();it(e);let t={file:e};E(``),at(t);return}let r=e.clipboardData?.getData(`text/plain`);if(r&&r.trim().toLowerCase().startsWith(`http`)){e.preventDefault(),e.stopPropagation(),E(r.trim());return}n?.type?.indexOf(`text`)===0&&n.getAsString(e=>{if(e.trim().toLowerCase().startsWith(`http`))E(e.trim());else if(e.toString().slice(1,5)===`meta`){let t=e.toString().split(`"`)[1];t&&E(t)}})}},(0,u.useEffect)(()=>{let e=e=>{let t=null;x?.kind===`background`?(t=ie,A(ie)):x?.kind===`img`&&(A(re),t=re),x?.currentUrl&&t&&(w(x.currentUrl),M(e))};b===i.ba.UPLOAD_IMAGE_MODAL||b===i.ba.UPLOAD_BACKGROUND_MODAL?e(oe):b===i.ba.UPLOAD_IMAGE_MODAL_AI||b===i.ba.UPLOAD_BACKGROUND_MODAL_AI?($?(Pe(!0),Ie(2)):e(le),setTimeout(()=>pe.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_UPLOAD||b===i.ba.UPLOAD_BACKGROUND_MODAL_UPLOAD?(e(q),setTimeout(()=>G.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_STOCK||b===i.ba.UPLOAD_BACKGROUND_MODAL_STOCK?($?(Pe(!0),Ie(3)):e(se),setTimeout(()=>de.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_GIF||b===i.ba.UPLOAD_BACKGROUND_MODAL_GIF?($?(Pe(!0),Ie(3)):e(ce),setTimeout(()=>K.current?.focus({cursor:`start`}),100)):b===i.ba.UPLOAD_IMAGE_MODAL_EDIT||b===i.ba.UPLOAD_BACKGROUND_MODAL_EDIT?($?(Pe(!0),Ie(5)):e(oe),s(a.i(i.ba.IMAGE_EDITOR_MODAL))):A(``)},[b,s,$,x]);let et=(0,u.useCallback)(({url:e=C||``})=>{w(e),S({url:e,meta:{mode:`select`}}),setTimeout(()=>{Q(),Z(),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),Ee([]),we([]),A(``),Me(``),Ae(!1),O(``),E(``),M(q)},200),s(a.t()),s(a.n())},[C,Q,s,S,Z]),tt=(0,u.useCallback)((e,t)=>(J(`auto`),R(!1),et({url:e}),g.success({id:`IMAGE_UPLOAD_SUCCESS`,data:t,title:r(`The image was successfully uploaded.`)}),e),[r,et,g]);(0,u.useEffect)(()=>{let t=T||D,r=l.l(t);if(!t||!r){I(``),Ve.current=``,Q(),Z(),Be.current.invalidateAll();return}let i=Ve.current;i&&i!==r&&(Be.current.abandonKey(i),Q(),Z()),Ve.current=r;let a=new AbortController,o=T?800:0,s=++He.current,c=setTimeout(async()=>{try{let i=async()=>{let e=await Be.current.resolve(r,a.signal,Xe);if(s!==He.current)return;let{width:t,height:n}=await l.d(e);if(s!==He.current)return;P({width:t,height:n,size:(e.size/1024).toFixed(2),format:fe(e.type)}),Q(),X.current&&URL.revokeObjectURL(X.current);let i=URL.createObjectURL(e);X.current=i,We(i)};if(n)await i();else{let t=await l.n(e,r);if(t?.previewUrl&&s===He.current){Ke(t.previewUrl),Z();try{let{data:e}=await m(r);if(s!==He.current)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await i()}catch{await i()}}else await i()}if(s!==He.current)return;I(`success`),w(t),Y(572),setTimeout(()=>{let e=0;V.current&&(e=V.current.offsetHeight+62),J(e)},0)}catch(e){if(e?.name===`AbortError`||a.signal.aborted||s!==He.current)return;Q(),Z(),I(`error`)}},o);return()=>{clearTimeout(c),a.abort()}},[T,D,n,Q,Xe,m,Z,e]),(0,u.useEffect)(()=>{if(!C||T||D)return;let t=l.l(C),r=new AbortController,i=!1,a=async()=>{let e=await Be.current.resolve(t,r.signal,Xe);if(i)return;let{width:n,height:a}=await l.d(e);if(i)return;Q(),X.current&&URL.revokeObjectURL(X.current);let o=URL.createObjectURL(e);X.current=o,We(o),P({width:n,height:a,size:(e.size/1024).toFixed(2),format:fe(e.type)})};return(async()=>{try{if(!n){let n=await l.n(e,t);if(n?.previewUrl&&!i){Ke(n.previewUrl),Z();try{let{data:e}=await m(t);if(i)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await a();return}catch{await a()}}}await a()}catch{i||Q()}})(),()=>{i=!0,r.abort()}},[n,Q,C,Xe,m,e,T,D]);let nt=()=>{s(a.t()),setTimeout(()=>{Q(),Z(),w(``),E(``),Ee([]),Ee([]),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),J(`auto`),!ke&&Me(``),Y(572),M(q)},200)},rt=e=>{e===ae?h.success({mask:{closable:!0},centered:!0,title:r(`Coming soon`),content:r(`The feature is under development.`),okText:r(`Ok. I'll be waiting`),onOk:()=>{}}):e===oe&&C===``?h.warning({mask:{closable:!0},centered:!0,title:r(``),content:r(`To preview and edit the uploaded image`),okText:r(`Upload Image`),onOk:()=>{M(q)}}):(setTimeout(()=>{let t=0,n=0;e===q&&z.current?(ye.keywords===``&&G.current?.focus({cursor:`start`}),t=300,n=572):e===oe&&V.current?(t=V.current.offsetHeight+62,n=572):e===se&&ee.current?(ye.keywords===``&&de.current?.focus({cursor:`start`}),t=130,n=572,Te.length>0&&(n=1060,t=`84vh`)):e===ce&&U.current?(ye.keywords===``&&K.current?.focus({cursor:`start`}),t=130,n=572,Ce.length>0&&(n=1060,t=`84vh`)):e===le&&W.current&&(je===``&&De.length===0?(pe.current?.focus({cursor:`start`}),t=130):t=W.current.offsetHeight+82,n=572),J(t),Y(n)},0),M(e))};(0,u.useEffect)(()=>{ye.keywords===``&&(G?.current?.focus({cursor:`start`}),Ee([]),setTimeout(()=>{J(`auto`),Y(572)},0))},[ye,Ee,J,Y]);let it=e=>{let t=e.type===`image/jpeg`||e.type===`image/png`||e.type===`image/jpg`||e.type===`image/webp`||e.type===`image/gif`||e.type===`image/svg+xml`;return t||g.error({id:`IMAGE_UPLOAD_WRONG_FORMAT`,data:e,title:`Upload`,description:`You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!`}),t},at=async({file:n})=>{try{ve(!0);let r=await l.i(n,t),i=await Ye(r);if(i)return tt(i,r),i;let a=await ne(r,e);if(a?.url)return tt(a.url,r),a.url;Je(r,null);return}catch(e){Je(n,e);return}finally{ve(!1)}},ot=e=>at({file:e}),st=[{label:r(`Upload`),key:q,children:(0,p.jsxs)(`div`,{ref:z,style:{paddingBottom:24},children:[t.imageCenterLocalUploadEnabled!==!1&&(0,p.jsxs)(ue,{showUploadList:!1,name:`Image`,beforeUpload:it,customRequest:at,style:{marginBottom:10},multiple:!1,accept:`image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml`,children:[(0,p.jsx)(`p`,{className:`ant-upload-drag-icon`,children:(0,p.jsx)(c.m,{icon:`InboxOutlined`})}),(0,p.jsx)(`p`,{className:`ant-upload-text`,children:r(`Click to select, paste from the clipboard, or drag and drop`)}),(0,p.jsx)(`p`,{className:`ant-upload-hint`,children:r(`Accepted formats: PNG, JPG, WEBP, SVG or GIF.`)})]}),(0,p.jsx)(o.Ft,{style:{padding:`0 2px 0 2px`},children:(0,p.jsx)(o.Ft.Item,{validateStatus:F,children:(0,p.jsx)(o.kt,{ref:G,allowClear:!0,size:`large`,placeholder:r(`Paste image URL here`),value:T,onChange:qe,spellCheck:`false`})})})]})}];return t.imageCenterStockEnabled&&!$&&st.push({label:r(`Stock`),key:se,children:(0,p.jsx)(`div`,{ref:ee,style:{paddingBottom:24},children:(0,p.jsx)(B,{currentReq:ye,setCurrentReq:be,imageStockList:Te,setImageStockList:Ee,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:de,customRequest:Ze})})}),t.imageCenterGifEnabled&&!$&&st.push({label:r(`GIF`),key:ce,children:(0,p.jsx)(`div`,{ref:U,style:{paddingBottom:24},children:(0,p.jsx)(H,{currentReqGif:xe,setCurrentReqGif:Se,imageGifList:Ce,setImageGifList:we,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:K,customRequest:Ze})})}),t.elementAIimageEnabled&&!$&&st.push({label:r(`AI`),key:le,children:(0,p.jsx)(`div`,{ref:W,style:{paddingBottom:24},children:(0,p.jsx)(te,{setModalHeight:J,customRequest:at,aiImageRequest:je,setAiImageRequest:Me,imageAiList:De,setImageAiList:Oe,isLoadingAi:ke,setIsLoadingAi:Ae,aiTabRef:W,inputAiRef:pe,isImageUploaded:L,setIsImageUploaded:R})})}),t.imageCenterEditorEnabled&&st.push({label:``,key:oe,children:(0,p.jsx)(`div`,{ref:V,children:(0,p.jsx)(y,{currentImageLink:C,newLink:T,previewDisplayUrl:Ge,resolvedPreviewObjectUrl:Ue,imageSize:N,onSave:ot,uploadImageResultIsLoading:_e||!1})})}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Y,{width:ge,className:`image-center`,title:r(`Image Center`),style:{minHeight:390},open:!!k,onOk:et,onCancel:nt,footer:j===oe?(0,p.jsx)(p.Fragment,{}):null,children:(0,p.jsx)(o.K,{spinning:_e,children:(0,p.jsx)(o.Z,{activeKey:j,onChange:rt,items:st,className:`modal-tabs`,style:{height:he,minHeight:130}})})}),(0,p.jsx)(c.g,{open:Ne,onCancel:()=>Pe(!1),initialSlide:Fe})]})};he.propTypes={dataProvider:d.default.object},t.default=he});
|
|
3
|
+
as expected. Check README.md for usage'`)},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener(`scroll`,this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener(`touchstart`,this.onStart),this.el.removeEventListener(`touchmove`,this.onMove),this.el.removeEventListener(`touchend`,this.onEnd),this.el.removeEventListener(`mousedown`,this.onStart),this.el.removeEventListener(`mousemove`,this.onMove),this.el.removeEventListener(`mouseup`,this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength===t.prevDataLength?null:S(S({},t),{prevDataLength:e.dataLength})},t.prototype.isElementAtTop=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){t===void 0&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=E(t);return r.unit===w.Pixel?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=S({height:this.props.height||`auto`,overflow:`auto`,WebkitOverflowScrolling:`touch`},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:`auto`}:{};return u.default.createElement(`div`,{style:r,className:`infinite-scroll-component__outerdiv`},u.default.createElement(`div`,{className:`infinite-scroll-component `+(this.props.className||``),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&u.default.createElement(`div`,{style:{position:`relative`},ref:function(t){return e._pullDown=t}},u.default.createElement(`div`,{style:{position:`absolute`,left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(u.Component);function O(e,t){if(e==null)return{};var n=k(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function k(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(this,arguments)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?j(Object(n),!0).forEach(function(t){N(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0},F=2,I=class extends u.default.Component{constructor(e){super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let t;t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||F,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener(`resize`,this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener(`resize`,this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){if(!window||!window.requestAnimationFrame){this.reCalculateColumnCount();return}window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})}reCalculateColumnCount(){let e=window&&window.innerWidth||1/0,t=this.props.breakpointCols;typeof t!=`object`&&(t={default:parseInt(t)||F});let n=1/0,r=t.default||F;for(let i in t){let a=parseInt(i);a>0&&e<=a&&a<n&&(n=a,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){let e=this.state.columnCount,t=Array(e),n=u.default.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){let i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){let{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),i=`${100/r.length}%`,a=n;a&&typeof a!=`string`&&(this.logDeprecated(`The property "columnClassName" requires a string`),a===void 0&&(a=`my-masonry-grid_column`));let o=M(M(M({},e),t),{},{style:M(M({},t.style),{},{width:i}),className:a});return r.map((e,t)=>u.default.createElement(`div`,A({},o,{key:t}),e))}logDeprecated(e){}render(){let e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:i,column:a,className:o}=e,s=O(e,[`children`,`breakpointCols`,`columnClassName`,`columnAttrs`,`column`,`className`]),c=o;return typeof o!=`string`&&(this.logDeprecated(`The property "className" requires a string`),o===void 0&&(c=`my-masonry-grid`)),u.default.createElement(`div`,A({},s,{className:c}),this.renderColumns())}};I.defaultProps=P;function L(e,t){return e?e.exhausted?{...e,src:null}:{...e,src:e.src||t||null}:null}function R({items:e,getItemId:t,getRequestUrl:n,createController:r}){let[i,a]=(0,u.useState)({}),o=(0,u.useRef)(new Map),s=(0,u.useCallback)(e=>{let i=t(e),a=n(e),s=`${i}:${a}`;if(o.current.has(s))return{itemId:i,requestUrl:a,cacheKey:s,controller:o.current.get(s)};let c=r(a);return o.current.set(s,c),{itemId:i,requestUrl:a,cacheKey:s,controller:c}},[r,t,n]);return(0,u.useEffect)(()=>{let t=new Set,n={},r=e.map(e=>{let{itemId:r,cacheKey:i,controller:o}=s(e);t.add(i),n[r]=o.src;let c=L(o.handleChangeSrc?.(),o.src);return c?.changed&&c.src&&(n[r]=c.src),o.subscribeToSrcChange?.(e=>{let t=L(e,o.src);!t?.changed||!t.src||a(e=>e[r]===t.src?e:{...e,[r]:t.src})})}).filter(Boolean);return o.current.forEach((e,n)=>{t.has(n)||o.current.delete(n)}),a(n),()=>{r.forEach(e=>e?.())}},[s,e]),{getDisplaySrc:(0,u.useCallback)(e=>{let{itemId:t,requestUrl:n,controller:r}=s(e);return i[t]||r.src||n},[i,s]),handleLoad:(0,u.useCallback)(e=>{s(e).controller.handleSuccess()},[s]),handleError:(0,u.useCallback)(e=>{let{itemId:t,controller:n}=s(e),r=L(n.handleError(),n.src);r?.changed&&r.src&&a(e=>({...e,[t]:r.src}))},[s])}}var z=`blocks`,B=({setCurrentImageLink:e,setModalHeight:t,setModalWidth:n,setImageStockList:r,imageStockList:s,currentReq:l,setCurrentReq:d,inputRef:f,setStockLink:m,customRequest:h})=>{let g=i.cn(),_=c.t(),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(2),{__:S}=o.h(),C=o.o(),[w]=a.S(),[T]=a.x(),E=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:S(`Failed to load stock images through the configured proxy chain.`),[S]),O=(0,u.useCallback)(e=>{C.error({id:`STOCK_IMAGES_SEARCH_FAILED`,title:S(`Failed to load stock images`),description:E(e)})},[S,E,C]),k=async()=>{v||(y(!0),T({query:l,page:b}).then(e=>{if(e?.error){O(e.error),y(!1);return}let t=e?.data?.results||[];r(e=>[...e,...t]),y(!1),x(e=>e+1)}).catch(()=>{y(!1)}))};(0,u.useEffect)(()=>{l.keywords!==``&&A()},[l.color,l.orientation]);let A=async()=>{let e=await T({query:l,page:1});if(e?.error){O(e.error),r([]);return}let i=e?.data?.results||[];i.length>0?(r(i),setTimeout(()=>{n(1060),t(`84vh`)},0)):r([])},[j,M]=(0,u.useState)(null),N=(0,u.useCallback)((e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}w=${t}&q=${n}`,[]),P=(0,u.useCallback)(e=>i.ro(e,{config:g,standalone:_,resourceType:`stockImages`,intent:`display`}),[g,_]),{getDisplaySrc:F,handleLoad:L,handleError:B}=R({items:s,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>N(e.urls.raw,644,96),[N]),createController:P}),V=e=>t=>{L(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)},te=(t,n,r)=>{w(n.download_location),M(r),setTimeout(()=>M(null),2e3),m(`${t.raw}&w=1200&q=96`),e(`${t.raw}&w=1200&q=96`),h(`${t.raw}&w=1200&q=96`)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:A,className:s.length>0?`serach-results`:``,children:[(0,p.jsxs)(o.Ot,{gutter:24,children:[(0,p.jsx)(o.Dt,{span:s.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:A,allowClear:!0,size:s.length>0?`medium`:`large`,placeholder:S(`Search image`),value:l.keywords,onChange:e=>d(t=>({...t,keywords:e.target.value})),ref:f,spellCheck:`false`,enterButton:!1})})}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Dt,{children:(0,p.jsxs)(o._t.Group,{defaultValue:``,onChange:e=>d(t=>({...t,orientation:e.target.value})),children:[(0,p.jsx)(o.U,{title:S(`All`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:``,children:(0,p.jsx)(c.m,{icon:`MixedView`})})}),(0,p.jsx)(o.U,{title:S(`Landscape`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`landscape`,children:(0,p.jsx)(c.m,{icon:`LandscapeView`})})}),(0,p.jsx)(o.U,{title:S(`Portrait`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`portrait`,children:(0,p.jsx)(c.m,{icon:`PortraitView`})})}),(0,p.jsx)(o.U,{title:S(`Squarish`),placement:`top`,children:(0,p.jsx)(o._t.Button,{value:`squarish`,children:(0,p.jsx)(c.m,{icon:`SquareView`})})})]})}),(0,p.jsx)(o.Dt,{children:(0,p.jsx)(o.A,{defaultValue:``,onChange:e=>d(t=>({...t,color:e.target.value})),options:[{value:``,colorClass:`all-colors`,label:S(`All`)},{value:`black`,colorClass:`black-color`,label:S(`Black`)},{value:`black_and_white`,colorClass:`bw-color`,label:S(`Black and White`)},{value:`white`,colorClass:`white-color`,label:S(`White`)},{value:`orange`,colorClass:`orange-color`,label:S(`Orange`)},{value:`red`,colorClass:`red-color`,label:S(`Red`)},{value:`purple`,colorClass:`purple-color`,label:S(`Purple`)},{value:`magenta`,colorClass:`magenta-color`,label:S(`Magenta`)},{value:`green`,colorClass:`green-color`,label:S(`Green`)},{value:`teal`,colorClass:`teal-color`,label:S(`Teal`)},{value:`blue`,colorClass:`blue-color`,label:S(`Blue`)}],tooltipPlacement:`top`})})]})]}),s.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:s.length>0&&(0,p.jsx)(`div`,{id:`scrollableDiv`,style:{width:`100%`,height:`calc(84vh - 148px)`,overflow:`auto`,paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:`0`,boxSizing:`unset`},children:(0,p.jsx)(D,{dataLength:s&&s.length,next:k,hasMore:s,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[S("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:null,children:(0,p.jsx)(I,{breakpointCols:{default:3},className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:s.map(e=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>te(e.urls,e.links,e.id),children:[(0,p.jsx)(`img`,{className:j===e.id?`loaded-image`:``,width:`322px`,src:F(e),alt:e.description,onLoad:V(e),onError:ee(e)}),(0,p.jsxs)(`p`,{className:`creator-info`,onClick:e=>e.stopPropagation(),children:[`Photo by`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`${e.user.links.html}?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:e.user.name}),` `,`on`,` `,(0,p.jsx)(`a`,{target:`_blank`,href:`https://unsplash.com/?utm_source=${z}&utm_medium=referral`,rel:`noreferrer`,children:`Unsplash`})]}),j===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id))})})})})]})},V=({images:e,transitionDuration:t=1e3})=>{let[n,r]=(0,u.useState)([]);return(0,u.useEffect)(()=>{if(e.length>0){let t=e[e.length-1];r(e=>[...e,{src:t,opacity:0}]),setTimeout(()=>{r(e=>e.map((t,n)=>n===e.length-1?{...t,opacity:1}:t))},1e3)}},[e]),(0,p.jsx)(`div`,{className:`slideshow-container`,children:n.map((e,n)=>(0,p.jsx)(`img`,{src:`data:image/jpeg;base64, ${e.src}`,alt:`Slide ${n+1}`,className:`slideshow-image`,style:{opacity:e.opacity,transition:`opacity ${t}ms linear`}},n))})};function ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:s,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,onPluginAiImageLimitExceeded:g,onImageGenerateLimitExceeded:_}){let{__:v}=o.h(),y=i.cn(),b=o.o(),x=i.wt(),{emailId:S,blockId:C,projectId:w}=(0,f.useParams)(),[T]=a.C(),[E,{data:D=[]}]=a.v(),[O]=a.g(),k=y?.sendAIImageRequest||T,A=y?.trigger||E,j=y?.handleLimitUsageEmitter||i.q(i.wo.ON_LIMIT_ID),[M,N]=(0,u.useState)(0),[P,F]=(0,u.useState)(null),[I,L]=(0,u.useState)(!1),[R,z]=(0,u.useState)(v(`Evaluating the task`)),[B,V]=(0,u.useState)(!1),ee=S||C,{limits:te}=y?.limits?y:{limits:{ai_img_limit:0}},{ai_img_limit:H}=te,U=H>0&&M>=H,W=!!(y.limits&&y.counters)&&i.Ea.isPlugin,G=(0,u.useCallback)(()=>{j.fire({name:`AiImgCount`,count:M+1})},[j,M]),K=(0,u.useMemo)(()=>!U&&(!W||H===0||M<H),[U,W,M,H]),ne=(0,u.useCallback)(async()=>{z(v(`Evaluating the task`)),l!==``&&!m&&(h(!0),V(!0),p([]),x({event:`submit_form`,action:`ai_image_generation`,entity_id:S,project_id:w}),k({body:{project_id:w,request:`create-image`,connection:`midjourney`,message:l}}).then(({data:e,error:t})=>{if(t)throw t;if(e.data.status===401)throw Error(i.ua);e?.data.status===200?(e?.data.task.id&&(z(e.data.task.message),F(e.data.task.id)),e.message&&b.success({id:`AI_IMAGE_SEND_SUCCESS`,title:e.message,placement:`bottomRight`,data:l}),A({task_id:e?.data.task.id,entity_id:ee})):(h(!1),V(!1),b.error({id:`AI_IMAGE_SEND_ERROR`,title:e?.message||v(`Something went wrong, please try again`),placement:`bottomRight`,data:l,innerException:e}))}).catch(e=>{h(!1),V(!1),(e?.error||e?.data)&&b.fromError(`AI_IMAGE_SEND_ERROR`,l,e.error||e)}))},[l,m,h,V,p,x,S,w,k,b,A,ee,v]),re=(0,u.useCallback)(async()=>{if(K){if(!W){let e=c.l(`image_generate`,(await O(`image_generate`)).data?.stats);if(e){_?.(e);return}}W&&(N(e=>e+1),G()),ne()}else W&&(g?g():b.error({title:v(`The usage limit has been exceeded`),description:v(`The maximum number of requests for the current subscription period has been reached.
|
|
4
|
+
Select the appropriate plan to fulfil more requests`),placement:`bottomRight`}))},[K,W,O,_,N,G,ne,b,v,g]);(0,u.useEffect)(()=>{W&&N(y?.counters?.ai_img_counter||0)},[y,W]);let ie=(0,u.useCallback)(e=>{if(!r){s(!0);let n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;let r=n[1],i=n[2],a=atob(i),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let c=new Uint8Array(o),l=new Blob([c],{type:`image/${r}`});t({file:new File([l],`image.jpeg`,{type:l.type})})}},[r,s,t]),ae=(0,u.useCallback)(e=>{e.status!==`error`&&e.status!==`Canceled`?e.images?(z(e.status),e.progress===100&&(p(e.images),z(v(`Evaluating the task`)),F(null),V(!1))):(p([e.data]),h(!1)):(h(!1),V(!1),b.error({id:`AI_IMAGE_GET_ERROR`,title:v(`Something went wrong, please try again`),placement:`bottomRight`,data:P}))},[p,z,v,h,e,P,b,V]);return(0,u.useEffect)(()=>{D.length>1&&ae(D[D.length-1])},[D,ae]),(0,u.useEffect)(()=>{(m||d.length>0)&&setTimeout(()=>{let t=550;n.current&&(t=n.current.offsetHeight+68),e(t)},0)},[n,D,d.length,m,e]),{aiImageCounter:M,setAiImageCounter:N,currentAiImgLimits:H,isFieldsDisabled:U,canGenerateImage:K,aiImageRequest:l,imageAiList:d,setImageAiList:p,isLoadingAi:m,setIsLoadingAi:h,loadingDuringGeneration:B,setLoadingDuringGeneration:V,requestStatus:R,setRequestStatus:z,handleGenerate:re,handleLimitAiImgCount:G,convertBase64ToFile:ie,isShiftPressed:I,setIsShiftPressed:L,currentReqId:P,setCurrentReqId:F,limitsInPlugin:W}}var te=({setModalHeight:e,customRequest:t,aiTabRef:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,setAiImageRequest:h,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y})=>{let b=(0,f.useNavigate)(),x=i.ki(),{__:S,_n:C}=o.h(),w=i.cn(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),{aiImageCounter:k,currentAiImgLimits:A,loadingDuringGeneration:j,requestStatus:M,handleGenerate:N,convertBase64ToFile:P,isShiftPressed:F,setIsShiftPressed:I,limitsInPlugin:L}=ee({setModalHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:s,setIsImageUploaded:d,aiImageRequest:m,imageAiList:g,setImageAiList:_,isLoadingAi:v,setIsLoadingAi:y,onPluginAiImageLimitExceeded:()=>E(!0),onImageGenerateLimitExceeded:O}),R=T&&A>0?l.p(A):null,z=R?c.u(R.presetId):null,B=D?c.u(D.presetId):null,[te,H]=(0,u.useState)(!1),U=(0,u.useCallback)(()=>H(!0),[]),W=(0,u.useCallback)(()=>H(!1),[]),G=(0,u.useCallback)(e=>h(e.target.value),[h]),K=(0,u.useCallback)(e=>{e.key===`Shift`?I(!0):e.key===`Enter`&&!F&&(e.preventDefault(),N())},[F,N,I]),ne=(0,u.useCallback)(e=>{e.key===`Shift`&&I(!1)},[I]),re=g[g.length-1];return(0,p.jsxs)(`div`,{className:`image-ai`,children:[z&&R?(0,p.jsx)(c.f,{open:!0,onClose:()=>E(!1),title:S(z.titleKey),subtitle:S(z.subtitleKey),usageResource:z.usageResource,previousDisplay:c.d(R.previousLimit),nextDisplay:c.d(R.nextLimit),onChangePlan:()=>{E(!1),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.xa.SWITCH_TO_PLAN_MODAL))}}):null,B&&D?(0,p.jsx)(c.f,{open:!0,onClose:()=>O(null),title:S(B.titleKey),subtitle:S(B.subtitleKey),usageResource:B.usageResource,previousDisplay:c.d(D.previousLimit),nextDisplay:c.d(D.nextLimit),onChangePlan:()=>{O(null),document.body.classList.remove(`editor`),b(`/billing`),x(a.r(i.xa.SWITCH_TO_PLAN_MODAL))}}):null,L&&(0,p.jsx)(o.P,{text:`${k} ${S(`of`)} ${A>0?A:`∞`} images ${C(`was used`,`were used`,k)}`,exceeded:A>0&&k>=A,style:{marginTop:-25},extra:(0,p.jsx)(`span`,{style:{textDecoration:`underline`,cursor:`pointer`},onClick:()=>b(w.billingPageUrl||i.Ui.billing),children:S(`Need more?`)})}),(0,p.jsx)(o.Ot,{gutter:24,className:`image-ai__row`,children:(0,p.jsx)(o.Dt,{span:24,children:(0,p.jsx)(o.Ft.Item,{style:{margin:0},children:(0,p.jsxs)(`span`,{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${te?` ant-input-affix-wrapper-focused`:``}`,children:[(0,p.jsx)(o.xt,{ref:r,onKeyDown:K,onKeyUp:ne,onFocus:U,onBlur:W,autoSize:!0,allowClear:!0,className:`text-area-input-hybrid image-ai__textarea`,placeholder:S(`Generate image`),value:m,onChange:G,spellCheck:`false`}),(0,p.jsx)(`span`,{className:`ant-input-suffix image-ai__input-suffix`,children:v||j?(0,p.jsx)(c.m,{icon:`LoadingOutlined`,className:`input-icon image-ai__input-icon`,spin:!0}):(0,p.jsx)(c.m,{icon:`AI`,className:`input-icon image-ai__input-icon`,onClick:N})})]})})})}),(v||g.length>0)&&(0,p.jsxs)(`div`,{className:`image-ai__preview`,children:[v&&g.length===0&&(0,p.jsx)(`div`,{className:`image-ai__loading`,children:(0,p.jsxs)(`div`,{className:`spin`,children:[(0,p.jsx)(c.m,{icon:`LoadingOutlined`,style:{fontSize:48},spin:!0}),(0,p.jsx)(`p`,{className:`status`,children:M})]})}),g.length>0&&(0,p.jsxs)(`div`,{className:`image-ai__image-item`,children:[(0,p.jsx)(V,{images:g}),(0,p.jsx)(`div`,{className:`buttons`,children:(0,p.jsx)(o.Rt,{onClick:()=>P(`data:image/jpeg;base64, ${re}`),icon:(0,p.jsx)(c.m,{icon:`CheckOutlined`}),children:S(`Use this one`)})})]})]})]})},H=({setNewLink:e,setCurrentImageLink:t,setModalHeight:n,setModalWidth:r,setImageGifList:s,imageGifList:l,currentReqGif:d,setCurrentReqGif:f,inputRef:m,setStockLink:h,customRequest:g})=>{let{__:_}=o.h(),v=i.cn(),y=c.t(),b=o.o(),[x,S]=(0,u.useState)(null),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)(25),[O]=a.b(),k=(0,u.useCallback)(e=>e instanceof Error||typeof e?.message==`string`&&e.message?e.message:typeof e?.error?.message==`string`&&e.error.message?e.error.message:_(`Failed to load GIFs through the configured proxy chain.`),[_]),A=(0,u.useCallback)(e=>{b.error({id:`STOCK_GIFS_SEARCH_FAILED`,title:_(`Failed to load GIFs`),description:k(e)})},[_,k,b]),j=async()=>{C||(w(!0),O({query:d,page:T}).then(e=>{if(e?.error){A(e.error),w(!1);return}s(t=>[...t,...e.data.data]),w(!1),E(e=>e+25)}).catch(()=>{w(!1)}))},M=async()=>{let e=await O({query:d,page:0});if(e?.error){A(e.error),s([]);return}e?.data?.data?.length>0&&(s(e.data.data),setTimeout(()=>{n(`84vh`),r(1060)},0))},N=(e,n)=>{S(n),setTimeout(()=>{S(null)},2e3),h(`${e}`),t(`${e}`),g(`${e}`)},P={default:3},F=(0,u.useCallback)(e=>i.ro(e,{config:v,standalone:y,resourceType:`generic`,intent:`display`}),[v,y]),{getDisplaySrc:L,handleLoad:z,handleError:B}=R({items:l,getItemId:(0,u.useCallback)(e=>e.id,[]),getRequestUrl:(0,u.useCallback)(e=>e.images.downsized.url,[]),createController:F}),V=e=>t=>{z(e),t.target.parentNode.classList.add(`loaded`)},ee=e=>()=>{B(e)};return(0,p.jsxs)(`div`,{className:`stock-tab`,children:[(0,p.jsxs)(o.Ft,{onValuesChange:M,className:l.length>0?`serach-results`:``,children:[(0,p.jsx)(o.Ot,{gutter:24,children:(0,p.jsx)(o.Dt,{span:l.length>0?``:24,children:(0,p.jsx)(o.Ft.Item,{className:`stock-search-input`,children:(0,p.jsx)(o.St,{onSearch:M,allowClear:!0,size:l.length>0?`medium`:`large`,placeholder:_(`Search GIFs`),value:d.keywords,onChange:e=>f(t=>({...t,keywords:e.target.value})),ref:m,spellCheck:`false`,enterButton:!1})})})}),l.length>0&&(0,p.jsx)(`div`,{className:`blocks-search__divider-wrapper`,children:(0,p.jsx)(`div`,{className:`ant-divider ant-divider-horizontal`,role:`separator`})})]}),(0,p.jsx)(`div`,{className:`serach-output-wrapper`,style:{marginRight:-10},children:l.length>0&&(0,p.jsx)(`div`,{id:`scrollableDiv`,style:{width:`100%`,height:`calc(84vh - 148px)`,overflow:`auto`,paddingTop:24,paddingRight:14,paddingLeft:24,marginLeft:-24,lineHeight:`0`,boxSizing:`unset`},children:(0,p.jsx)(D,{dataLength:l&&l.length,next:j,hasMore:l,endMessage:(0,p.jsxs)(o.jt,{plain:!0,children:[_("That`s all we could find."),` 🤐`]}),scrollableTarget:`scrollableDiv`,style:{overflow:`visible`},loader:(0,p.jsx)(o.K,{size:`small`}),children:(0,p.jsx)(I,{breakpointCols:P,className:`my-masonry-grid`,columnClassName:`my-masonry-grid_column`,children:l.map((e,t)=>(0,p.jsxs)(`div`,{className:`list-item`,onClick:()=>N(e.images.downsized.url,e.id),children:[(0,p.jsx)(`img`,{className:x===e.id?`loaded-image`:``,width:`322px`,src:L(e),alt:e.title,onLoad:V(e),onError:ee(e)}),(0,p.jsx)(`a`,{rel:`noreferrer`,href:`https://giphy.com/`,target:`_blank`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`overlay-image`,style:{backgroundImage:`url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAkCAYAAAB/up84AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABSBJREFUeNrsWjFv2zoQVoMW8BZ18xaN3qLRW9QtW9OtW92to98vaPoP3K1b1S1b3c2jvWlUNm3lw1s8Mpu3PAo4Iocr70jKlp0COuCQlpKPx/t43x1pv3h8fEwGeT5yNoTgeclLZvza6NgxXoNaGRktjE6MpjC2NVqh92bwt4HxBI1ro0s0dgN2tvD5a8a/9vkq0M+xYKdG81A7Gp6pyBjZddrnO6N36Hkbqyn8u4L3vYC0hjLHeAbPVhC4TwAK/ewNvLsEhyxgFXLK2l/D4tvnOVrUiPEh1k/JjvLYyWENdeTcKazBBr6AdY4AqBTmbkIzhO4gvMumYLxAYKzgPTvhBBajYNwCksHYhOyYiow1KONaKYlfO8bPEWyGEfi5Iu+Vjizg7EzB3xvwWTMxWkHG4mDnMF6BnSnYncLzHWGG4BqiwZkKQMC7I0cOVTCJhvRUKNgNCmCOxhNmrBEWzwGi0Y6rIihbsnOH/JgE2hshKrLZv4Px9yhj1twafRlid/UIGWvlFdlVLirIkIM12nETGLeO2tTPECBUZuT/a7JBMpSxUybYLjulUCN2iEpHQoyuGWZJUCa8R/VGSZvGB0iOdjAO9n8EtC2zUxICSIoW0ICTmA53DCDKQzWZg89XAXZ2B2iMavBnjDKpBX6B1tnAM5aqQgGhnU2D6GmHuqw7AkaOPmP/bsHpFC1kTLqVhglS6fFNgX1MCXUHO1zR1h5AFOoSc1jjmKx/An/1PoBQasBSoZZ3hpyaOrg0IW2sRkG8JsU8CaCaLckAhfi6AG0cmeuzkyMQMtL+SiySkY3oA/EgGeICK0UOZYQKVsQpDAjm2BpsaAGQLMKnMdok3yLtpKS70yT7OUBcm7UTHb5grk5y1Csrj40MqUbUpgW7NXo+RunckODkQvdXM37iwm7b1VA7lAaVB4jUUZOUIzNxfOougAwy3GUN0qWG2IJJ09V2NcvIFE8c54nQelEHFM6C6chUhI+WZjjffDQkrenPhqmlrAC9Naof/aLhXZeNNfMZOk+MtPOVRjNmTpfcCut0+biGZ3PBj1ywWTOfqV3v+yjLFuDPRs8Ddu05vLtmsuHQ0s73wehvR0t7aGkPevfCM5fcGr0MbOW9NSSFwF52cP5KcLIv+X4EUGbCemcOqpoz73/haE4CZNkRjAR20vwENXHRc2bWEMyQuUuGVe4hc6K6rBmg7pKN0XdGX7dts9E3Rr8afUATFl1PqgLAG6T3AoX1nSVtMP9l5r5FVyiu+D14/YssRHOheGVQYNMeinrhsMcV2WVPRR1rIRT4QmiA5r4G6oxp0y6ZzFh4LvhmB84MHz1xta9vWQMrcFR/3iF+7DmEu2YoyTshRbuMvGE9hnwGPQR1tdR04aCueKrqAIgiu/AqcCf1JXPhfuoYosGHn4Hgqa6AnCK4IfSkCa1eCJRxLGnn+mX0rfDOJok4AsQAUpwQlND2++HIgNiOVO1LVRIgtXDPs0bpunEU08vktHLMpoJS1/d9qEo6h6gAzq7RRaPV+QmBeICzUUh2fIHzk0s3HedXwkEy2ReQmjn4XDzDjqkN4D/J04/y/np5KbSrrtbwAyx+kTxdf9tfpvSZIW9O3FScHJAF8PEFc5F2lQzSi5wJheoG3U/t0xYOcgBAcOHuAkr7mY9ditoAiCz2q8uvEcD8gJpSDuGNl5hfnaTJ0/fpheMUr4CitHCO6fqdesj359xh1tWiqggfdUCmcz9ZivZ7+BnQM5P/BRgABx8sJWqTxoYAAAAASUVORK5CYII=)`}})}),x===e.id&&(0,p.jsx)(o.K,{className:`ant-spin`,size:`small`})]},e.id+t))})})})})]})};function U(e){if(!(e==null||e===``))return e}async function W(e,t){if(e){if(e.url)return e.url;if(typeof t.getFileById==`function`&&e.id){let n=await t.getFileById(e.id);if(n?.url)return n.url;if(n?.thumbnailUrl)return n.thumbnailUrl;if(n?.thumbnail)return n.thumbnail}if(typeof t.getFileUrl==`function`&&e.folderId!==void 0&&e.name){let n=await t.getFileUrl(e.folderId||``,e.name);if(n)return n}if(typeof t.getUrl==`function`&&e.name){let n=await t.getUrl(e);if(n)return n}return e.thumbnail||e.thumbnailUrl}}function G(e){if(!(!e?.success||!Array.isArray(e.detailed)))return e.detailed.find(e=>e?.success&&e.data)?.data}function K(e,t,n){if(e)return{id:e.id,name:e.name||t.name,size:e.size??t.size,type:e.type||t.type,folderId:e.folderId??n??``,url:e.url,thumbnail:e.thumbnail,thumbnailUrl:e.thumbnailUrl,date:e.date,dimensions:e.dimensions,aspectRatio:e.aspectRatio,extension:e.extension,selected:e.selected,isFolder:e.isFolder,lastEdited:e.lastEdited,childrenCount:e.childrenCount}}async function ne(e,t,n){if(!t)return;let r=U(n??t.rootId),i;typeof t.uploadFiles==`function`?i=G(await t.uploadFiles({folderId:r,items:[{name:e.name,size:e.size,type:e.type,folderId:r,data:e}]})):typeof t.uploadFile==`function`&&(i=K(await t.uploadFile({name:e.name,size:e.size,type:e.type,folderId:r,data:e}),e,r));let a=await W(i,t);return a?{item:i,url:a}:void 0}var re=`IMG`,ie=`BACKGROUND`,ae=`GALLERY`,oe=`EDITOR`,q=`UPLOAD`,se=`STOCK`,ce=`GIF`,le=`AI`,{Dragger:ue}=o.gt,de=(e,t=`image`)=>{try{let n=new URL(e).pathname.split(`/`).pop();return n&&decodeURIComponent(n)||t}catch{return t}},fe=l.f,pe=(e,t)=>{let n=fe(t);return!n||e.includes(`.`)?e:`${e}.${n}`},me=(e,t)=>new File([e],pe(de(t),e.type),{type:e.type||`application/octet-stream`}),he=({dataProvider:e})=>{let t=i.cn(),n=c.t(),{__:r}=o.h(),s=i.ki(),{projectId:d}=(0,f.useParams)(),[m]=a.y(),{modal:h}=o.Wt.useApp(),g=o.o(),_=i.Oi(i.r),v=i.Oi(i.n),b=i.Oi(a.s),{request:x,resolveImagePicker:S}=c.r(),[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,M]=(0,u.useState)(q),[N,P]=(0,u.useState)({width:``,height:``,size:``,format:``}),[F,I]=(0,u.useState)(`success`),[L,R]=(0,u.useState)(!1),z=u.default.useRef(null),V=u.default.useRef(null),ee=u.default.useRef(null),U=u.default.useRef(null),W=u.default.useRef(null),G=u.default.useRef(null),K=u.default.useRef(null),de=u.default.useRef(null),pe=u.default.useRef(null),[he,J]=(0,u.useState)(`auto`),[ge,Y]=(0,u.useState)(572),[_e,ve]=(0,u.useState)(!1),[ye,be]=(0,u.useState)({keywords:``,color:``,orientation:``}),[xe,Se]=(0,u.useState)({keywords:``}),[Ce,we]=(0,u.useState)([]),[Te,Ee]=(0,u.useState)([]),[De,Oe]=(0,u.useState)([]),[ke,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(!1),[Fe,Ie]=(0,u.useState)(0),Le=i.Oi(i.ct),Re=Le?.id===void 0?d||``:String(Le.id),ze=i.q(i.wo.UPLOAD_EVENT_ID),Be=u.default.useRef(l.u()),Ve=u.default.useRef(``),He=u.default.useRef(0),X=u.default.useRef(``),[Ue,We]=(0,u.useState)(``),[Ge,Ke]=(0,u.useState)(``),Z=(0,u.useCallback)(()=>{X.current&&=(URL.revokeObjectURL(X.current),``),We(``)},[]),Q=(0,u.useCallback)(()=>{Ke(``)},[]),$=!(_||v.id?.toString()!==Le?.members?.owner.ID),qe=e=>{E(e.target.value)},Je=(0,u.useCallback)((e,t,n=r(`The image could not be uploaded.`))=>{let i=t instanceof Error?t.message:n;g.error({id:`IMAGE_UPLOAD_ERROR`,data:e,title:r(`Upload failed`),description:i})},[r,g]),Ye=(0,u.useCallback)(async e=>c.o(await ze.fire({file:e,project:Re})),[Re,ze]),Xe=l.t(),Ze=async e=>{if(e)try{let t=await $e(e);t&&it(t)?await at({file:t}):t||Je({url:e},null,r(`Failed to download image from URL.`))}catch(t){Je({url:e},t,r(`Failed to process image URL.`))}},Qe=u.default.useRef(Ze);Qe.current=Ze,u.default.useEffect(()=>{if(j!==q||!k)return;let e=T.trim();if(!e||!e.toLowerCase().startsWith(`http`))return;let t=setTimeout(()=>{Qe.current(e)},1e3);return()=>{clearTimeout(t)}},[T,j,k]);let $e=async e=>{try{let t=l.l(e);return me(await Be.current.resolve(t,void 0,Xe),t)}catch{}};document.onpaste=function(e){let n=e.clipboardData?.items?.[0];if(j===q&&k){if(n?.type?.indexOf(`image`)===0&&t.imageCenterLocalUploadEnabled!==!1){let e=n.getAsFile();it(e);let t={file:e};E(``),at(t);return}let r=e.clipboardData?.getData(`text/plain`);if(r&&r.trim().toLowerCase().startsWith(`http`)){e.preventDefault(),e.stopPropagation(),E(r.trim());return}n?.type?.indexOf(`text`)===0&&n.getAsString(e=>{if(e.trim().toLowerCase().startsWith(`http`))E(e.trim());else if(e.toString().slice(1,5)===`meta`){let t=e.toString().split(`"`)[1];t&&E(t)}})}},(0,u.useEffect)(()=>{let e=e=>{let t=null;x?.kind===`background`?(t=ie,A(ie)):x?.kind===`img`&&(A(re),t=re),x?.currentUrl&&t&&(w(x.currentUrl),M(e))};b===i.xa.UPLOAD_IMAGE_MODAL||b===i.xa.UPLOAD_BACKGROUND_MODAL?e(oe):b===i.xa.UPLOAD_IMAGE_MODAL_AI||b===i.xa.UPLOAD_BACKGROUND_MODAL_AI?($?(Pe(!0),Ie(2)):e(le),setTimeout(()=>pe.current?.focus({cursor:`start`}),100)):b===i.xa.UPLOAD_IMAGE_MODAL_UPLOAD||b===i.xa.UPLOAD_BACKGROUND_MODAL_UPLOAD?(e(q),setTimeout(()=>G.current?.focus({cursor:`start`}),100)):b===i.xa.UPLOAD_IMAGE_MODAL_STOCK||b===i.xa.UPLOAD_BACKGROUND_MODAL_STOCK?($?(Pe(!0),Ie(3)):e(se),setTimeout(()=>de.current?.focus({cursor:`start`}),100)):b===i.xa.UPLOAD_IMAGE_MODAL_GIF||b===i.xa.UPLOAD_BACKGROUND_MODAL_GIF?($?(Pe(!0),Ie(3)):e(ce),setTimeout(()=>K.current?.focus({cursor:`start`}),100)):b===i.xa.UPLOAD_IMAGE_MODAL_EDIT||b===i.xa.UPLOAD_BACKGROUND_MODAL_EDIT?($?(Pe(!0),Ie(5)):e(oe),s(a.i(i.xa.IMAGE_EDITOR_MODAL))):A(``)},[b,s,$,x]);let et=(0,u.useCallback)(({url:e=C||``})=>{w(e),S({url:e,meta:{mode:`select`}}),setTimeout(()=>{Q(),Z(),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),Ee([]),we([]),A(``),Me(``),Ae(!1),O(``),E(``),M(q)},200),s(a.t()),s(a.n())},[C,Q,s,S,Z]),tt=(0,u.useCallback)((e,t)=>(J(`auto`),R(!1),et({url:e}),g.success({id:`IMAGE_UPLOAD_SUCCESS`,data:t,title:r(`The image was successfully uploaded.`)}),e),[r,et,g]);(0,u.useEffect)(()=>{let t=T||D,r=l.l(t);if(!t||!r){I(``),Ve.current=``,Q(),Z(),Be.current.invalidateAll();return}let i=Ve.current;i&&i!==r&&(Be.current.abandonKey(i),Q(),Z()),Ve.current=r;let a=new AbortController,o=T?800:0,s=++He.current,c=setTimeout(async()=>{try{let i=async()=>{let e=await Be.current.resolve(r,a.signal,Xe);if(s!==He.current)return;let{width:t,height:n}=await l.d(e);if(s!==He.current)return;P({width:t,height:n,size:(e.size/1024).toFixed(2),format:fe(e.type)}),Q(),X.current&&URL.revokeObjectURL(X.current);let i=URL.createObjectURL(e);X.current=i,We(i)};if(n)await i();else{let t=await l.n(e,r);if(t?.previewUrl&&s===He.current){Ke(t.previewUrl),Z();try{let{data:e}=await m(r);if(s!==He.current)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await i()}catch{await i()}}else await i()}if(s!==He.current)return;I(`success`),w(t),Y(572),setTimeout(()=>{let e=0;V.current&&(e=V.current.offsetHeight+62),J(e)},0)}catch(e){if(e?.name===`AbortError`||a.signal.aborted||s!==He.current)return;Q(),Z(),I(`error`)}},o);return()=>{clearTimeout(c),a.abort()}},[T,D,n,Q,Xe,m,Z,e]),(0,u.useEffect)(()=>{if(!C||T||D)return;let t=l.l(C),r=new AbortController,i=!1,a=async()=>{let e=await Be.current.resolve(t,r.signal,Xe);if(i)return;let{width:n,height:a}=await l.d(e);if(i)return;Q(),X.current&&URL.revokeObjectURL(X.current);let o=URL.createObjectURL(e);X.current=o,We(o),P({width:n,height:a,size:(e.size/1024).toFixed(2),format:fe(e.type)})};return(async()=>{try{if(!n){let n=await l.n(e,t);if(n?.previewUrl&&!i){Ke(n.previewUrl),Z();try{let{data:e}=await m(t);if(i)return;e?P({width:e?.width,height:e?.height,size:e?.fileSize==null?``:(e.fileSize/1024).toFixed(2),format:fe(e?.format)}):await a();return}catch{await a()}}}await a()}catch{i||Q()}})(),()=>{i=!0,r.abort()}},[n,Q,C,Xe,m,e,T,D]);let nt=()=>{s(a.t()),setTimeout(()=>{Q(),Z(),w(``),E(``),Ee([]),Ee([]),be({keywords:``,color:``,orientation:``}),Se({keywords:``}),J(`auto`),!ke&&Me(``),Y(572),M(q)},200)},rt=e=>{e===ae?h.success({mask:{closable:!0},centered:!0,title:r(`Coming soon`),content:r(`The feature is under development.`),okText:r(`Ok. I'll be waiting`),onOk:()=>{}}):e===oe&&C===``?h.warning({mask:{closable:!0},centered:!0,title:r(``),content:r(`To preview and edit the uploaded image`),okText:r(`Upload Image`),onOk:()=>{M(q)}}):(setTimeout(()=>{let t=0,n=0;e===q&&z.current?(ye.keywords===``&&G.current?.focus({cursor:`start`}),t=300,n=572):e===oe&&V.current?(t=V.current.offsetHeight+62,n=572):e===se&&ee.current?(ye.keywords===``&&de.current?.focus({cursor:`start`}),t=130,n=572,Te.length>0&&(n=1060,t=`84vh`)):e===ce&&U.current?(ye.keywords===``&&K.current?.focus({cursor:`start`}),t=130,n=572,Ce.length>0&&(n=1060,t=`84vh`)):e===le&&W.current&&(je===``&&De.length===0?(pe.current?.focus({cursor:`start`}),t=130):t=W.current.offsetHeight+82,n=572),J(t),Y(n)},0),M(e))};(0,u.useEffect)(()=>{ye.keywords===``&&(G?.current?.focus({cursor:`start`}),Ee([]),setTimeout(()=>{J(`auto`),Y(572)},0))},[ye,Ee,J,Y]);let it=e=>{let t=e.type===`image/jpeg`||e.type===`image/png`||e.type===`image/jpg`||e.type===`image/webp`||e.type===`image/gif`||e.type===`image/svg+xml`;return t||g.error({id:`IMAGE_UPLOAD_WRONG_FORMAT`,data:e,title:`Upload`,description:`You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!`}),t},at=async({file:n})=>{try{ve(!0);let r=await l.i(n,t),i=await Ye(r);if(i)return tt(i,r),i;let a=await ne(r,e);if(a?.url)return tt(a.url,r),a.url;Je(r,null);return}catch(e){Je(n,e);return}finally{ve(!1)}},ot=e=>at({file:e}),st=[{label:r(`Upload`),key:q,children:(0,p.jsxs)(`div`,{ref:z,style:{paddingBottom:24},children:[t.imageCenterLocalUploadEnabled!==!1&&(0,p.jsxs)(ue,{showUploadList:!1,name:`Image`,beforeUpload:it,customRequest:at,style:{marginBottom:10},multiple:!1,accept:`image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml`,children:[(0,p.jsx)(`p`,{className:`ant-upload-drag-icon`,children:(0,p.jsx)(c.m,{icon:`InboxOutlined`})}),(0,p.jsx)(`p`,{className:`ant-upload-text`,children:r(`Click to select, paste from the clipboard, or drag and drop`)}),(0,p.jsx)(`p`,{className:`ant-upload-hint`,children:r(`Accepted formats: PNG, JPG, WEBP, SVG or GIF.`)})]}),(0,p.jsx)(o.Ft,{style:{padding:`0 2px 0 2px`},children:(0,p.jsx)(o.Ft.Item,{validateStatus:F,children:(0,p.jsx)(o.kt,{ref:G,allowClear:!0,size:`large`,placeholder:r(`Paste image URL here`),value:T,onChange:qe,spellCheck:`false`})})})]})}];return t.imageCenterStockEnabled&&!$&&st.push({label:r(`Stock`),key:se,children:(0,p.jsx)(`div`,{ref:ee,style:{paddingBottom:24},children:(0,p.jsx)(B,{currentReq:ye,setCurrentReq:be,imageStockList:Te,setImageStockList:Ee,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:de,customRequest:Ze})})}),t.imageCenterGifEnabled&&!$&&st.push({label:r(`GIF`),key:ce,children:(0,p.jsx)(`div`,{ref:U,style:{paddingBottom:24},children:(0,p.jsx)(H,{currentReqGif:xe,setCurrentReqGif:Se,imageGifList:Ce,setImageGifList:we,setModalWidth:Y,setModalHeight:J,setStockLink:O,setCurrentImageLink:w,inputRef:K,customRequest:Ze})})}),t.elementAIimageEnabled&&!$&&st.push({label:r(`AI`),key:le,children:(0,p.jsx)(`div`,{ref:W,style:{paddingBottom:24},children:(0,p.jsx)(te,{setModalHeight:J,customRequest:at,aiImageRequest:je,setAiImageRequest:Me,imageAiList:De,setImageAiList:Oe,isLoadingAi:ke,setIsLoadingAi:Ae,aiTabRef:W,inputAiRef:pe,isImageUploaded:L,setIsImageUploaded:R})})}),t.imageCenterEditorEnabled&&st.push({label:``,key:oe,children:(0,p.jsx)(`div`,{ref:V,children:(0,p.jsx)(y,{currentImageLink:C,newLink:T,previewDisplayUrl:Ge,resolvedPreviewObjectUrl:Ue,imageSize:N,onSave:ot,uploadImageResultIsLoading:_e||!1})})}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.Y,{width:ge,className:`image-center`,title:r(`Image Center`),style:{minHeight:390},open:!!k,onOk:et,onCancel:nt,footer:j===oe?(0,p.jsx)(p.Fragment,{}):null,children:(0,p.jsx)(o.K,{spinning:_e,children:(0,p.jsx)(o.Z,{activeKey:j,onChange:rt,items:st,className:`modal-tabs`,style:{height:he,minHeight:130}})})}),(0,p.jsx)(c.g,{open:Ne,onCancel:()=>Pe(!1),initialSlide:Fe})]})};he.propTypes={dataProvider:d.default.object},t.default=he});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
__emailmaker__.define(`static/core/
|
|
1
|
+
__emailmaker__.define(`static/core/5a6dd152.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/63a369c8.js`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./63a369c8.js");function a(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function o(e){return t=>{let n={},r=[];for(let n of e)r.push(n(t));for(let e of r)Object.assign(n,e.instance);return{instance:n,setOptions:async e=>{for(let t of r)await t.setOptions(e)},dispose:()=>{for(let e of r)e.dispose()}}}}function s(){let e=new Date;return e.valueOf()-e.getTimezoneOffset()*60*1e3}function c(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(4-e.length%4)%4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}function l(e){let[t,n,r]=e.split(`.`),i=JSON.parse(c(n));return{exp:i.exp,createdAt:i.iat,data:i}}var u=i.Ko();function d(e,t,n,r){e.inject(u,void 0),e.injectFactory(u,async(a,o)=>{try{let a=o?await o:void 0;if(!a){let t=e.getInstance(i.xo);t&&(a=await t)}return t?!a||(l(a)?.exp??0)*1e3<=s()?await t(n,r,a):a:``}catch{return``}},!0)}var f=a(e=>{let t,n,r;return e.addService(i.Xa,{execute:async n=>{if(t){let t=await e.getInstanceAsync(u);t&&n.headers.append(`authorization`,`Bearer ${t}`)}}}),{setOptions(a){let o=!i.Ja(n,a.user),s=r!==a.project;(t!==a.getAuthToken||o||s)&&(t=a.getAuthToken,n=a.user,r=a.project,d(e,t,a.user,a.project))}}}),p=r.a(((e,t)=>{(function(n){"use strict";var r=n.setTimeout,i=n.clearTimeout,a=n.XMLHttpRequest,o=n.XDomainRequest,s=n.ActiveXObject,c=n.EventSource,l=n.document,u=n.Promise,d=n.fetch,f=n.Response,p=n.TextDecoder,m=n.TextEncoder,h=n.AbortController;if(typeof window<`u`&&l!==void 0&&!(`readyState`in l)&&l.body==null&&(l.readyState=`loading`,window.addEventListener(`load`,function(e){l.readyState=`complete`},!1)),a==null&&s!=null&&(a=function(){return new s(`Microsoft.XMLHTTP`)}),Object.create??(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return new Date().getTime()}),h==null){var g=d;d=function(e,t){var n=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then(function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}})},h=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){this.signal._reader!=null&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function _(){this.bitsNeeded=0,this.codePoint=0}_.prototype.decode=function(e){function t(e,t,n){if(n===1)return e>=128>>t&&e<<t<=2047;if(n===2)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(n===3)return e>=65536>>t&&e<<t<=1114111;throw Error()}function n(e,t){if(e===6)return t>>6>15?3:t>31?2:1;if(e===12)return t>15?3:2;if(e===18)return 3;throw Error()}for(var r=65533,i=``,a=this.bitsNeeded,o=this.codePoint,s=0;s<e.length;s+=1){var c=e[s];a!==0&&(c<128||c>191||!t(o<<6|c&63,a-6,n(a,o)))&&(a=0,o=r,i+=String.fromCharCode(o)),a===0?(c>=0&&c<=127?(a=0,o=c):c>=192&&c<=223?(a=6,o=c&31):c>=224&&c<=239?(a=12,o=c&15):c>=240&&c<=247?(a=18,o=c&7):(a=0,o=r),a!==0&&!t(o,a,n(a,o))&&(a=0,o=r)):(a-=6,o=o<<6|c&63),a===0&&(o<=65535?i+=String.fromCharCode(o):(i+=String.fromCharCode(55296+(o-65535-1>>10)),i+=String.fromCharCode(56320+(o-65535-1&1023))))}return this.bitsNeeded=a,this.codePoint=o,i},(p==null||m==null||!function(){try{return new p().decode(new m().encode(`test`),{stream:!0})===`test`}catch{}return!1}())&&(p=_);var v=function(){};function y(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText=``,this.responseText=``,this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType=``,this._xhr=e,this._sendTimeout=0,this._abort=v}y.prototype.open=function(e,t){this._abort(!0);var n=this,o=this._xhr,s=1,c=0;this._abort=function(e){n._sendTimeout!==0&&(i(n._sendTimeout),n._sendTimeout=0),(s===1||s===2||s===3)&&(s=4,o.onload=v,o.onerror=v,o.onabort=v,o.onprogress=v,o.onreadystatechange=v,o.abort(),c!==0&&(i(c),c=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),s=0};var l=function(){if(s===1){var e=0,t=``,r=void 0;if(`contentType`in o)e=200,t=`OK`,r=o.contentType;else try{e=o.status,t=o.statusText,r=o.getResponseHeader(`Content-Type`)}catch{e=0,t=``,r=void 0}e!==0&&(s=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=r,n.onreadystatechange())}},u=function(){if(l(),s===2||s===3){s=3;var e=``;try{e=o.responseText}catch{}n.readyState=3,n.responseText=e,n.onprogress()}},d=function(e,t){if((t==null||t.preventDefault==null)&&(t={preventDefault:v}),u(),s===1||s===2||s===3){if(s=4,c!==0&&(i(c),c=0),n.readyState=4,e===`load`)n.onload(t);else if(e===`error`)n.onerror(t);else if(e===`abort`)n.onabort(t);else throw TypeError();n.onreadystatechange()}},f=function(e){o!=null&&(o.readyState===4?(!(`onload`in o)||!(`onerror`in o)||!(`onabort`in o))&&d(o.responseText===``?`error`:`load`,e):o.readyState===3?`onprogress`in o||u():o.readyState===2&&l())},p=function(){c=r(function(){p()},500),o.readyState===3&&u()};`onload`in o&&(o.onload=function(e){d(`load`,e)}),`onerror`in o&&(o.onerror=function(e){d(`error`,e)}),`onabort`in o&&(o.onabort=function(e){d(`abort`,e)}),`onprogress`in o&&(o.onprogress=u),`onreadystatechange`in o&&(o.onreadystatechange=function(e){f(e)}),(`contentType`in o||!(`ontimeout`in a.prototype))&&(t+=(t.indexOf(`?`)===-1?`?`:`&`)+`padding=true`),o.open(e,t,!0),`readyState`in o&&(c=r(function(){p()},0))},y.prototype.abort=function(){this._abort(!1)},y.prototype.getResponseHeader=function(e){return this._contentType},y.prototype.setRequestHeader=function(e,t){var n=this._xhr;`setRequestHeader`in n&&n.setRequestHeader(e,t)},y.prototype.getAllResponseHeaders=function(){return this._xhr.getAllResponseHeaders==null?``:this._xhr.getAllResponseHeaders()||``},y.prototype.send=function(){if((!(`ontimeout`in a.prototype)||!(`sendAsBinary`in a.prototype)&&!(`mozAnon`in a.prototype))&&l!=null&&l.readyState!=null&&l.readyState!==`complete`){var e=this;e._sendTimeout=r(function(){e._sendTimeout=0,e.send()},4);return}var t=this._xhr;`withCredentials`in t&&(t.withCredentials=this.withCredentials);try{t.send(void 0)}catch(e){throw e}};function b(e){return e.replace(/[A-Z]/g,function(e){return String.fromCharCode(e.charCodeAt(0)+32)})}function x(e){for(var t=Object.create(null),n=e.split(`\r
|
|
2
2
|
`),r=0;r<n.length;r+=1){var i=n[r].split(`: `),a=i.shift(),o=i.join(`: `);t[b(a)]=o}this._map=t}x.prototype.get=function(e){return this._map[b(e)]},a!=null&&a.HEADERS_RECEIVED==null&&(a.HEADERS_RECEIVED=2);function S(){}S.prototype.open=function(e,t,n,r,i,o,s){e.open(`GET`,i);var c=0;for(var l in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,n(t)},e.onerror=function(e){e.preventDefault(),r(Error(`NetworkError`))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===a.HEADERS_RECEIVED){var n=e.status,r=e.statusText;t(n,r,e.getResponseHeader(`Content-Type`),new x(e.getAllResponseHeaders()))}},e.withCredentials=o,s)Object.prototype.hasOwnProperty.call(s,l)&&e.setRequestHeader(l,s[l]);return e.send(),e};function C(e){this._headers=e}C.prototype.get=function(e){return this._headers.get(e)};function w(){}w.prototype.open=function(e,t,n,r,i,a,o){var s=null,c=new h,l=c.signal,f=new p;return d(i,{headers:o,credentials:a?`include`:`same-origin`,signal:l,cache:`no-store`}).then(function(e){return s=e.body.getReader(),t(e.status,e.statusText,e.headers.get(`Content-Type`),new C(e.headers)),new u(function(e,t){var r=function(){s.read().then(function(t){t.done?e(void 0):(n(f.decode(t.value,{stream:!0})),r())}).catch(function(e){t(e)})};r()})}).catch(function(e){if(e.name!==`AbortError`)return e}).then(function(e){r(e)}),{abort:function(){s?.cancel(),c.abort()}}};function T(){this._listeners=Object.create(null)}function E(e){r(function(){throw e},0)}T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(t!=null)for(var n=t.length,r=0;r<n;r+=1){var i=t[r];try{typeof i.handleEvent==`function`?i.handleEvent(e):i.call(this,e)}catch(e){E(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];r??(r=[],n[e]=r);for(var i=!1,a=0;a<r.length;a+=1)r[a]===t&&(i=!0);i||r.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(r!=null){for(var i=[],a=0;a<r.length;a+=1)r[a]!==t&&i.push(r[a]);i.length===0?delete n[e]:n[e]=i}};function D(e){this.type=e,this.target=void 0}function O(e,t){D.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}O.prototype=Object.create(D.prototype);function k(e,t){D.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}k.prototype=Object.create(D.prototype);function A(e,t){D.call(this,e),this.error=t.error}A.prototype=Object.create(D.prototype);var j=-1,M=0,N=1,P=2,F=-1,I=0,L=1,R=2,z=3,B=/^text\/event\-stream(;.*)?$/i,V=1e3,H=18e6,U=function(e,t){var n=e==null?t:parseInt(e,10);return n!==n&&(n=t),W(n)},W=function(e){return Math.min(Math.max(e,V),H)},G=function(e,t,n){try{typeof t==`function`&&t.call(e,n)}catch(e){E(e)}};function K(e,t){T.call(this),t||={},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,Y(this,e,t)}function q(){return a!=null&&`withCredentials`in a.prototype||o==null?new a:new o}var J=d!=null&&f!=null&&`body`in f.prototype;function Y(e,t,n){t=String(t);var a=!!n.withCredentials,o=n.lastEventIdQueryParameterName||`lastEventId`,s=W(1e3),c=U(n.heartbeatTimeout,45e3),l=``,u=s,d=!1,f=0,p=n.headers||{},m=n.Transport,h=J&&m==null?void 0:new y(m==null?q():new m),g=m!=null&&typeof m!=`string`?new m:h==null?new w:new S,_=void 0,v=0,b=j,x=``,C=``,T=``,E=``,D=I,V=0,H=0,K=function(t,n,r,i){if(b===M)if(t===200&&r!=null&&B.test(r)){b=N,d=Date.now(),u=s,e.readyState=N;var a=new k(`open`,{status:t,statusText:n,headers:i});e.dispatchEvent(a),G(e,e.onopen,a)}else{t===200?``+(r==null?`-`:r.replace(/\s+/g,` `)):(n&&=n.replace(/\s+/g,` `),``+t+n),Z();var a=new k(`error`,{status:t,statusText:n,headers:i});e.dispatchEvent(a),G(e,e.onerror,a)}},Y=function(t){if(b===N){for(var n=-1,a=0;a<t.length;a+=1){var o=t.charCodeAt(a);(o===10||o===13)&&(n=a)}var p=(n===-1?``:E)+t.slice(0,n+1);E=(n===-1?E:``)+t.slice(n+1),t!==``&&(d=Date.now(),f+=t.length);for(var m=0;m<p.length;m+=1){var o=p.charCodeAt(m);if(D===F&&o===10)D=I;else if(D===F&&(D=I),o===13||o===10){if(D!==I){D===L&&(H=m+1);var h=p.slice(V,H-1),g=p.slice(H+ +(H<m&&p.charCodeAt(H)===32),m);h===`data`?(x+=`
|
|
3
|
-
`,x+=g):h===`id`?C=g:h===`event`?T=g:h===`retry`?(s=U(g,s),u=s):h===`heartbeatTimeout`&&(c=U(g,c),v!==0&&(i(v),v=r(function(){Q()},c)))}if(D===I){if(x!==``){l=C,T===``&&(T=`message`);var _=new O(T,{data:x.slice(1),lastEventId:C});if(e.dispatchEvent(_),T===`open`?G(e,e.onopen,_):T===`message`?G(e,e.onmessage,_):T===`error`&&G(e,e.onerror,_),b===P)return}x=``,T=``}D=o===13?F:I}else D===I&&(V=m,D=L),D===L?o===58&&(H=m+1,D=R):D===R&&(D=z)}}},X=function(t){if(b===N||b===M){b=j,v!==0&&(i(v),v=0),v=r(function(){Q()},u),u=W(Math.min(s*16,u*2)),e.readyState=M;var n=new A(`error`,{error:t});e.dispatchEvent(n),G(e,e.onerror,n)}},Z=function(){b=P,_!=null&&(_.abort(),_=void 0),v!==0&&(i(v),v=0),e.readyState=P},Q=function(){if(v=0,b!==j){if(!d&&_!=null)X(Error(`No activity within `+c+` milliseconds. `+(b===M?`No response received.`:f+` chars received.`)+` Reconnecting.`)),_!=null&&(_.abort(),_=void 0);else{var n=Math.max((d||Date.now())+c-Date.now(),1);d=!1,v=r(function(){Q()},n)}return}d=!1,f=0,v=r(function(){Q()},c),b=M,x=``,T=``,C=l,E=``,V=0,H=0,D=I;var i=t;if(t.slice(0,5)!==`data:`&&t.slice(0,5)!==`blob:`&&l!==``){var a=t.indexOf(`?`);i=a===-1?t:t.slice(0,a+1)+t.slice(a+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(e,t){return t===o?``:e}),i+=(t.indexOf(`?`)===-1?`?`:`&`)+o+`=`+encodeURIComponent(l)}var s=e.withCredentials,u={};u.Accept=`text/event-stream`;var p=e.headers;if(p!=null)for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(u[m]=p[m]);try{_=g.open(h,K,Y,X,i,s,u)}catch(e){throw Z(),e}};e.url=t,e.readyState=M,e.withCredentials=a,e.headers=p,e._close=Z,Q()}K.prototype=Object.create(T.prototype),K.prototype.CONNECTING=M,K.prototype.OPEN=N,K.prototype.CLOSED=P,K.prototype.close=function(){this._close()},K.CONNECTING=M,K.OPEN=N,K.CLOSED=P,K.prototype.withCredentials=void 0;var X=c;a!=null&&(c==null||!(`withCredentials`in c.prototype))&&(X=K),(function(r){if(typeof t==`object`&&typeof t.exports==`object`){var i=r(e);i!==void 0&&(t.exports=i)}else typeof define==`function`&&define.amd?define([`exports`],r):r(n)})(function(e){e.EventSourcePolyfill=K,e.NativeEventSource=c,e.EventSource=X})})(typeof globalThis>`u`?typeof window<`u`?window:typeof self<`u`?self:e:globalThis)})),m=p();function h({candidates:e,headers:t,createEventSource:n,onMessage:r,onError:i}){let a=e.filter(Boolean),o=!1,s=null,c=()=>{s?.close(),s=null},l=e=>{if(o)return;let u=a[e];if(!u){i?.(Error(`Failed to connect to EventSource through proxy chain`));return}c();let d=n(u,{headers:t});s=d,d.onmessage=e=>{o||s!==d||r(e)},d.onerror=t=>{if(!(o||s!==d)){if(c(),e+1<a.length){l(e+1);return}i?.(t)}}};return l(0),{close(){o=!0,c()}}}var g=`https://api.unsplash.com`,_=`https://api.giphy.com/v1/gifs`;function v(e){return{error:e instanceof Error?e:Error(String(e))}}async function y(e){if(!e.ok)throw Error(`Request failed with status ${e.status}`);let t=await e.text();try{return t?JSON.parse(t):null}catch(e){throw e}}function b(e){return e&&Array.isArray(e.results)?e:e?.data&&Array.isArray(e.data.results)?e.data:e?.response&&Array.isArray(e.response.results)?e.response:{...e||{},results:[]}}var x=i.Ei({reducerPath:`imageApi`,baseQuery:void 0,endpoints:e=>({getImageInfo:e.query({queryFn:async function(e,t){try{let n=t.getState().configSlice?.config?.imageInfoToolUrl||`https://scr.emcdn.ru/imageinfo`;return{data:await y(await fetch(`${n}?url=${encodeURIComponent(e)}`))}}catch(e){return v(e)}}}),getSearchImage:e.query({queryFn:async function({query:e,page:t},n){let r=e.keywords.replace(/[^\w\d\sа-яёА-ЯЁ]|_/g,``).replace(/[\s_-]+/g,` `);try{let a=n.getState().configSlice?.config,o=i.Si.getInstance(n,i.yo)!==void 0,s=new URL(`${g}/search/photos`);return s.searchParams.set(`client_id`,`S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o`),s.searchParams.set(`lang`,`ru`),s.searchParams.set(`per_page`,`18`),s.searchParams.set(`query`,r),s.searchParams.set(`page`,String(t)),e.color!==``&&s.searchParams.set(`color`,e.color),e.orientation!==``&&s.searchParams.set(`orientation`,e.orientation),{data:b(await y(await i.to(s.toString(),{config:a,standalone:o,resourceType:`stockImages`,intent:`metadata`})))}}catch(e){return v(e)}}}),getUnsplashImage:e.query({queryFn:async function(e,t){try{let n=t.getState().configSlice?.config,r=i.Si.getInstance(t,i.yo)!==void 0,a=new URL(e);return a.searchParams.set(`client_id`,`S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o`),{data:await y(await i.to(a.toString(),{config:n,standalone:r,resourceType:`stockImages`,intent:`metadata`}))}}catch(e){return v(e)}}}),sendAiImageRequest:e.query({queryFn:async function({body:e},t){try{return await i.yi(t).aiGenerator.ai_create(e)}catch(e){throw Error(e)}}}),getAiImage:e.query({queryFn:async function(e,t){try{return await i.yi(t).aiGenerator.ai_status_list(e)}catch(e){return v(e)}}}),getAiImageSSE:e.query({queryFn:e=>({data:[]}),async onCacheEntryAdded({task_id:e,entity_id:t,setError:n},r){let{updateCachedData:a,cacheEntryRemoved:o}=r,s=i.yi(r).baseUrl||i.Qa(`https://app.emailmaker.ru/api/`),c=r.getState().configSlice?.config,l=i.Si.getInstance(r,i.yo)!==void 0,d=i.Ta.isPlugin?await i.Si.getInstance(r,u):i.gi.get(i.Vi.em_token),f=d?{Authorization:`Bearer ${d}`}:{},p=`${s}/ai-generator/v1/ai-status?entity_id=${t}&stream=1&task_id=${e}`,g=i.io(p,{config:c,method:`GET`,requestType:`ai`,standalone:l}),_=h({candidates:g.length>0?g:[p],headers:f,createEventSource:(e,t)=>new m.EventSourcePolyfill(e,t),onMessage:e=>{let t=JSON.parse(e.data);a(e=>{e.push(t)}),t.progress===100&&_.close()},onError:()=>{_.close()}});await o,_.close()}}),getSearchGif:e.query({queryFn:async function({query:e,page:t},n){let r=e.keywords.replace(/[^\w\d\sа-яёА-ЯЁ]|_/g,``).replace(/[\s_-]+/g,` `);try{let e=n.getState().configSlice?.config,a=i.Si.getInstance(n,i.yo)!==void 0;return{data:await y(await i.to(`${_}/search?api_key=Nh77eBlPeMn1ed9MBAvL542NUGeNO26F&q=${encodeURIComponent(r)}&limit=25&offset=${t}&lang=en`,{config:e,standalone:a,resourceType:`generic`,intent:`metadata`}))}}catch(e){return v(e)}}})})}),{useLazyGetImageInfoQuery:S,useGetImageInfoQuery:C,useGetSearchImageQuery:w,useLazyGetSearchImageQuery:T,useSendAiImageRequestQuery:E,useLazySendAiImageRequestQuery:D,useGetAiImageQuery:O,useLazyGetAiImageQuery:k,useGetUnsplashImageQuery:A,useLazyGetUnsplashImageQuery:j,useGetSearchGifQuery:M,useLazyGetSearchGifQuery:N,useGetAiImageSSEQuery:P,useLazyGetAiImageSSEQuery:F}=x,I=`https://app.emailmaker.ru/api/`.replaceAll(/[\\/]$/g,``),L=`wp-json/limits/v1`,R=`wp-json/subscription/v2`,z=i.Ei({reducerPath:`limitsApi`,baseQuery:i._i({baseUrl:I}),tagTypes:[`LimitsStats`,`LimitsWarnings`,`SubscriptionMe`],endpoints:e=>({getLimitsStats:e.query({query:()=>({url:`${L}/stats`,method:`GET`}),providesTags:[`LimitsStats`]}),getLimitsStatsByType:e.query({query:e=>({url:`${L}/stats/${e}`,method:`GET`}),providesTags:(e,t,n)=>[{type:`LimitsStats`,id:n}]}),getLimitsWarnings:e.query({query:()=>({url:`${L}/warnings`,method:`GET`}),providesTags:[`LimitsWarnings`]}),getSubscriptionMeV2:e.query({query:()=>({url:`${R}/me`,method:`GET`}),providesTags:[`SubscriptionMe`]})})}),{useGetLimitsStatsQuery:B,useLazyGetLimitsStatsQuery:V,useGetLimitsStatsByTypeQuery:H,useLazyGetLimitsStatsByTypeQuery:U,useGetLimitsWarningsQuery:W,useLazyGetLimitsWarningsQuery:G,useGetSubscriptionMeV2Query:K,useLazyGetSubscriptionMeV2Query:q}=z,J=new URLSearchParams(window.location.search),Y=J.get(`tag`),X=J.get(`folder`),Z=i.li({activeModal:``,switchToPlanRequestTitle:``,secondModal:``,projectsTotal:``,projectsTotalPages:``,folders:[],activeTagId:Y||null,activeFolderId:X||(Y?null:`all`),activeTab:null,activeIntegration:null,addNewProjectInitialTitle:null}),Q=`projectsPageSlice`,$=i.Ii({name:Q,initialState:Z,reducers:{openModal(e,t){e.activeModal=t.payload},openAddNewProjectModal(e,t){e.activeModal=i.ba.ADD_NEW_PROJECT_MODAL,e.addNewProjectInitialTitle=t.payload??null},setSwitchToPlanRequestTitle(e,t){e.switchToPlanRequestTitle=typeof t.payload==`string`?t.payload:``},setActiveTab(e,t){e.activeTab=t.payload},closeModal(e){e.activeModal=``,e.activeIntegration=null,e.addNewProjectInitialTitle=null,e.switchToPlanRequestTitle=``},openSecondModal(e,t){e.secondModal=t.payload},closeSecondModal(e){e.secondModal=``},setFolders(e,{payload:t}){e.folders=t},setActiveTagId(e,{payload:t}){e.activeTagId=t},setActiveIntegration(e,t){e.activeIntegration=t.payload}},extraReducers:e=>{e.addMatcher(i.Jr.endpoints.getProjects.matchFulfilled,(e,t)=>{let n=t.meta,r=n.baseQueryMeta,i=n.projectsListPagination??r?.projectsListPagination;if(i!=null&&typeof i.total==`number`&&Number.isFinite(i.total)&&i.total>=0){e.projectsTotal=String(i.total),e.projectsTotalPages=String(typeof i.totalPages==`number`&&Number.isFinite(i.totalPages)?i.totalPages:``);return}let a=r?.response?.headers?.get?.(`X-WP-Total`),o=r?.response?.headers?.get?.(`X-WP-TotalPages`);e.projectsTotal=a??``,e.projectsTotalPages=o??``}),e.addMatcher(i.Vr.endpoints.getFolders.matchFulfilled,(e,{payload:t})=>{e.folders=t})}}),{openModal:ee,openAddNewProjectModal:te,setSwitchToPlanRequestTitle:ne,setActiveTab:re,closeModal:ie,openSecondModal:ae,closeSecondModal:oe,setFolders:se,setActiveTagId:ce,setActiveIntegration:le}=$.actions,ue=e=>e[Q].activeTab,de=e=>e[Q].activeModal,fe=e=>e[Q].secondModal,pe=e=>e[Q].projectsTotal,me=e=>e[Q].activeIntegration;Object.defineProperty(t,"C",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"D",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"E",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"O",{enumerable:!0,get:function(){return o}}),Object.defineProperty(t,"S",{enumerable:!0,get:function(){return j}}),Object.defineProperty(t,"T",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"_",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"a",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"b",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"c",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"d",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"f",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"g",{enumerable:!0,get:function(){return U}}),Object.defineProperty(t,"h",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"i",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(t,"k",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"l",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"m",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"n",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"o",{enumerable:!0,get:function(){return me}}),Object.defineProperty(t,"p",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"r",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(t,"s",{enumerable:!0,get:function(){return de}}),Object.defineProperty(t,"t",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"u",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"v",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"w",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"x",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"y",{enumerable:!0,get:function(){return S}})});
|
|
3
|
+
`,x+=g):h===`id`?C=g:h===`event`?T=g:h===`retry`?(s=U(g,s),u=s):h===`heartbeatTimeout`&&(c=U(g,c),v!==0&&(i(v),v=r(function(){Q()},c)))}if(D===I){if(x!==``){l=C,T===``&&(T=`message`);var _=new O(T,{data:x.slice(1),lastEventId:C});if(e.dispatchEvent(_),T===`open`?G(e,e.onopen,_):T===`message`?G(e,e.onmessage,_):T===`error`&&G(e,e.onerror,_),b===P)return}x=``,T=``}D=o===13?F:I}else D===I&&(V=m,D=L),D===L?o===58&&(H=m+1,D=R):D===R&&(D=z)}}},X=function(t){if(b===N||b===M){b=j,v!==0&&(i(v),v=0),v=r(function(){Q()},u),u=W(Math.min(s*16,u*2)),e.readyState=M;var n=new A(`error`,{error:t});e.dispatchEvent(n),G(e,e.onerror,n)}},Z=function(){b=P,_!=null&&(_.abort(),_=void 0),v!==0&&(i(v),v=0),e.readyState=P},Q=function(){if(v=0,b!==j){if(!d&&_!=null)X(Error(`No activity within `+c+` milliseconds. `+(b===M?`No response received.`:f+` chars received.`)+` Reconnecting.`)),_!=null&&(_.abort(),_=void 0);else{var n=Math.max((d||Date.now())+c-Date.now(),1);d=!1,v=r(function(){Q()},n)}return}d=!1,f=0,v=r(function(){Q()},c),b=M,x=``,T=``,C=l,E=``,V=0,H=0,D=I;var i=t;if(t.slice(0,5)!==`data:`&&t.slice(0,5)!==`blob:`&&l!==``){var a=t.indexOf(`?`);i=a===-1?t:t.slice(0,a+1)+t.slice(a+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(e,t){return t===o?``:e}),i+=(t.indexOf(`?`)===-1?`?`:`&`)+o+`=`+encodeURIComponent(l)}var s=e.withCredentials,u={};u.Accept=`text/event-stream`;var p=e.headers;if(p!=null)for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(u[m]=p[m]);try{_=g.open(h,K,Y,X,i,s,u)}catch(e){throw Z(),e}};e.url=t,e.readyState=M,e.withCredentials=a,e.headers=p,e._close=Z,Q()}K.prototype=Object.create(T.prototype),K.prototype.CONNECTING=M,K.prototype.OPEN=N,K.prototype.CLOSED=P,K.prototype.close=function(){this._close()},K.CONNECTING=M,K.OPEN=N,K.CLOSED=P,K.prototype.withCredentials=void 0;var X=c;a!=null&&(c==null||!(`withCredentials`in c.prototype))&&(X=K),(function(r){if(typeof t==`object`&&typeof t.exports==`object`){var i=r(e);i!==void 0&&(t.exports=i)}else typeof define==`function`&&define.amd?define([`exports`],r):r(n)})(function(e){e.EventSourcePolyfill=K,e.NativeEventSource=c,e.EventSource=X})})(typeof globalThis>`u`?typeof window<`u`?window:typeof self<`u`?self:e:globalThis)})),m=p();function h({candidates:e,headers:t,createEventSource:n,onMessage:r,onError:i}){let a=e.filter(Boolean),o=!1,s=null,c=()=>{s?.close(),s=null},l=e=>{if(o)return;let u=a[e];if(!u){i?.(Error(`Failed to connect to EventSource through proxy chain`));return}c();let d=n(u,{headers:t});s=d,d.onmessage=e=>{o||s!==d||r(e)},d.onerror=t=>{if(!(o||s!==d)){if(c(),e+1<a.length){l(e+1);return}i?.(t)}}};return l(0),{close(){o=!0,c()}}}var g=`https://api.unsplash.com`,_=`https://api.giphy.com/v1/gifs`;function v(e){return{error:e instanceof Error?e:Error(String(e))}}async function y(e){if(!e.ok)throw Error(`Request failed with status ${e.status}`);let t=await e.text();try{return t?JSON.parse(t):null}catch(e){throw e}}function b(e){return e&&Array.isArray(e.results)?e:e?.data&&Array.isArray(e.data.results)?e.data:e?.response&&Array.isArray(e.response.results)?e.response:{...e||{},results:[]}}var x=i.Di({reducerPath:`imageApi`,baseQuery:void 0,endpoints:e=>({getImageInfo:e.query({queryFn:async function(e,t){try{let n=t.getState().configSlice?.config?.imageInfoToolUrl||`https://scr.emcdn.ru/imageinfo`;return{data:await y(await fetch(`${n}?url=${encodeURIComponent(e)}`))}}catch(e){return v(e)}}}),getSearchImage:e.query({queryFn:async function({query:e,page:t},n){let r=e.keywords.replace(/[^\w\d\sа-яёА-ЯЁ]|_/g,``).replace(/[\s_-]+/g,` `);try{let a=n.getState().configSlice?.config,o=i.Ci.getInstance(n,i.bo)!==void 0,s=new URL(`${g}/search/photos`);return s.searchParams.set(`client_id`,`S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o`),s.searchParams.set(`lang`,`ru`),s.searchParams.set(`per_page`,`18`),s.searchParams.set(`query`,r),s.searchParams.set(`page`,String(t)),e.color!==``&&s.searchParams.set(`color`,e.color),e.orientation!==``&&s.searchParams.set(`orientation`,e.orientation),{data:b(await y(await i.no(s.toString(),{config:a,standalone:o,resourceType:`stockImages`,intent:`metadata`})))}}catch(e){return v(e)}}}),getUnsplashImage:e.query({queryFn:async function(e,t){try{let n=t.getState().configSlice?.config,r=i.Ci.getInstance(t,i.bo)!==void 0,a=new URL(e);return a.searchParams.set(`client_id`,`S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o`),{data:await y(await i.no(a.toString(),{config:n,standalone:r,resourceType:`stockImages`,intent:`metadata`}))}}catch(e){return v(e)}}}),sendAiImageRequest:e.query({queryFn:async function({body:e},t){try{return await i.bi(t).aiGenerator.ai_create(e)}catch(e){throw Error(e)}}}),getAiImage:e.query({queryFn:async function(e,t){try{return await i.bi(t).aiGenerator.ai_status_list(e)}catch(e){return v(e)}}}),getAiImageSSE:e.query({queryFn:e=>({data:[]}),async onCacheEntryAdded({task_id:e,entity_id:t,setError:n},r){let{updateCachedData:a,cacheEntryRemoved:o}=r,s=i.bi(r).baseUrl||i.$a(`https://app.emailmaker.ru/api/`),c=r.getState().configSlice?.config,l=i.Ci.getInstance(r,i.bo)!==void 0,d=i.Ea.isPlugin?await i.Ci.getInstance(r,u):i._i.get(i.Hi.em_token),f=d?{Authorization:`Bearer ${d}`}:{},p=`${s}/ai-generator/v1/ai-status?entity_id=${t}&stream=1&task_id=${e}`,g=i.ao(p,{config:c,method:`GET`,requestType:`ai`,standalone:l}),_=h({candidates:g.length>0?g:[p],headers:f,createEventSource:(e,t)=>new m.EventSourcePolyfill(e,t),onMessage:e=>{let t=JSON.parse(e.data);a(e=>{e.push(t)}),t.progress===100&&_.close()},onError:()=>{_.close()}});await o,_.close()}}),getSearchGif:e.query({queryFn:async function({query:e,page:t},n){let r=e.keywords.replace(/[^\w\d\sа-яёА-ЯЁ]|_/g,``).replace(/[\s_-]+/g,` `);try{let e=n.getState().configSlice?.config,a=i.Ci.getInstance(n,i.bo)!==void 0;return{data:await y(await i.no(`${_}/search?api_key=Nh77eBlPeMn1ed9MBAvL542NUGeNO26F&q=${encodeURIComponent(r)}&limit=25&offset=${t}&lang=en`,{config:e,standalone:a,resourceType:`generic`,intent:`metadata`}))}}catch(e){return v(e)}}})})}),{useLazyGetImageInfoQuery:S,useGetImageInfoQuery:C,useGetSearchImageQuery:w,useLazyGetSearchImageQuery:T,useSendAiImageRequestQuery:E,useLazySendAiImageRequestQuery:D,useGetAiImageQuery:O,useLazyGetAiImageQuery:k,useGetUnsplashImageQuery:A,useLazyGetUnsplashImageQuery:j,useGetSearchGifQuery:M,useLazyGetSearchGifQuery:N,useGetAiImageSSEQuery:P,useLazyGetAiImageSSEQuery:F}=x,I=`https://app.emailmaker.ru/api/`.replaceAll(/[\\/]$/g,``),L=`wp-json/limits/v1`,R=`wp-json/subscription/v2`,z=i.Di({reducerPath:`limitsApi`,baseQuery:i.vi({baseUrl:I}),tagTypes:[`LimitsStats`,`LimitsWarnings`,`SubscriptionMe`],endpoints:e=>({getLimitsStats:e.query({query:()=>({url:`${L}/stats`,method:`GET`}),providesTags:[`LimitsStats`]}),getLimitsStatsByType:e.query({query:e=>({url:`${L}/stats/${e}`,method:`GET`}),providesTags:(e,t,n)=>[{type:`LimitsStats`,id:n}]}),getLimitsWarnings:e.query({query:()=>({url:`${L}/warnings`,method:`GET`}),providesTags:[`LimitsWarnings`]}),getSubscriptionMeV2:e.query({query:()=>({url:`${R}/me`,method:`GET`}),providesTags:[`SubscriptionMe`]})})}),{useGetLimitsStatsQuery:B,useLazyGetLimitsStatsQuery:V,useGetLimitsStatsByTypeQuery:H,useLazyGetLimitsStatsByTypeQuery:U,useGetLimitsWarningsQuery:W,useLazyGetLimitsWarningsQuery:G,useGetSubscriptionMeV2Query:K,useLazyGetSubscriptionMeV2Query:q}=z,J=new URLSearchParams(window.location.search),Y=J.get(`tag`),X=J.get(`folder`),Z=i.ui({activeModal:``,switchToPlanRequestTitle:``,secondModal:``,projectsTotal:``,projectsTotalPages:``,folders:[],activeTagId:Y||null,activeFolderId:X||(Y?null:`all`),activeTab:null,activeIntegration:null,addNewProjectInitialTitle:null}),Q=`projectsPageSlice`,$=i.Li({name:Q,initialState:Z,reducers:{openModal(e,t){e.activeModal=t.payload},openAddNewProjectModal(e,t){e.activeModal=i.xa.ADD_NEW_PROJECT_MODAL,e.addNewProjectInitialTitle=t.payload??null},setSwitchToPlanRequestTitle(e,t){e.switchToPlanRequestTitle=typeof t.payload==`string`?t.payload:``},setActiveTab(e,t){e.activeTab=t.payload},closeModal(e){e.activeModal=``,e.activeIntegration=null,e.addNewProjectInitialTitle=null,e.switchToPlanRequestTitle=``},openSecondModal(e,t){e.secondModal=t.payload},closeSecondModal(e){e.secondModal=``},setFolders(e,{payload:t}){e.folders=t},setActiveTagId(e,{payload:t}){e.activeTagId=t},setActiveIntegration(e,t){e.activeIntegration=t.payload}},extraReducers:e=>{e.addMatcher(i.Yr.endpoints.getProjects.matchFulfilled,(e,t)=>{let n=t.meta,r=n.baseQueryMeta,i=n.projectsListPagination??r?.projectsListPagination;if(i!=null&&typeof i.total==`number`&&Number.isFinite(i.total)&&i.total>=0){e.projectsTotal=String(i.total),e.projectsTotalPages=String(typeof i.totalPages==`number`&&Number.isFinite(i.totalPages)?i.totalPages:``);return}let a=r?.response?.headers?.get?.(`X-WP-Total`),o=r?.response?.headers?.get?.(`X-WP-TotalPages`);e.projectsTotal=a??``,e.projectsTotalPages=o??``}),e.addMatcher(i.Hr.endpoints.getFolders.matchFulfilled,(e,{payload:t})=>{e.folders=t})}}),{openModal:ee,openAddNewProjectModal:te,setSwitchToPlanRequestTitle:ne,setActiveTab:re,closeModal:ie,openSecondModal:ae,closeSecondModal:oe,setFolders:se,setActiveTagId:ce,setActiveIntegration:le}=$.actions,ue=e=>e[Q].activeTab,de=e=>e[Q].activeModal,fe=e=>e[Q].secondModal,pe=e=>e[Q].projectsTotal,me=e=>e[Q].activeIntegration;Object.defineProperty(t,"C",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"D",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"E",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"O",{enumerable:!0,get:function(){return o}}),Object.defineProperty(t,"S",{enumerable:!0,get:function(){return j}}),Object.defineProperty(t,"T",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"_",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"a",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"b",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"c",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"d",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"f",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"g",{enumerable:!0,get:function(){return U}}),Object.defineProperty(t,"h",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"i",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(t,"k",{enumerable:!0,get:function(){return a}}),Object.defineProperty(t,"l",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"m",{enumerable:!0,get:function(){return B}}),Object.defineProperty(t,"n",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(t,"o",{enumerable:!0,get:function(){return me}}),Object.defineProperty(t,"p",{enumerable:!0,get:function(){return z}}),Object.defineProperty(t,"r",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(t,"s",{enumerable:!0,get:function(){return de}}),Object.defineProperty(t,"t",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(t,"u",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"v",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"w",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"x",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"y",{enumerable:!0,get:function(){return S}})});
|