@emailmaker/filemanager 0.10.74 → 0.10.75
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/file-manager.esm.js +1 -1
- package/file-manager.js +1 -1
- package/package.json +1 -1
package/file-manager.esm.js
CHANGED
|
@@ -58,5 +58,5 @@ function WM(){return WM=Object.assign?Object.assign.bind():function(e){for(var t
|
|
|
58
58
|
*
|
|
59
59
|
* @license MIT
|
|
60
60
|
*/
|
|
61
|
-
function nR(){return nR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},nR.apply(this,arguments)}new Promise(()=>{});const iR=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"];try{window.__reactRouterVersion="6"}catch{}const oR=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",aR=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,sR=n.forwardRef(function(e,t){let r,{onClick:i,relative:o,reloadDocument:a,replace:s,state:l,target:c,to:u,preventScrollReset:d,unstable_viewTransition:h}=e,f=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&(i[r]=e[r]);return i}(e,iR),{basename:p}=n.useContext(qM),g=!1;if("string"==typeof u&&aR.test(u)&&(r=u,oR))try{let e=new URL(window.location.href),t=u.startsWith("//")?new URL(e.protocol+u):new URL(u),r=function(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}(t.pathname,p);t.origin===e.origin&&null!=r?u=r+t.search+t.hash:g=!0}catch{}let m=function(e,t){let{relative:r}=void 0===t?{}:t;KM()||MM(!1);let{basename:i,navigator:o}=n.useContext(qM),{hash:a,pathname:s,search:l}=eR(e,{relative:r}),c=s;return"/"!==i&&(c="/"===s?i:BM([i,s])),o.createHref({pathname:c,search:l,hash:a})}(u,{relative:o}),v=function(e,t){let{target:r,replace:i,state:o,preventScrollReset:a,relative:s,unstable_viewTransition:l}=void 0===t?{}:t,c=QM(),u=ZM(),d=eR(e,{relative:s});return n.useCallback(t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,r)){t.preventDefault();let r=void 0!==i?i:RM(u)===RM(d);c(e,{replace:r,state:o,preventScrollReset:a,relative:s,unstable_viewTransition:l})}},[u,c,d,i,o,r,e,a,s,l])}(u,{replace:s,state:l,target:c,preventScrollReset:d,relative:o,unstable_viewTransition:h});return n.createElement("a",nR({},f,{href:r||m,onClick:g||a?i:function(e){i&&i(e),e.defaultPrevented||v(e)},ref:t,target:c}))});var lR,cR;!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"}(lR||(lR={})),function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(cR||(cR={}));const uR=nf(e("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutlineOutlined"),dR=nf(e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined"),hR={opacity:0,y:50,scale:.3},fR={opacity:1,y:0,scale:1},pR={opacity:0,scale:.5};function gR(){const r=Fm(e=>e.toasts);return e("div",{className:"pointer-events-none relative",children:e(Ax,{initial:!1,children:r.map(r=>e("div",{className:ef("fixed z-toast mx-auto p-20","bottom-center"===r.position?"bottom-0 left-0 right-0":"bottom-0 right-0"),children:t(bx.div,{initial:r.disableEnterAnimation?void 0:hR,animate:r.disableEnterAnimation?void 0:fR,exit:r.disableExitAnimation?void 0:pR,className:ef("pointer-events-auto mx-auto flex max-h-100 min-h-50 w-min min-w-288 max-w-500 items-center gap-10 rounded-lg border bg-paper bg-paper py-6 pl-16 pr-6 text-sm text-main shadow-lg"),onPointerEnter:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onPointerLeave:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},role:"alert","aria-live":"danger"===r.type?"assertive":"polite",children:["danger"===r.type&&e(uR,{className:"flex-shrink-0 text-danger",size:"md"}),"loading"===r.type&&e(aO,{size:"sm",className:"flex-shrink-0",isIndeterminate:!0}),"positive"===r.type&&e(dR,{className:"flex-shrink-0 text-positive",size:"md"}),e("div",{className:"mr-auto w-max overflow-hidden overflow-ellipsis","data-testid":"toast-message",children:e(XA,{value:r.message})}),r.action&&e(L_,{variant:"text",color:"primary",size:"sm",className:"flex-shrink-0",onFocus:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onBlur:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},onClick:()=>Tm().remove(r.id),elementType:sR,to:r.action.action,children:e(XA,{value:r.action.label})}),"loading"!==r.type&&e(qA,{onFocus:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onBlur:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},type:"button",className:"flex-shrink-0",onClick:()=>{Tm().remove(r.id)},size:"sm",children:e(lI,{})})]})},r.id))})})}function mR(e){return $x()?e.metaKey:e.ctrlKey}function vR(e){switch(e.key){case"z":mR(e)&&(e.preventDefault(),e.stopPropagation(),e.shiftKey?bm().history.redo():bm().history.undo());break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),bm().objects.move("up");break;case"ArrowRight":e.preventDefault(),e.stopPropagation(),bm().objects.move("right");break;case"ArrowDown":e.preventDefault(),e.stopPropagation(),bm().objects.move("down");break;case"ArrowLeft":e.preventDefault(),e.stopPropagation(),bm().objects.move("left");break;case"Delete":e.preventDefault(),e.stopPropagation(),bm().objects.delete();break;case"v":mR(e)&&(e.preventDefault(),e.stopPropagation(),async function(){try{const e=await navigator.clipboard.read();for(const t of e)for(const e of t.types)if(e.startsWith("image/")){const r=await t.getType(e),n=new FileReader;return n.onload=e=>{var t;null!=(t=e.target)&&t.result&&bm().import.addImageFromData(e.target.result)},void n.readAsDataURL(r)}}catch(e){console.error(e)}}())}}const yR=new Map,bR=new Map,wR={};async function*xR(e){const t=e.createReader();let r;do{r=await new Promise((e,r)=>{t.readEntries(e,r)});for(const e of r)if(e.isFile){if(".DS_Store"===e.name)continue;const t=await CR(e);yield new s_(t,e.fullPath)}else e.isDirectory&&(yield*xR(e))}while(r.length>0)}function CR(e){return new Promise((t,r)=>e.file(t,r))}function _R(e){return null!=wR.dragTargetId?yR.get(wR.dragTargetId):e.dataTransfer.types.includes("Files")?{type:"nativeFile",el:null,ref:null,getData:()=>async function(e){const t=[];for await(const r of e)t.push(r);return t}(async function*(e){const t=[];for(const r of e.items)if("file"===r.kind){const e=r.webkitGetAsEntry();e&&t.push(e)}for(const e of t)if(e.isFile){if(".DS_Store"===e.name)continue;const t=await CR(e);yield new s_(t,e.fullPath)}else e.isDirectory&&(yield*xR(e))}(e.dataTransfer))}:void 0}function SR(){const r=vm(e=>{var t;return null==(t=e.config.ui)?void 0:t.visible})??!0,n=vm(e=>{var t,r;return null==(r=null==(t=e.config.ui)?void 0:t.nav)?void 0:r.position})??"bottom",i=vm(e=>{var t,r;return null==(r=null==(t=e.config.ui)?void 0:t.menubar)?void 0:r.position})??"top",o=vm(e=>{var t;return null==(t=e.config.ui)?void 0:t.allowEditorClose})??!0,s=u(null),l=u(null),{isModal:d,isMobile:h}=cI(),f=c(async e=>{var t,r;if(ym().activeTool||ym().dirty||"nativeFile"!==e.type)return;const n=await e.getData();bm().import.fileIsValid(n[0])&&((null==(r=null==(t=ym().config.tools)?void 0:t.import)?void 0:r.openDroppedImageAsBackground)?await bm().import.openBackgroundImage(n[0]):await bm().import.openUploadedFile(n[0]))},[]),{droppableProps:p}=function({id:e,disabled:t,ref:r,...n}){const i=u({dragOverElements:new Set,dropActivateTimer:void 0}).current,o=u(n);o.current=n,x(()=>(bR.set(e,{...bR.get(e),disabled:t,id:e,ref:r}),()=>{bR.delete(e)}),[e,o,t,r]);const a=e=>{var t;const n=o.current,i=n.allowDragEventsFromItself||r.current!==(null==(t=e.ref)?void 0:t.current);return!(!(null!=e&&e.type&&i&&n.types.includes(e.type))||n.acceptsDrop&&!n.acceptsDrop(e))},s=e=>{var t,r;const n=_R(e);n&&(null==(r=(t=o.current).onDragLeave)||r.call(t,n))};return{droppableProps:t?{}:{onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation();const n=_R(e);n&&a(n)&&(null==(r=(t=o.current).onDragOver)||r.call(t,n,e))},onDragEnter:e=>{var t,r;if(e.stopPropagation(),i.dragOverElements.add(e.target),i.dragOverElements.size>1)return;const n=_R(e);n&&a(n)&&(null==(r=(t=o.current).onDragEnter)||r.call(t,n),clearTimeout(i.dropActivateTimer),"function"==typeof o.current.onDropActivate&&(i.dropActivateTimer=setTimeout(()=>{var e,t;n&&(null==(t=(e=o.current).onDropActivate)||t.call(e,n))},400)))},onDragLeave:e=>{e.stopPropagation(),i.dragOverElements.delete(e.target);for(const t of i.dragOverElements)e.currentTarget.contains(t)||i.dragOverElements.delete(t);if(i.dragOverElements.size>0)return;const t=_R(e);t&&a(t)&&(s(e),clearTimeout(i.dropActivateTimer))},onDrop:async e=>{var t,r,n,l;e.preventDefault(),e.stopPropagation(),i.dragOverElements.clear(),s(e),clearTimeout(i.dropActivateTimer);const c=_R(e);c&&(null==(r=(t=o.current).onDragLeave)||r.call(t,c),a(c)&&(null==(l=(n=o.current).onDrop)||l.call(n,c)))}}}}({id:"pixie-root",ref:l,types:["nativeFile"],onDrop:f});a(()=>{var e,t;ym().fabric||(vm.setState({canvasRef:s}),A_(s.current),null!=(e=ym().config.ui)&&e.defaultTool&&ym().setActiveTool(null==(t=ym().config.ui)?void 0:t.defaultTool,null),bm().canvas.loadInitialContent().then(()=>{var e,t;null==(t=(e=ym().config).onLoad)||t.call(e,ym().editor)}));const r=I_(l,()=>{ym().setStageSize(E_(l.current))}),n=I_(s,()=>{ym().setCanvasSize(E_(s.current))});return()=>{r(),n()}},[l]);const g=ef("pixie-root flex flex-col overflow-hidden bg-background text-main no-tap-highlight w-full h-full",{relative:!d,"fixed inset-0 w-full h-full z-20":d,"shadow-lg border rounded-md m-auto max-h-[calc(100vh-90px)] max-w-[calc(100vw-90px)]":d&&!h});return t(Ix,{features:Fx,strict:!0,children:[d&&r&&!h&&o&&e(qA,{className:"z-20 fixed right-2 top-2 text-white",size:"lg",onClick:()=>{ym().editor.close()},children:e(lI,{})}),d&&r&&e(Kk,{position:"fixed",disableInitialTransition:!0}),t(bx.div,{initial:!1,variants:{visible:{opacity:1,scale:1,display:"flex"},hidden:{opacity:0,transitionEnd:{display:"none"}}},animate:r?"visible":"hidden",className:g,children:["top"===i&&e(mI,{}),"top"===n&&e(dM,{className:"pt-14"}),t("main",{className:"relative flex-auto my-20 overflow-hidden outline-none",tabIndex:-1,...Ux(p,{onKeyDownCapture:vR}),ref:l,children:[e(yI,{}),e(KE,{ref:s})]}),e(eP,{}),"bottom"===n&&e(dM,{}),"bottom"===i&&e(mI,{}),e(FM,{}),e(gR,{})]})]})}!function(){fabric.Object.ENLIVEN_PROPS.push("eraser");var e=fabric.Object.prototype._drawClipPath,t=fabric.Object.prototype.needsItsOwnCache,r=fabric.Object.prototype.toObject,n=fabric.Object.prototype.getSvgCommons,i=fabric.Object.prototype._createBaseClipPathSVGMarkup,o=fabric.Object.prototype._createBaseSVGMarkup;fabric.Object.prototype.cacheProperties.push("eraser"),fabric.Object.prototype.stateProperties.push("eraser"),fabric.util.object.extend(fabric.Object.prototype,{erasable:!0,eraser:void 0,needsItsOwnCache:function(){return t.call(this)||!!this.eraser},_drawClipPath:function(t,r){if(e.call(this,t,r),this.eraser){var n=this._getNonTransformedDimensions();this.eraser.isType("eraser")&&this.eraser.set({width:n.x,height:n.y}),e.call(this,t,this.eraser)}},toObject:function(e){var t=r.call(this,["erasable"].concat(e));return this.eraser&&!this.eraser.excludeFromExport&&(t.eraser=this.eraser.toObject(e)),t},getSvgCommons:function(){return n.call(this)+(this.eraser?'mask="url(#'+this.eraser.clipPathId+')" ':"")},_createEraserSVGMarkup:function(e){return this.eraser?(this.eraser.clipPathId="MASK_"+fabric.Object.__uid++,['<mask id="',this.eraser.clipPathId,'" >',this.eraser.toSVG(e),"</mask>","\n"].join("")):""},_createBaseClipPathSVGMarkup:function(e,t){return[this._createEraserSVGMarkup(t&&t.reviver),i.call(this,e,t)].join("")},_createBaseSVGMarkup:function(e,t){return[this._createEraserSVGMarkup(t&&t.reviver),o.call(this,e,t)].join("")}});var a=fabric.Group.prototype._restoreObjectsState;fabric.util.object.extend(fabric.Group.prototype,{_addEraserPathToObjects:function(e){this._objects.forEach(function(t){fabric.EraserBrush.prototype._addPathToObjectEraser.call(fabric.EraserBrush.prototype,t,e)})},applyEraserToObjects:function(){var e=this,t=this.eraser;if(t){delete this.eraser;var r=e.calcTransformMatrix();t.clone(function(t){var n=e.clipPath;t.getObjects("path").forEach(function(t){var i=fabric.util.multiplyTransformMatrices(r,t.calcTransformMatrix());fabric.util.applyTransformToObject(t,i),n?n.clone(function(n){var i=fabric.EraserBrush.prototype.applyClipPathToPath.call(fabric.EraserBrush.prototype,t,n,r);e._addEraserPathToObjects(i)},["absolutePositioned","inverted"]):e._addEraserPathToObjects(t)})})}},_restoreObjectsState:function(){return!0===this.erasable&&this.applyEraserToObjects(),a.call(this)}}),fabric.Eraser=fabric.util.createClass(fabric.Group,{type:"eraser",originX:"center",originY:"center",drawObject:function(e){e.save(),e.fillStyle="black",e.fillRect(-this.width/2,-this.height/2,this.width,this.height),e.restore(),this.callSuper("drawObject",e)},_getBounds:function(){},_toSVG:function(e){var t=["<g ","COMMON_PARTS"," >\n"],r=["<rect ",'fill="white" ','x="',-this.width/2,'" y="',-this.height/2,'" width="',this.width,'" height="',this.height,'" />\n'].join("");t.push("\t\t",r);for(var n=0,i=this._objects.length;n<i;n++)t.push("\t\t",this._objects[n].toSVG(e));return t.push("</g>\n"),t}}),fabric.Eraser.fromObject=function(e,t){var r=e.objects;fabric.util.enlivenObjects(r,function(r){var n=fabric.util.object.clone(e,!0);delete n.objects,fabric.util.enlivenObjectEnlivables(e,n,function(){t&&t(new fabric.Eraser(r,n,!0))})})};var s=fabric.Canvas.prototype._renderOverlay;fabric.util.object.extend(fabric.Canvas.prototype,{isErasing:function(){return this.isDrawingMode&&this.freeDrawingBrush&&"eraser"===this.freeDrawingBrush.type&&this.freeDrawingBrush._isErasing},_renderOverlay:function(e){s.call(this,e),this.isErasing()&&!this.freeDrawingBrush.inverted&&this.freeDrawingBrush._render()}}),fabric.EraserBrush=fabric.util.createClass(fabric.PencilBrush,{type:"eraser",inverted:!1,_isErasing:!1,_isErasable:function(e){return!1!==e.erasable},_prepareCollectionTraversal:function(e,t,r){e.forEachObject(function(n){n.forEachObject&&"deep"===n.erasable?this._prepareCollectionTraversal(n,t,r):!this.inverted&&n.erasable&&n.visible?(n.visible=!1,e.dirty=!0,r.visibility.push(n),r.collection.push(e)):this.inverted&&n.visible&&(n.erasable&&n.eraser?(n.eraser.inverted=!0,n.dirty=!0,e.dirty=!0,r.eraser.push(n),r.collection.push(e)):(n.visible=!1,e.dirty=!0,r.visibility.push(n),r.collection.push(e)))},this)},preparePattern:function(){this._patternCanvas||(this._patternCanvas=fabric.util.createCanvasElement());var e=this._patternCanvas;e.width=this.canvas.width,e.height=this.canvas.height;var t=e.getContext("2d");if(this.canvas._isRetinaScaling()){var r=this.canvas.getRetinaScaling();this.canvas.__initRetinaScaling(r,e,t)}var n=this.canvas.backgroundImage,i=n&&this._isErasable(n),o=this.canvas.overlayImage,a=o&&this._isErasable(o);if(!this.inverted&&(n&&!i||this.canvas.backgroundColor))i&&(this.canvas.backgroundImage=void 0),this.canvas._renderBackground(t),i&&(this.canvas.backgroundImage=n);else if(this.inverted&&n&&i){var l=this.canvas.backgroundColor;this.canvas.backgroundColor=void 0,this.canvas._renderBackground(t),this.canvas.backgroundColor=l}t.save(),t.transform.apply(t,this.canvas.viewportTransform);var c={visibility:[],eraser:[],collection:[]};if(this._prepareCollectionTraversal(this.canvas,t,c),this.canvas._renderObjects(t,this.canvas._objects),c.visibility.forEach(function(e){e.visible=!0}),c.eraser.forEach(function(e){e.eraser.inverted=!1,e.dirty=!0}),c.collection.forEach(function(e){e.dirty=!0}),t.restore(),!this.inverted&&(o&&!a||this.canvas.overlayColor))a&&(this.canvas.overlayImage=void 0),s.call(this.canvas,t),a&&(this.canvas.overlayImage=o);else if(this.inverted&&o&&a){l=this.canvas.overlayColor;this.canvas.overlayColor=void 0,s.call(this.canvas,t),this.canvas.overlayColor=l}},_setBrushStyles:function(e){this.callSuper("_setBrushStyles",e),e.strokeStyle="black"},_saveAndTransform:function(e){this.callSuper("_saveAndTransform",e),this._setBrushStyles(e),e.globalCompositeOperation=e===this.canvas.getContext()?"destination-out":"source-over"},needsFullRender:function(){return!0},onMouseDown:function(e,t){this.canvas._isMainEvent(t.e)&&(this._prepareForDrawing(e),this._captureDrawingPath(e),this.preparePattern(),this._isErasing=!0,this.canvas.fire("erasing:start"),this._render())},_render:function(){var e;this.inverted||(e=this.canvas.getContext(),this.callSuper("_render",e)),e=this.canvas.contextTop,this.canvas.clearContext(e),this.callSuper("_render",e),e.save();var t=1/this.canvas.getRetinaScaling();e.scale(t,t),e.globalCompositeOperation="source-in",e.drawImage(this._patternCanvas,0,0),e.restore()},createPath:function(e){var t=this.callSuper("createPath",e);return t.globalCompositeOperation=this.inverted?"source-over":"destination-out",t.stroke=this.inverted?"white":"black",t},applyClipPathToPath:function(e,t,r){var n=fabric.util.invertTransform(e.calcTransformMatrix()),i=t.calcTransformMatrix(),o=t.absolutePositioned?n:fabric.util.multiplyTransformMatrices(n,r);return t.absolutePositioned=!1,fabric.util.applyTransformToObject(t,fabric.util.multiplyTransformMatrices(o,i)),e.clipPath=e.clipPath?fabric.util.mergeClipPaths(t,e.clipPath):t,e},clonePathWithClipPath:function(e,t,r){var n=t.calcTransformMatrix(),i=t.clipPath,o=this;e.clone(function(e){i.clone(function(t){r(o.applyClipPathToPath(e,t,n))},["absolutePositioned","inverted"])})},_addPathToObjectEraser:function(e,t){var r=this;if(e.forEachObject&&"deep"===e.erasable){var n=e._objects.filter(function(e){return e.erasable});n.length>0&&e.clipPath?this.clonePathWithClipPath(t,e,function(e){n.forEach(function(t){r._addPathToObjectEraser(t,e)})}):n.length>0&&n.forEach(function(e){r._addPathToObjectEraser(e,t)})}else{var i=e.eraser;i||(i=new fabric.Eraser,e.eraser=i),t.clone(function(t){var n=fabric.util.multiplyTransformMatrices(fabric.util.invertTransform(e.calcTransformMatrix()),t.calcTransformMatrix());fabric.util.applyTransformToObject(t,n),i.addWithUpdate(t),e.set("dirty",!0),e.fire("erasing:end",{path:t}),e.group&&Array.isArray(r.__subTargets)&&r.__subTargets.push(e)})}},applyEraserToCanvas:function(e){var t=this.canvas,r={};return["backgroundImage","overlayImage"].forEach(function(n){var i=t[n];i&&i.erasable&&(this._addPathToObjectEraser(i,e),r[n]=i)},this),r},_finalizeAndAddPath:function(){var e=this.canvas.contextTop,t=this.canvas;e.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate)),t.clearContext(t.contextTop),this._isErasing=!1;var r=this._points&&this._points.length>1?this.convertPointsToSVGPath(this._points):null;if(!r||this._isEmptySVGPath(r))return t.fire("erasing:end"),void t.requestRenderAll();var n=this.createPath(r);n.setCoords(),t.fire("before:path:created",{path:n});var i=this.applyEraserToCanvas(n),o=this;this.__subTargets=[];var a=[];t.forEachObject(function(e){e.erasable&&e.intersectsWithObject(n,!0,!0)&&(o._addPathToObjectEraser(e,n),a.push(e))}),t.fire("erasing:end",{path:n,targets:a,subTargets:this.__subTargets,drawables:i}),delete this.__subTargets,t.requestRenderAll(),this._resetShadow(),t.fire("path:created",{path:n})}})}(),Cl.enableBoundaryChecking(!1);const kR=class t{constructor(t){if(dl(this,"tools",{}),dl(this,"fabric",null),t.sentryDsn&&function(e){const t={...e};Ed(t,"react"),zh(t)}({dsn:t.sentryDsn}),function(e,t){void 0===t&&(t={});var r=t.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===r&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}('/*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/.pi *,.pi :after,.pi :before{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity));border-style:solid;border-width:0;box-sizing:border-box}.pi :after,.pi :before{--tw-content:""}.pi hr{border-top-width:1px;color:inherit;height:0}.pi abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6{font-size:inherit;font-weight:inherit}.pi a{color:inherit;text-decoration:inherit}.pi b,.pi strong{font-weight:bolder}.pi code,.pi kbd,.pi pre,.pi samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.pi small{font-size:80%}.pi sub,.pi sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.pi sub{bottom:-.25em}.pi sup{top:-.5em}.pi table{border-collapse:collapse;border-color:inherit;text-indent:0}.pi button,.pi input,.pi optgroup,.pi select,.pi textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}.pi button,.pi select{text-transform:none}.pi [type=button],.pi [type=reset],.pi [type=submit],.pi button{-webkit-appearance:button;background-color:transparent;background-image:none}.pi :-moz-focusring{outline:auto}.pi :-moz-ui-invalid{box-shadow:none}.pi progress{vertical-align:baseline}.pi ::-webkit-inner-spin-button,.pi ::-webkit-outer-spin-button{height:auto}.pi [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.pi ::-webkit-search-decoration{-webkit-appearance:none}.pi ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.pi summary{display:list-item}.pi blockquote,.pi dd,.pi dl,.pi figure,.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6,.pi hr,.pi p,.pi pre{margin:0}.pi fieldset{margin:0;padding:0}.pi legend{padding:0}.pi menu,.pi ol,.pi ul{list-style:none;margin:0;padding:0}.pi textarea{resize:vertical}.pi input::-moz-placeholder,.pi textarea::-moz-placeholder{color:#9ca3af;opacity:1}.pi input::placeholder,.pi textarea::placeholder{color:#9ca3af;opacity:1}.pi [role=button],.pi button{cursor:pointer}.pi :disabled{cursor:default}.pi audio,.pi canvas,.pi embed,.pi iframe,.pi img,.pi object,.pi svg,.pi video{display:block;vertical-align:middle}.pi img,.pi video{height:auto;max-width:100%}.pi [hidden]{display:none}.pi *,.pi :after,.pi :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi ::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi .\\!container{width:100%!important}.pi .container{width:100%}@media (min-width:640px){.pi .\\!container{max-width:640px!important}.pi .container{max-width:640px}}@media (min-width:768px){.pi .\\!container{max-width:768px!important}.pi .container{max-width:768px}}@media (min-width:1024px){.pi .\\!container{max-width:1024px!important}.pi .container{max-width:1024px}}@media (min-width:1280px){.pi .\\!container{max-width:1280px!important}.pi .container{max-width:1280px}}@media (min-width:1536px){.pi .\\!container{max-width:1536px!important}.pi .container{max-width:1536px}}.pi .sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border-width:0;white-space:nowrap}.pi .pointer-events-none{pointer-events:none}.pi .pointer-events-auto{pointer-events:auto}.pi .\\!visible{visibility:visible!important}.pi .visible{visibility:visible}.pi .invisible{visibility:hidden}.pi .collapse{visibility:collapse}.pi .static{position:static}.pi .fixed{position:fixed}.pi .absolute{position:absolute}.pi .relative{position:relative}.pi .inset-0{top:0;right:0;bottom:0;left:0}.pi .inset-x-0{left:0;right:0}.pi .-bottom-10{bottom:-10px}.pi .-bottom-20{bottom:-20px}.pi .-bottom-5{bottom:-5px}.pi .-left-5{left:-5px}.pi .-left-8{left:-8px}.pi .-left-80{left:-80px}.pi .-right-5{right:-5px}.pi .-top-144{top:-144px}.pi .-top-40{top:-40px}.pi .-top-5{top:-5px}.pi .bottom-0{bottom:0}.pi .bottom-20{bottom:20px}.pi .left-0{left:0}.pi .left-1\\/2{left:50%}.pi .left-20{left:20px}.pi .right-0{right:0}.pi .right-16{right:16px}.pi .right-2{right:2px}.pi .right-20{right:20px}.pi .right-4{right:4px}.pi .top-0{top:0}.pi .top-1\\/2{top:50%}.pi .top-2{top:2px}.pi .isolate{isolation:isolate}.pi .z-10{z-index:10}.pi .z-20{z-index:20}.pi .z-50{z-index:50}.pi .z-cropzone{z-index:10}.pi .z-loading-indicator{z-index:50}.pi .z-modal{z-index:110}.pi .z-navbar{z-index:40}.pi .z-obj-box{z-index:20}.pi .z-popover{z-index:130}.pi .z-toast{z-index:160}.pi .z-tool-overlay{z-index:30}.pi .z-tooltip{z-index:150}.pi .z-tray{z-index:120}.pi .m-auto{margin:auto}.pi .mx-20{margin-left:20px;margin-right:20px}.pi .mx-8{margin-left:8px;margin-right:8px}.pi .mx-auto{margin-left:auto;margin-right:auto}.pi .my-20{margin-bottom:20px;margin-top:20px}.pi .my-4{margin-bottom:4px;margin-top:4px}.pi .my-6{margin-bottom:6px;margin-top:6px}.pi .my-8{margin-bottom:8px;margin-top:8px}.pi .my-auto{margin-bottom:auto;margin-top:auto}.pi .-ml-1{margin-left:-1px}.pi .-ml-10{margin-left:-10px}.pi .-ml-12{margin-left:-12px}.pi .-ml-3{margin-left:-3px}.pi .-ml-4{margin-left:-4px}.pi .-ml-6{margin-left:-6px}.pi .-mr-4{margin-right:-4px}.pi .-mr-8{margin-right:-8px}.pi .mb-1{margin-bottom:1px}.pi .mb-10{margin-bottom:10px}.pi .mb-16{margin-bottom:16px}.pi .mb-2{margin-bottom:2px}.pi .mb-20{margin-bottom:20px}.pi .mb-24{margin-bottom:24px}.pi .mb-4{margin-bottom:4px}.pi .mb-6{margin-bottom:6px}.pi .mb-8{margin-bottom:8px}.pi .ml-10{margin-left:10px}.pi .ml-12{margin-left:12px}.pi .ml-4{margin-left:4px}.pi .ml-6{margin-left:6px}.pi .ml-8{margin-left:8px}.pi .ml-auto{margin-left:auto}.pi .mr-10{margin-right:10px}.pi .mr-16{margin-right:16px}.pi .mr-20{margin-right:20px}.pi .mr-4{margin-right:4px}.pi .mr-5{margin-right:5px}.pi .mr-6{margin-right:6px}.pi .mr-8{margin-right:8px}.pi .mr-auto{margin-right:auto}.pi .mt-0{margin-top:0}.pi .mt-10{margin-top:10px}.pi .mt-14{margin-top:14px}.pi .mt-20{margin-top:20px}.pi .mt-24{margin-top:24px}.pi .mt-4{margin-top:4px}.pi .mt-6{margin-top:6px}.pi .box-content{box-sizing:content-box}.pi .block{display:block}.pi .inline-block{display:inline-block}.pi .inline{display:inline}.pi .flex{display:flex}.pi .inline-flex{display:inline-flex}.pi .grid{display:grid}.pi .contents{display:contents}.pi .hidden{display:none}.pi .aspect-square{aspect-ratio:1/1}.pi .h-1{height:1px}.pi .h-12{height:12px}.pi .h-128{height:128px}.pi .h-14{height:14px}.pi .h-16{height:16px}.pi .h-18{height:18px}.pi .h-2{height:2px}.pi .h-2\\/4{height:50%}.pi .h-20{height:20px}.pi .h-22{height:22px}.pi .h-24{height:24px}.pi .h-26{height:26px}.pi .h-28{height:28px}.pi .h-3{height:3px}.pi .h-30{height:30px}.pi .h-32{height:32px}.pi .h-36{height:36px}.pi .h-38{height:2.375rem}.pi .h-4{height:4px}.pi .h-40{height:40px}.pi .h-42{height:42px}.pi .h-48{height:48px}.pi .h-50{height:50px}.pi .h-56{height:56px}.pi .h-6{height:6px}.pi .h-60{height:60px}.pi .h-64{height:64px}.pi .h-68{height:68px}.pi .h-8{height:8px}.pi .h-80{height:80px}.pi .h-84{height:84px}.pi .h-92{height:92px}.pi .h-\\[54px\\]{height:54px}.pi .h-font{height:1em}.pi .h-full{height:100%}.pi .h-px{height:1px}.pi .h-screen{height:100dvh}.pi .max-h-100{max-height:6.25rem}.pi .max-h-\\[calc\\(100\\%-40px\\)\\]{max-height:calc(100% - 40px)}.pi .max-h-\\[calc\\(100vh-90px\\)\\]{max-height:calc(100vh - 90px)}.pi .max-h-dialog{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .max-h-full{max-height:100%}.pi .max-h-inherit{max-height:inherit}.pi .max-h-tray{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .min-h-24{min-height:24px}.pi .min-h-30{min-height:30px}.pi .min-h-36{min-height:36px}.pi .min-h-42{min-height:42px}.pi .min-h-50{min-height:50px}.pi .min-h-60{min-height:60px}.pi .min-h-86{min-height:86px}.pi .\\!w-auto{width:auto!important}.pi .w-1\\/2{width:50%}.pi .w-110{width:110px}.pi .w-12{width:12px}.pi .w-1280{width:80rem}.pi .w-14{width:14px}.pi .w-144{width:144px}.pi .w-16{width:16px}.pi .w-18{width:18px}.pi .w-2{width:2px}.pi .w-20{width:20px}.pi .w-22{width:22px}.pi .w-224{width:224px}.pi .w-24{width:24px}.pi .w-256{width:256px}.pi .w-26{width:26px}.pi .w-28{width:28px}.pi .w-280{width:17.5rem}.pi .w-30{width:30px}.pi .w-32{width:32px}.pi .w-320{width:320px}.pi .w-36{width:36px}.pi .w-38{width:2.375rem}.pi .w-384{width:384px}.pi .w-40{width:40px}.pi .w-42{width:42px}.pi .w-440{width:27.5rem}.pi .w-46{width:2.875rem}.pi .w-50{width:50px}.pi .w-56{width:56px}.pi .w-60{width:60px}.pi .w-620{width:38.75rem}.pi .w-64{width:64px}.pi .w-68{width:68px}.pi .w-780{width:48.75rem}.pi .w-8{width:8px}.pi .w-80{width:80px}.pi .w-850{width:53.125rem}.pi .w-96{width:96px}.pi .w-\\[4ch\\]{width:4ch}.pi .w-auto{width:auto}.pi .w-font{width:1em}.pi .w-full{width:100%}.pi .w-max{width:-moz-max-content;width:max-content}.pi .w-min{width:-moz-min-content;width:min-content}.pi .w-px{width:1px}.pi .w-screen{width:100vw}.pi .min-w-0{min-width:0}.pi .min-w-128{min-width:128px}.pi .min-w-180{min-width:11.25rem}.pi .min-w-192{min-width:192px}.pi .min-w-288{min-width:288px}.pi .min-w-30{min-width:30px}.pi .min-w-4{min-width:4px}.pi .min-w-42{min-width:42px}.pi .min-w-92{min-width:92px}.pi .min-w-min{min-width:-moz-min-content;min-width:min-content}.pi .max-w-112{max-width:112px}.pi .max-w-240{max-width:240px}.pi .max-w-288{max-width:288px}.pi .max-w-320{max-width:320px}.pi .max-w-375{max-width:375px}.pi .max-w-500{max-width:31.25rem}.pi .max-w-\\[90\\%\\]{max-width:90%}.pi .max-w-\\[calc\\(100\\%-40px\\)\\]{max-width:calc(100% - 40px)}.pi .max-w-\\[calc\\(100vw-90px\\)\\]{max-width:calc(100vw - 90px)}.pi .max-w-dialog{max-width:calc(var(--be-viewport-width, 100vw)*.9)}.pi .max-w-full{max-width:100%}.pi .max-w-max{max-width:-moz-max-content;max-width:max-content}.pi .flex-\\[1_1_60px\\]{flex:1 1 60px}.pi .flex-auto{flex:1 1 auto}.pi .flex-shrink-0,.pi .shrink-0{flex-shrink:0}.pi .origin-\\[0_55\\%\\]{transform-origin:0 55%}.pi .origin-\\[100\\%\\]{transform-origin:100%}.pi .-translate-x-1\\/2{--tw-translate-x:-50%}.pi .-translate-x-1\\/2,.pi .-translate-y-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .-translate-y-1\\/2{--tw-translate-y:-50%}.pi .rotate-0{--tw-rotate:0deg}.pi .rotate-0,.pi .rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-180{--tw-rotate:180deg}.pi .rotate-45{--tw-rotate:45deg}.pi .rotate-45,.pi .rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-90{--tw-rotate:90deg}.pi .scale-y-\\[0\\.6\\]{--tw-scale-y:.6}.pi .scale-y-\\[0\\.6\\],.pi .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .cursor-default{cursor:default}.pi .cursor-move{cursor:move}.pi .cursor-nesw-resize{cursor:nesw-resize}.pi .cursor-not-allowed{cursor:not-allowed}.pi .cursor-nwse-resize{cursor:nwse-resize}.pi .cursor-pointer{cursor:pointer}.pi .cursor-se-resize{cursor:se-resize}.pi .cursor-sw-resize{cursor:sw-resize}.pi .touch-none{touch-action:none}.pi .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pi .resize{resize:both}.pi .appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.pi .grid-cols-5-min-content{grid-template-columns:repeat(5,min-content)}.pi .flex-row{flex-direction:row}.pi .flex-col{flex-direction:column}.pi .flex-col-reverse{flex-direction:column-reverse}.pi .flex-wrap{flex-wrap:wrap}.pi .flex-nowrap{flex-wrap:nowrap}.pi .items-start{align-items:flex-start}.pi .items-end{align-items:flex-end}.pi .items-center{align-items:center}.pi .items-stretch{align-items:stretch}.pi .justify-start{justify-content:flex-start}.pi .justify-center{justify-content:center}.pi .justify-between{justify-content:space-between}.pi .gap-10{gap:10px}.pi .gap-14{gap:14px}.pi .gap-16{gap:16px}.pi .gap-18{gap:18px}.pi .gap-20{gap:20px}.pi .gap-36{gap:36px}.pi .gap-4{gap:4px}.pi .gap-40{gap:40px}.pi .gap-6{gap:6px}.pi .gap-8{gap:8px}.pi .space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(10px*var(--tw-space-y-reverse));margin-top:calc(10px*(1 - var(--tw-space-y-reverse)))}.pi .overflow-auto{overflow:auto}.pi .overflow-hidden{overflow:hidden}.pi .overflow-x-auto{overflow-x:auto}.pi .overflow-y-auto{overflow-y:auto}.pi .overflow-x-hidden{overflow-x:hidden}.pi .overflow-y-hidden{overflow-y:hidden}.pi .overscroll-contain{overscroll-behavior:contain}.pi .truncate{overflow:hidden;white-space:nowrap}.pi .overflow-ellipsis,.pi .text-ellipsis,.pi .truncate{text-overflow:ellipsis}.pi .whitespace-normal{white-space:normal}.pi .whitespace-nowrap{white-space:nowrap}.pi .break-words{overflow-wrap:break-word}.pi .rounded{border-radius:4px}.pi .rounded-2xl{border-radius:16px}.pi .rounded-3xl{border-radius:24px}.pi .rounded-button{border-radius:var(--be-button-radius,.25rem)}.pi .rounded-full{border-radius:9999px}.pi .rounded-input{border-radius:var(--be-input-radius,.25rem)}.pi .rounded-lg{border-radius:8px}.pi .rounded-md{border-radius:6px}.pi .rounded-none{border-radius:0}.pi .rounded-panel{border-radius:var(--be-panel-radius,.25rem)}.pi .rounded-xl{border-radius:12px}.pi .rounded-l{border-bottom-left-radius:4px;border-top-left-radius:4px}.pi .rounded-l-full{border-bottom-left-radius:9999px;border-top-left-radius:9999px}.pi .rounded-l-input{border-bottom-left-radius:var(--be-input-radius,.25rem);border-top-left-radius:var(--be-input-radius,.25rem)}.pi .rounded-l-none{border-bottom-left-radius:0;border-top-left-radius:0}.pi .rounded-r-full{border-bottom-right-radius:9999px;border-top-right-radius:9999px}.pi .rounded-r-input{border-bottom-right-radius:var(--be-input-radius,.25rem);border-top-right-radius:var(--be-input-radius,.25rem)}.pi .rounded-r-none{border-bottom-right-radius:0;border-top-right-radius:0}.pi .rounded-t{border-top-left-radius:4px;border-top-right-radius:4px}.pi .rounded-bl-none{border-bottom-left-radius:0}.pi .rounded-br-none{border-bottom-right-radius:0}.pi .rounded-tl-none{border-top-left-radius:0}.pi .rounded-tr-none{border-top-right-radius:0}.pi .border{border-width:1px}.pi .border-2{border-width:2px}.pi .border-4{border-width:4px}.pi .border-\\[3px\\]{border-width:3px}.pi .border-y{border-top-width:1px}.pi .border-b,.pi .border-y{border-bottom-width:1px}.pi .border-b-4{border-bottom-width:4px}.pi .border-l{border-left-width:1px}.pi .border-l-4{border-left-width:4px}.pi .border-r{border-right-width:1px}.pi .border-r-4{border-right-width:4px}.pi .border-t{border-top-width:1px}.pi .border-t-4{border-top-width:4px}.pi .border-dotted{border-style:dotted}.pi .border-none{border-style:none}.pi .border-background{--tw-border-opacity:1;border-color:rgb(var(--be-background)/var(--tw-border-opacity))}.pi .border-bg-alt{--tw-border-opacity:1;border-color:rgb(var(--be-background-alt)/var(--tw-border-opacity))}.pi .border-chip{--tw-border-opacity:1;border-color:rgb(var(--be-background-chip)/var(--tw-border-opacity))}.pi .border-danger{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .border-danger\\/50{border-color:#ef444480}.pi .border-divider{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .border-paper{--tw-border-opacity:1;border-color:rgb(var(--be-paper)/var(--tw-border-opacity))}.pi .border-positive\\/50{border-color:#22c55e80}.pi .border-primary{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .border-primary\\/50{border-color:rgb(var(--be-primary)/.5)}.pi .border-text-muted{border-color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .border-transparent{border-color:transparent}.pi .border-white{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.pi .border-white\\/50{border-color:#ffffff80}.pi .border-b-bg{--tw-border-opacity:1;border-bottom-color:rgb(var(--be-background)/var(--tw-border-opacity))}.pi .border-b-transparent{border-bottom-color:transparent}.pi .border-r-transparent{border-right-color:transparent}.pi .bg{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-alt{--tw-bg-opacity:1;background-color:rgb(var(--be-background-alt)/var(--tw-bg-opacity))}.pi .bg-background{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-background\\/70{background-color:rgb(var(--be-background)/.7)}.pi .bg-background\\/80{background-color:rgb(var(--be-background)/.8)}.pi .bg-black\\/50{background-color:#00000080}.pi .bg-black\\/80{background-color:#000c}.pi .bg-chip{--tw-bg-opacity:1;background-color:rgb(var(--be-background-chip)/var(--tw-bg-opacity))}.pi .bg-controls{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-danger{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .bg-danger-lighter{--tw-bg-opacity:1;background-color:rgb(254 202 202/var(--tw-bg-opacity))}.pi .bg-divider{background-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .bg-fg-base\\/4{background-color:rgb(var(--be-foreground-base)/4%)}.pi .bg-focus{background-color:rgb(var(--be-foreground-base)/var(--be-focus-opacity))}.pi .bg-inherit{background-color:inherit}.pi .bg-paper{--tw-bg-opacity:1;background-color:rgb(var(--be-paper)/var(--tw-bg-opacity))}.pi .bg-positive{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.pi .bg-positive-lighter{--tw-bg-opacity:1;background-color:rgb(187 247 208/var(--tw-bg-opacity))}.pi .bg-primary{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .bg-primary-dark{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .bg-primary-light{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-light)/var(--tw-bg-opacity))}.pi .bg-primary\\/focus{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .bg-primary\\/selected{background-color:rgb(var(--be-primary)/var(--be-selected-opacity))}.pi .bg-slider-disabled{--tw-bg-opacity:1;background-color:rgb(189 189 189/var(--tw-bg-opacity))}.pi .bg-slider-disabled\\/60{background-color:#bdbdbd99}.pi .bg-toast{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-transparent{background-color:transparent}.pi .bg-warning{--tw-bg-opacity:1;background-color:rgb(243 164 50/var(--tw-bg-opacity))}.pi .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .bg-white\\/50{background-color:#ffffff80}.pi .bg-opacity-95{--tw-bg-opacity:.95}.pi .bg-no-repeat{background-repeat:no-repeat}.pi .fill-current{fill:currentColor}.pi .fill-transparent{fill:transparent}.pi .stroke-current{stroke:currentColor}.pi .object-contain{-o-object-fit:contain;object-fit:contain}.pi .object-cover{-o-object-fit:cover;object-fit:cover}.pi .p-0{padding:0}.pi .p-10{padding:10px}.pi .p-14{padding:14px}.pi .p-16{padding:16px}.pi .p-18{padding:18px}.pi .p-2{padding:2px}.pi .p-20{padding:20px}.pi .p-4{padding:4px}.pi .p-40{padding:40px}.pi .p-6{padding:6px}.pi .p-8{padding:8px}.pi .px-10{padding-left:10px;padding-right:10px}.pi .px-12{padding-left:12px;padding-right:12px}.pi .px-14{padding-left:14px;padding-right:14px}.pi .px-16{padding-left:16px;padding-right:16px}.pi .px-18{padding-left:18px;padding-right:18px}.pi .px-20{padding-left:20px;padding-right:20px}.pi .px-22{padding-left:22px;padding-right:22px}.pi .px-24{padding-left:24px;padding-right:24px}.pi .px-26{padding-left:26px;padding-right:26px}.pi .px-32{padding-left:32px;padding-right:32px}.pi .px-4{padding-left:4px;padding-right:4px}.pi .px-5vw{padding-left:5vw;padding-right:5vw}.pi .px-6{padding-left:6px;padding-right:6px}.pi .px-8{padding-left:8px;padding-right:8px}.pi .py-10{padding-bottom:10px;padding-top:10px}.pi .py-12{padding-bottom:12px;padding-top:12px}.pi .py-14{padding-bottom:14px;padding-top:14px}.pi .py-2{padding-bottom:2px;padding-top:2px}.pi .py-20{padding-bottom:20px;padding-top:20px}.pi .py-3{padding-bottom:3px;padding-top:3px}.pi .py-4{padding-bottom:4px;padding-top:4px}.pi .py-5{padding-bottom:5px;padding-top:5px}.pi .py-6{padding-bottom:6px;padding-top:6px}.pi .py-8{padding-bottom:8px;padding-top:8px}.pi .py-\\[9px\\]{padding-bottom:9px;padding-top:9px}.pi .pb-10{padding-bottom:10px}.pi .pb-12{padding-bottom:12px}.pi .pb-14{padding-bottom:14px}.pi .pb-16{padding-bottom:16px}.pi .pb-18{padding-bottom:18px}.pi .pb-20{padding-bottom:20px}.pi .pb-4{padding-bottom:4px}.pi .pb-8{padding-bottom:8px}.pi .pb-safe-area{padding-bottom:env(safe-area-inset-bottom)}.pi .pl-10{padding-left:10px}.pi .pl-12{padding-left:12px}.pi .pl-14{padding-left:14px}.pi .pl-16{padding-left:16px}.pi .pl-18{padding-left:18px}.pi .pl-28{padding-left:28px}.pi .pl-46{padding-left:2.875rem}.pi .pl-54{padding-left:3.375rem}.pi .pl-8{padding-left:8px}.pi .pr-10{padding-right:10px}.pi .pr-12{padding-right:12px}.pi .pr-18{padding-right:18px}.pi .pr-24{padding-right:24px}.pi .pr-28{padding-right:28px}.pi .pr-46{padding-right:2.875rem}.pi .pr-54{padding-right:3.375rem}.pi .pr-6{padding-right:6px}.pi .pr-8{padding-right:8px}.pi .pt-10{padding-top:10px}.pi .pt-12{padding-top:12px}.pi .pt-14{padding-top:14px}.pi .pt-16{padding-top:16px}.pi .pt-20{padding-top:20px}.pi .pt-24{padding-top:24px}.pi .pt-4{padding-top:4px}.pi .pt-40{padding-top:40px}.pi .pt-6{padding-top:6px}.pi .text-left{text-align:left}.pi .text-center{text-align:center}.pi .text-right{text-align:right}.pi .align-middle{vertical-align:middle}.pi .text-base{font-size:16px;line-height:24px}.pi .text-lg{font-size:18px;line-height:28px}.pi .text-sm{font-size:14px;line-height:20px}.pi .text-xl{font-size:20px;line-height:28px}.pi .text-xs{font-size:12px;line-height:16px}.pi .font-bold{font-weight:700}.pi .font-medium{font-weight:500}.pi .font-semibold{font-weight:600}.pi .uppercase{text-transform:uppercase}.pi .capitalize{text-transform:capitalize}.pi .italic{font-style:italic}.pi .tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.pi .leading-5{line-height:1.25rem}.pi .leading-none{line-height:1}.pi .tracking-wide{letter-spacing:.025em}.pi .\\!text{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))!important}.pi .text{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.pi .text-black\\/30{color:#0000004d}.pi .text-danger{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.pi .text-danger-darker{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.pi .text-disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .text-link{--tw-text-opacity:1;color:rgb(var(--be-link-color,var(--be-primary))/var(--tw-text-opacity))}.pi .text-main{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .text-muted{color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .text-on-primary{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .text-positive{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity))}.pi .text-positive-darker{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.pi .text-primary{--tw-text-opacity:1;color:rgb(var(--be-primary)/var(--tw-text-opacity))}.pi .text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.pi .underline{text-decoration-line:underline}.pi .no-underline{text-decoration-line:none}.pi .caret-transparent{caret-color:transparent}.pi .opacity-0{opacity:0}.pi .opacity-100{opacity:1}.pi .opacity-70{opacity:.7}.pi .opacity-80{opacity:.8}.pi .opacity-90{opacity:.9}.pi .shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.pi .shadow,.pi .shadow-2xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0,0,0,.25);--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color)}.pi .shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.pi .shadow-lg,.pi .shadow-md{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.pi .shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.pi .shadow-sm,.pi .shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.pi .outline-none{outline:2px solid transparent;outline-offset:2px}.pi .outline{outline-color:rgb(var(--be-primary-lighter)/1);outline-style:solid;outline-width:2px}.pi .ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .ring-inset{--tw-ring-inset:inset}.pi .blur{--tw-blur:blur(8px)}.pi .blur,.pi .grayscale{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .grayscale{--tw-grayscale:grayscale(100%)}.pi .invert{--tw-invert:invert(100%)}.pi .invert,.pi .sepia{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .sepia{--tw-sepia:sepia(100%)}.pi .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .backdrop-blur-sm{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.pi .transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-button{transition-duration:.15s;transition-property:background-color,box-shadow,border-color,color;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-shadow{transition-duration:.15s;transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-width{transition-duration:.15s;transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .duration-100{transition-duration:.1s}.pi .duration-200{transition-duration:.2s}.pi .will-change-transform{will-change:transform}.pi .icon-2xs{font-size:.75rem}.pi .icon-xs{font-size:1rem}.pi .icon-sm{font-size:1.25rem}.pi .icon-md{font-size:1.5rem}.pi .icon-lg{font-size:2.1875rem}.pi .icon-xl{font-size:2.6875rem}.pi .no-tap-highlight{-webkit-tap-highlight-color:transparent}@media only screen and (min-device-width:768px){.pi .tiny-scrollbar{scrollbar-color:rgba(0,0,0,.2) transparent;scrollbar-width:thin}.pi .tiny-scrollbar::-webkit-scrollbar{background-color:transparent;height:6px;width:6px}.pi .tiny-scrollbar::-webkit-scrollbar-thumb{background-color:rgb(var(--be-foreground-base)/.2);border-radius:10px}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:start{background:transparent}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:end{background:transparent}}.pi .hide-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.pi .hide-scrollbar::-webkit-scrollbar{background:transparent;display:none;height:0;width:0}.pi .svg-icon{display:inline-block;flex-shrink:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;fill:currentColor;transition-duration:.15s;transition-property:transform,fill;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .cropzone:not(.moving) .cropzone-transition{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .first-letter\\:capitalize:first-letter{text-transform:capitalize}.pi .file\\:mr-10::file-selector-button{margin-right:10px}.pi .file\\:h-24::file-selector-button{height:24px}.pi .file\\:rounded::file-selector-button{border-radius:4px}.pi .file\\:border-none::file-selector-button{border-style:none}.pi .file\\:bg-primary::file-selector-button{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .file\\:px-10::file-selector-button{padding-left:10px;padding-right:10px}.pi .file\\:text-sm::file-selector-button{font-size:14px;line-height:20px}.pi .file\\:font-semibold::file-selector-button{font-weight:600}.pi .file\\:text-on-primary::file-selector-button{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .before\\:z-10:before{content:var(--tw-content);z-index:10}.pi .before\\:block:before{content:var(--tw-content);display:block}.pi .before\\:h-12:before{content:var(--tw-content);height:12px}.pi .before\\:h-14:before{content:var(--tw-content);height:14px}.pi .before\\:h-18:before{content:var(--tw-content);height:18px}.pi .before\\:h-22:before{content:var(--tw-content);height:22px}.pi .before\\:h-28:before{content:var(--tw-content);height:28px}.pi .before\\:h-full:before{content:var(--tw-content);height:100%}.pi .before\\:w-12:before{content:var(--tw-content);width:12px}.pi .before\\:w-14:before{content:var(--tw-content);width:14px}.pi .before\\:w-18:before{content:var(--tw-content);width:18px}.pi .before\\:w-22:before{content:var(--tw-content);width:22px}.pi .before\\:w-28:before{content:var(--tw-content);width:28px}.pi .before\\:w-full:before{content:var(--tw-content);width:100%}.pi .before\\:translate-x-2:before{--tw-translate-x:2px}.pi .before\\:scale-10:before,.pi .before\\:translate-x-2:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .before\\:scale-10:before{--tw-scale-x:.1;--tw-scale-y:.1}.pi .before\\:rounded-3xl:before{border-radius:24px;content:var(--tw-content)}.pi .before\\:rounded-full:before{border-radius:9999px;content:var(--tw-content)}.pi .before\\:border:before{border-width:1px;content:var(--tw-content)}.pi .before\\:bg-primary:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .before\\:bg-white:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .before\\:opacity-0:before{content:var(--tw-content);opacity:0}.pi .before\\:transition:before{content:var(--tw-content);transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:transition-transform:before{content:var(--tw-content);transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:duration-200:before{content:var(--tw-content);transition-duration:.2s}.pi .after\\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.pi .after\\:absolute:after{content:var(--tw-content);position:absolute}.pi .after\\:inset-0:after{content:var(--tw-content);top:0;right:0;bottom:0;left:0}.pi .checked\\:border-danger:checked{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .checked\\:border-primary:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .checked\\:bg-danger:checked{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .checked\\:bg-primary:checked{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .checked\\:before\\:translate-x-14:checked:before{--tw-translate-x:14px}.pi .checked\\:before\\:translate-x-14:checked:before,.pi .checked\\:before\\:translate-x-20:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-20:checked:before{--tw-translate-x:20px}.pi .checked\\:before\\:translate-x-24:checked:before{--tw-translate-x:24px}.pi .checked\\:before\\:translate-x-24:checked:before,.pi .checked\\:before\\:translate-x-30:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-30:checked:before{--tw-translate-x:30px}.pi .checked\\:before\\:translate-x-36:checked:before{--tw-translate-x:36px}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before,.pi .checked\\:before\\:translate-x-36:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before{--tw-scale-x:.65;--tw-scale-y:.65}.pi .checked\\:before\\:border-white:checked:before{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.pi .checked\\:before\\:opacity-100:checked:before{content:var(--tw-content);opacity:1}.pi .focus-within\\:border-primary\\/60:focus-within{border-color:rgb(var(--be-primary)/.6)}.pi .focus-within\\:ring:focus-within{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-within\\:ring-primary\\/focus:focus-within{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .hover\\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .hover\\:border-chip\\/90:hover{border-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:border-danger:hover{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .hover\\:border-danger\\/90:hover{border-color:#ef4444e6}.pi .hover\\:border-paper\\/90:hover{border-color:rgb(var(--be-paper)/.9)}.pi .hover\\:border-positive:hover{--tw-border-opacity:1;border-color:rgb(34 197 94/var(--tw-border-opacity))}.pi .hover\\:border-primary:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .hover\\:border-primary-dark:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .hover\\:bg-chip\\/90:hover{background-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:bg-danger\\/4:hover{background-color:#ef44440a}.pi .hover\\:bg-danger\\/90:hover{background-color:#ef4444e6}.pi .hover\\:bg-fg-base\\/15:hover{background-color:rgb(var(--be-foreground-base)/15%)}.pi .hover\\:bg-hover:hover{background-color:rgb(var(--be-foreground-base)/var(--be-hover-opacity))}.pi .hover\\:bg-paper\\/90:hover{background-color:rgb(var(--be-paper)/.9)}.pi .hover\\:bg-positive\\/4:hover{background-color:#22c55e0a}.pi .hover\\:bg-primary-dark:hover{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .hover\\:bg-primary\\/4:hover{background-color:rgb(var(--be-primary)/4%)}.pi .hover\\:bg-primary\\/focus:hover{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .hover\\:bg-primary\\/hover:hover{background-color:rgb(var(--be-primary)/var(--be-hover-opacity))}.pi .hover\\:bg-white:hover{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .hover\\:bg-white\\/20:hover{background-color:#fff3}.pi .hover\\:bg-white\\/hover:hover{background-color:rgb(255 255 255/var(--be-hover-opacity))}.pi .hover\\:text-main:hover{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .hover\\:text-primary-dark:hover{--tw-text-opacity:1;color:rgb(var(--be-primary-dark)/var(--tw-text-opacity))}.pi .hover\\:underline:hover{text-decoration-line:underline}.pi .hover\\:shadow-md:hover{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .before\\:hover\\:bg-primary-dark:hover:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .hover\\:after\\:bg-black\\/5:hover:after{background-color:#0000000d;content:var(--tw-content)}.pi .checked\\:hover\\:border-primary-dark:hover:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .focus\\:border-danger\\/60:focus{border-color:#ef444499}.pi .focus\\:border-primary\\/60:focus{border-color:rgb(var(--be-primary)/.6)}.pi .focus\\:bg-primary:focus{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .focus\\:text-on-primary:focus{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.pi .focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus\\:ring-danger\\/focus:focus{--tw-ring-color:rgb(239 68 68/var(--be-focus-opacity))}.pi .focus\\:ring-primary\\/focus:focus{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus\\:after\\:bg-black\\/10:focus:after{background-color:#0000001a;content:var(--tw-content)}.pi .focus-visible\\:bg-primary\\/focus:focus-visible{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus-visible\\:outline:focus-visible{outline-color:rgb(var(--be-primary-lighter)/1);outline-style:solid;outline-width:2px}.pi .focus-visible\\:outline-primary-light:focus-visible{outline-color:rgb(var(--be-primary-light)/1)}.pi .focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-visible\\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.pi .disabled\\:pointer-events-none:disabled{pointer-events:none}.pi .disabled\\:cursor-default:disabled{cursor:default}.pi .disabled\\:border-disabled-bg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:border-disabled-fg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:border-transparent:disabled{border-color:transparent}.pi .disabled\\:border-white\\/70:disabled{border-color:#ffffffb3}.pi .disabled\\:border-r-transparent:disabled{border-right-color:transparent}.pi .disabled\\:bg-disabled:disabled{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:bg-transparent:disabled{background-color:transparent}.pi .disabled\\:text-disabled:disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:text-white\\/70:disabled{color:#ffffffb3}.pi .disabled\\:shadow-none:disabled{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .disabled\\:before\\:bg-disabled-fg:disabled:before{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity));content:var(--tw-content)}.pi :is(.dark .dark\\:bg-chip){--tw-bg-opacity:1;background-color:rgb(var(--be-background-chip)/var(--tw-bg-opacity))}.pi :is(.dark .dark\\:text-white\\/50){color:#ffffff80}.pi :is(.dark .dark\\:checked\\:border-primary-dark:checked){--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi :is(.dark .dark\\:checked\\:bg-primary-dark:checked){--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}@media (min-width:640px){.pi .sm\\:text-sm{font-size:14px;line-height:20px}}@media (min-width:768px){.pi .md\\:text-lg{font-size:18px;line-height:28px}}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-2:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-inset:focus-visible>.tree-label{--tw-ring-inset:inset}\n'),!t.selector)throw new Error('Pixie required "selector" option.');const r=document.querySelector(t.selector);r&&(r.classList.add("pi"),function(e){um=e,dm=e}(r),this.setConfig(t),vm.setState({editor:this}),_(r).render(e(i.StrictMode,{children:e(SR,{})})))}get state(){return ym()}get defaultConfig(){return t.defaultConfig}open(e={}){return new Promise(async t=>{var r;Object.keys(e).length?await this.resetEditor({...eg(e,{ui:{visible:!0},image:e.image||ym().config.image,state:e.state||ym().config.state,blankCanvasSize:e.blankCanvasSize||ym().config.blankCanvasSize})}):null!=(r=ym().config.ui)&&r.visible||ym().setConfig({ui:{visible:!0}}),t()})}close(){var e,t,r;null!=(e=ym().config.ui)&&e.visible&&(this.setConfig({ui:{visible:!1}}),null==(r=(t=ym().config).onClose)||r.call(t))}setConfig(e){ym().setConfig(e)}uploadAndAddImage(){return bm().import.uploadAndAddImage()}uploadAndReplaceMainImage(){return bm().import.uploadAndReplaceMainImage()}uploadAndOpenStateFile(){return bm().import.uploadAndOpenStateFile()}newCanvas(e,t,r){return bm().canvas.openNew(e,t,r)}getState(e){return JSON.stringify(Sm(e))}setState(e){return bm().import.loadState(e)}async setStateFromUrl(e){const t=await Cm(e);return bm().import.loadState(t)}openTool(e){km(e)}applyChanges(){ym().applyChanges()}cancelChanges(){ym().cancelChanges()}async resetEditor(e){await xm(e),await bm().canvas.loadInitialContent()}togglePanel(e,t){"objects"===e&&ym().togglePanel("history",!1),"history"===e&&ym().togglePanel("objects",!1),ym().togglePanel(e,t)}on(e,t){var r;null==(r=this.fabric)||r.on(e,t)}isDirty(){return ym().dirty}get(e){return this.tools[e]}notify(e){return Om(e)}static init(e){return new Promise(t=>{const r=e.onLoad;e.onLoad=e=>{null==r||r(e),t(e)},new this(e)})}};dl(kR,"defaultConfig",If),dl(kR,"version",Af);let AR=kR;function IR(e){if(!this.backgroundColor)return;const t=this._getNonTransformedDimensions(),r=-t.x/2,n=-t.y/2,i=t.x,o=t.y,a=this.backgroundColor;if("string"==typeof a||a instanceof CanvasGradient||a instanceof CanvasPattern)e.fillStyle=a,e.fillRect(r,n,i,o);else if("object"!=typeof a||!("type"in a)||"linear"!==a.type&&"radial"!==a.type){if("source"in a&&(a.source instanceof HTMLImageElement||a.source instanceof HTMLCanvasElement))if(a.repeat){const t=e.createPattern(a.source,a.repeat);t&&(e.fillStyle=t,e.fillRect(r,n,i,o))}else e.drawImage(a.source,r,n,i,o)}else{const t=function(e,t,r,n){var i,o;if("linear"===t.type){const i=e.createLinearGradient(r+t.coords.x1,n+t.coords.y1,r+t.coords.x2,n+t.coords.y2);return t.colorStops.forEach(e=>i.addColorStop(e.offset,e.color)),i}if("radial"===t.type){const a=e.createRadialGradient(r+t.coords.x1,n+t.coords.y1,null!==(i=t.coords.r1)&&void 0!==i?i:0,r+t.coords.x2,n+t.coords.y2,null!==(o=t.coords.r2)&&void 0!==o?o:0);return t.colorStops.forEach(e=>a.addColorStop(e.offset,e.color)),a}throw new Error("Unknown gradient type")}(e,a,r,n);e.fillStyle=t,e.fillRect(r,n,i,o)}this._removeShadow(e)}const ER="fm-pixie-editor";const FR=new class{constructor(){this._container=document.createElement("div"),this._instance=null,this._container.classList.add(ER),this._container.style.width="100%",this._container.style.height="85vh",this._container.style.minHeight="400px"}get className(){return`.${ER}`}get canvas(){var e,t;return null===(t=null===(e=this._instance)||void 0===e?void 0:e.state.canvasRef)||void 0===t?void 0:t.current}get tools(){var e;return null===(e=this._instance)||void 0===e?void 0:e.tools}isLoaded(){return!!this._instance}async _setConfig(e){var t;this._instance?await this._instance.resetEditor(e):this._instance=await AR.init(Object.assign(Object.assign({},e),{selector:this.className})),(t=this._instance).fabric?t.fabric.on("object:added",e=>{const t=e.target;t&&"text"===t.name&&(t._renderBackground=IR)}):console.warn("Pixie fabric instance is not available")}async show(e,t,r=t.firstChild){t.insertBefore(this._container,r),await this._setConfig(e),this._instance.open()}close(){var e;null===(e=this._container.parentNode)||void 0===e||e.removeChild(this._container)}};function TR(e,t){if(!e)return t;if(!t)return e;return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function OR(e,t){if(/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(t))return t;const r=function(e){const t="undefined"!=typeof __webpack_public_path__?__webpack_public_path__:"";if(e&&/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(e))return e;let r=TR(t,e||"");return!r||r.startsWith("/")||/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(r)||(r="/"+r),r}(e),n=TR(r,t);return!n||n.startsWith("/")||/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(n)?n:"/"+n}var PR,MR;!function(e){e.TOP="top",e.BOTTOM="bottom",e.HIDDEN=""}(PR||(PR={})),function(e){e.TOP="top",e.BOTTOM="bottom",e.HIDDEN=""}(MR||(MR={}));const RR=(e,t="image/png")=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function LR(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=()=>{var e;return r(null!==(e=n.error)&&void 0!==e?e:new Error("Failed to convert blob to data URL"))},n.readAsDataURL(e)})}const NR=({visible:r,onClose:n,file:o,onSave:a,onSaveCopy:s})=>{var l;const{t:c}=Yn(),u=i.useRef(null),d=Oo(),h=Ga(),{options:f,actions:p}=po(),{i18n:g}=Yn(),{config:m}=f,{setCurrentMenuFile:v}=p,{getFileData:y,resolveFileForEditByUrl:b}=h,[w,x]=i.useState(!1),[C,_]=i.useState(null),[S,k]=i.useState(""),[A,I]=i.useState(!1),[E,F]=i.useState(!1),[T,O]=i.useState(null),P=i.useRef(!1),R=i.useRef(),L=i.useRef(),N=i.useRef("saveCopy"),j=i.useRef(void 0);R.current=a,L.current=s,i.useEffect(()=>{o&&!P.current&&(async()=>{if(j.current!==o)if("object"!=typeof o){j.current=o,x(!0);try{if(o.startsWith("data:"))O({thumbnail:o,saveWithoutFolder:!0});else{const e=await b(o);j.current===o&&O(e)}}catch(e){console.error("Failed to load file for editor:",e),j.current===o&&(j.current=null),null==n||n()}finally{x(!1)}}else O(o)})()},[o,n,b]);const D=i.useCallback(async e=>{try{if("string"==typeof e.thumbnail&&e.thumbnail.startsWith("data:"))return e.thumbnail;const t=await y(e.id,!0);if(!t)throw new Error(c("Error loading image"));return new Promise(e=>{const r=new FileReader;r.onload=()=>e(r.result),r.readAsDataURL(t)})}catch(e){throw console.error("Error getting the image data:",e),e}},[y,c]);i.useEffect(()=>{if(!C&&r&&T){let e=!1;const t=async()=>{var t,r,i;x(!0);try{const t=await D(T);if(!t||"string"!=typeof t||""===t.trim())throw new Error("Invalid image data: empty or null");if(!t.startsWith("data:"))throw new Error("Invalid image data: not a valid data URL");const r=t.match(/^data:([^;]+);base64,(.+)$/);if(!r)throw new Error("Invalid image data: malformed data URL format");const[,n,i]=r;if(!n.startsWith("image/"))throw new Error(`Invalid image data: unsupported MIME type ${n}`);if(i.length<10)throw new Error("Invalid image data: base64 content too short");if(!/^[A-Za-z0-9+/]+=*$/.test(i))throw new Error("Invalid image data: corrupted base64 content");if(!e){_(t);const e=Ta(T,"image/png");k(e.mimeType)}}catch(o){e||(d.error({id:"IMAGE_DOWNLOAD_FAILED",innerException:o,message:c("Error loading image"),placement:"bottomRight",data:{itemId:null!==(t=null==T?void 0:T.id)&&void 0!==t?t:void 0,itemName:null!==(r=null==T?void 0:T.name)&&void 0!==r?r:void 0,folderId:null!==(i=null==T?void 0:T.folderId)&&void 0!==i?i:null,thumbnail:null==T?void 0:T.thumbnail}}),null==n||n())}finally{x(!1)}};return t(),()=>{e=!0}}},[T,D,C,n,c,r]);const z=i.useCallback(async(e,t,r)=>{var n;let i=await function(e,t){if("json"===e)return new Blob([t],{type:"application/json"});if("svg"===e)return new Blob([t],{type:"image/svg+xml"});let r=`image/${e}`;if(t.startsWith("data:")){const e=Ir(t);e&&e.startsWith("image/")&&(r=e);const n=t.replace(/data:image\/[^;]+;base64,/,"");return RR(n,Ar(r))}return RR(t,Ar(r))}(r,e),o=Ar(i.type||`image/${r}`);const a=null!==(n=null==m?void 0:m.compessorUrl)&&void 0!==n?n:null==m?void 0:m.compressorUrl;if(o.startsWith("image/"))try{const e=new File([i],t,{type:o}),r=await La(e,{maxSizeMB:null==m?void 0:m.compressMaxSize,maxWidthOrHeight:null==m?void 0:m.compressMaxWidthOrHeight,mimeType:o,fileName:t,libURL:a,enableCompression:Boolean(m)&&"image/gif"!==o});i=r,o=r.type}catch(e){console.warn("Image preparation failed, using original:",e)}return{blob:i,mimeType:o,thumbnailDataUrl:await LR(i)}},[m]),B=i.useCallback(async(e,t,r,n)=>{var i,o,a,s,l,u;const h="save"===n?R.current:L.current;if(!T||!h)return;const f="object"==typeof T&&null!==T?T:null;let p=null;try{x(!0);const{blob:o,mimeType:a,thumbnailDataUrl:s}=await z(e,t,r),l=Object.assign(Object.assign({},T),{thumbnail:s,size:o.size,date:(new Date).toISOString().split("T")[0],type:a,folderId:T.folderId||"",name:T.name||t,extension:T.extension||(null===(i=(T.name||t).split(".").pop())||void 0===i?void 0:i.toLowerCase())||""});p=l;const u={blob:o,mimeType:a,thumbnail:s,mode:n},d=await h(l,u);if(d)return x(!1),d;throw new Error(c("saveCopy"===n?"Failed to save image copy":"Failed to save changes"))}catch(e){console.error("Error saving:",e);const r=null!=p?p:f,i=e;if(!(null==i?void 0:i.notificationShown)){const i=No(e),h=null!==(a=null!==(o=Ro(null==i?void 0:i.code,c))&&void 0!==o?o:null==i?void 0:i.message)&&void 0!==a?a:c("saveCopy"===n?"Failed to save image copy":"Error saving image");d.error({id:"saveCopy"===n?"IMAGE_SAVE_COPY_FAILED":"IMAGE_SAVE_FAILED",message:h,placement:"bottomRight",data:{itemId:null!==(s=null==r?void 0:r.id)&&void 0!==s?s:void 0,itemName:null!==(l=null==r?void 0:r.name)&&void 0!==l?l:t,folderId:null!==(u=null==r?void 0:r.folderId)&&void 0!==u?u:null,thumbnail:null==r?void 0:r.thumbnail},innerException:e})}x(!1)}},[T,d,z,c]),U=i.useCallback(async e=>{var t;if(!FR.isLoaded()||!T)return void console.error("❌ Pixie instance or file is missing");N.current=e;const r=T.name||"edited-image",n=Ta(T,S);try{await(null===(t=FR.tools)||void 0===t?void 0:t.export.save(r.replace(/\.[^/.]+$/,""),n.pixieFormat,Oa.QUALITY))}catch(t){console.error("🎨 Error saving through the button:",t);try{const t=FR.canvas,i=t?t.toDataURL(n.mimeType):null;i&&await B(i,r,n.extension,e)}catch(e){console.error("🎨 Alternative method also did not work:",e)}}},[T,S,B]),V=i.useCallback(async()=>{var t;if(C&&r&&A&&!P.current)try{P.current=!0;const r=u.current;let i=0;for(;i<20&&(0===r.clientWidth||0===r.clientHeight);)await new Promise(e=>setTimeout(e,50)),i++;const o=(null==m?void 0:m.locale)?null==m?void 0:m.locale.replace("_","-"):"en",a=matchMedia(hr).matches?ur:cr,s=(null==m?void 0:m.theme)===dr?a:null==m?void 0:m.theme,l=((null==m?void 0:m.locale)||g.language||"en").split("-")[0].split("_")[0],c=(g.getResourceBundle(l,"translation")||{}).pixie||{},d=e=>e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),h={};Object.entries(c).forEach(([e,t])=>{const r=d(e);h[r]=t,h[e]=t});const f={[o]:h},p=Ta(T,S),v={selector:"#pixie-editor",baseUrl:OR((null==m?void 0:m.baseUrl)||"",(null==m?void 0:m.assetsUrl)||"assets/image-editor"),image:C,activeLanguage:o,languages:f,ui:{activeTheme:s,mode:"inline",forceOverlayModeOnMobile:!1,visible:!0,menubar:{replaceDefaultItems:!0,position:PR.TOP,items:[{type:"undoWidget",align:"left"},{type:"zoomWidget",align:"center",desktopOnly:!0},{type:"button",align:"right",desktopOnly:!0,icon:()=>e(xe,{style:{fontSize:20}}),action:e=>{e.togglePanel("history")}},{type:"button",icon:()=>e(be,{style:{fontSize:20}}),align:"right",desktopOnly:!0,action:n}]},nav:{position:MR.TOP}},tools:{export:{defaultFormat:p.pixieFormat,defaultQuality:Oa.QUALITY,defaultName:(null===(t=null==T?void 0:T.name)||void 0===t?void 0:t.replace(/\.[^/.]+$/,""))||"image"},text:{replaceDefaultItems:!0,defaultText:"Handwriting",items:[{family:"Inter",src:"fonts/inter-v20-cyrillic_latin-regular.woff2"},{family:"Commissioner",src:"fonts/commissioner-v24-cyrillic_latin-regular.woff2"},{family:"Montserrat Light",src:"fonts/Montserrat-Light.woff2"},{family:"Montserrat Regular",src:"fonts/Montserrat-Regular.woff2"},{family:"Montserrat Bold",src:"fonts/Montserrat-Bold.woff2"},{family:"Montserrat Black",src:"fonts/Montserrat-Black.woff2"},{family:"Roboto Light",src:"fonts/Roboto-Light.woff2"},{family:"Roboto Regular",src:"fonts/Roboto-Regular.woff2"},{family:"Roboto Bold",src:"fonts/Roboto-Bold.woff2"},{family:"Roboto Black",src:"fonts/Roboto-Black.woff2"},{family:"Lato Light",src:"fonts/Lato-Light.woff2"},{family:"Lato Regular",src:"fonts/Lato-Regular.woff2"},{family:"Lato Bold",src:"fonts/Lato-Bold.woff2"},{family:"Lato Black",src:"fonts/Lato-Black.woff2"},{family:"Rubik Light",src:"fonts/Rubik-Light.woff2"},{family:"Rubik Regular",src:"fonts/Rubik-Regular.woff2"},{family:"Rubik Bold",src:"fonts/Rubik-Bold.woff2"},{family:"Rubik Black",src:"fonts/Rubik-Black.woff2"},{family:"Bebas Neue Light",src:"fonts/BebasNeueLight.woff2"},{family:"Bebas Neue Regular",src:"fonts/BebasNeueRegular.woff2"},{family:"Bebas Neue Book",src:"fonts/BebasNeueBook.woff2"},{family:"Bebas Neue Bold",src:"fonts/BebasNeueBold.woff2"},{family:"Fira Sans",src:"fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"},{family:"Lobster",src:"fonts/Lobster.woff2"},{family:"Pacifico",src:"fonts/pacifico-v23-cyrillic_latin-regular.woff2"},{family:"Playfair Display",src:"fonts/playfair-display-v40-cyrillic_latin-regular.woff2"},{family:"Oswald",src:"fonts/oswald-v57-cyrillic_latin-regular.woff2"},{family:"Caveat",src:"fonts/caveat-v23-cyrillic_latin-regular.woff2"}]}},onSave:async function(e,t,r){try{x(!0);return await B(e,t,r,N.current)}catch(e){throw console.error("🎨 PIXIE onSave ERROR:",e),x(!1),e}}};try{F(!1),await FR.show(v,u.current);const e=FR.canvas;e&&e.focus(),F(!0),x(!1)}catch(e){console.error("init pixie failed:",e)}}catch(e){console.error("Error initializing Pixie:",e),d.error({id:"EDITOR_INIT_FAILED",message:c("Error initializing editor"),placement:"bottomRight",innerException:e}),P.current=!1,null==n||n()}},[T,S,C,r,A,null==m?void 0:m.locale,null==m?void 0:m.theme,null==m?void 0:m.baseUrl,null==m?void 0:m.assetsUrl,n,B,d,g,c]);i.useEffect(()=>{r&&C&&A&&V()},[r,C,A,V]),i.useEffect(()=>{if(!r){try{FR.close()}catch(e){console.warn("Error closing Pixie:",e)}x(!1),_(null),k(""),P.current=!1,I(!1),F(!1)}return()=>{try{FR.close()}catch(e){console.warn("Error closing Pixie when unmounting:",e)}}},[r]);const H=Boolean(null==T?void 0:T.id)&&!1!==(null===(l=null==m?void 0:m.features)||void 0===l?void 0:l.enableUpdateFile);return e(G,{title:(null==T?void 0:T.name)?c("Editing: {{name}}",{name:T.name}):c("Editing image"),open:r,closeIcon:null,onCancel:n,afterOpenChange:e=>I(e),forceRender:!0,width:"100vw",style:{top:0,height:"100vh",maxWidth:"none",padding:10},styles:{body:{height:"85vh",padding:0}},footer:[e(M,{onClick:n,disabled:!A||w,children:c("Cancel")},"cancel"),e(M,{type:"primary",onClick:()=>U("saveCopy"),loading:w,children:c("Save as copy and choose")},"save-copy"),...H?[e(M,{type:"primary",onClick:()=>U("save"),loading:w,children:c("Save and choose")},"save")]:[]],maskClosable:!1,destroyOnHidden:!1,afterClose:()=>{v&&v("")},children:t("div",{ref:u,style:{position:"relative",width:"100%",height:"100%"},children:[r&&!E?e("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.45)",backdropFilter:"blur(1px)",pointerEvents:"all",zIndex:10},children:e("span",{style:{fontSize:14,color:"#555"},children:c("Loading editor...")})}):null,w&&E&&e(rl,{style:{position:"absolute",top:0,background:"var(--colorBgLayout)",zIndex:100,opacity:.7}})]})})};var jR="uploadProgress",DR="uploadProgress__card",zR="uploadProgress__header",BR="uploadProgress__header-title",UR="uploadProgress__header-buttons",VR="uploadProgress__header-button",HR="uploadProgress__close-icon",$R="uploadProgress__body",WR="uploadProgress__common-error",GR="uploadProgress__common-error-row",qR="uploadProgress__common-error-hint",YR="uploadProgress__list-wrapper",XR="uploadProgress__status-icon",KR="uploadProgress__file-item",ZR="uploadProgress__file-item--error",JR="uploadProgress__body--error",QR="uploadProgress__error-item",eL="uploadProgress__error-message",tL="uploadProgress__error-hint",rL="uploadProgress__file-avatar",nL="uploadProgress__file-info",iL="uploadProgress__file-name",oL="uploadProgress__file-size",aL="uploadProgress__progress-bar",sL="uploadProgress__minimized",lL="uploadProgress__minimized-button",cL="uploadProgress__file-list";const{Text:uL}=T,dL=({visible:r,files:n,totalFiles:i,completedFiles:o,onClose:a,onMinimize:s,onInsert:l,minimized:c=!1})=>{var u;const{token:d}=k.useToken(),{t:h}=Yn();if(!r)return null;const f=t=>{switch(t){case"success":return e("div",{className:XR,children:e(Se,{style:{color:d.colorSuccess}})});case"error":return e(Ce,{style:{color:d.colorError}});default:return e(_e,{style:{color:"#1890ff"}})}},p=t=>"success"===t.status?[e(M,{type:"primary",size:"small",onClick:()=>l(t),children:h("Insert")},"insert")]:[];if(c)return e("div",{className:sL,children:e(M,{type:"primary",size:"small",onClick:s,className:lL,children:h("Upload progress",{completed:o,total:i})})});const g=n.filter(e=>"uploading"===e.status).length,m=n.filter(e=>"success"===e.status).length,v=n.filter(e=>"error"===e.status).length,y=n.filter(e=>"error"===e.status),b=y.length>1&&y.every(e=>{var t;return e.error&&e.error===(null===(t=y[0])||void 0===t?void 0:t.error)}),w=b?null===(u=y[0])||void 0===u?void 0:u.error:null;return e("div",{className:jR+" fm-upload-progress",children:t("div",{className:DR,children:[t("div",{className:zR,children:[e(uL,{strong:!0,className:BR,children:g>0?h("Uploading files",{completed:o,total:i}):m>0?h("Uploaded files",{success:m,total:i}):h("Upload error files",{errorCount:v})}),e("div",{className:UR,children:e(M,{type:"text",size:"small",icon:e(be,{className:HR}),onClick:a,className:VR})})]}),t("div",{className:`${$R} ${n.some(e=>"error"===e.status)?JR:""}`,children:[e("div",{className:YR,children:e(K,{className:cL,size:"small",dataSource:n,renderItem:r=>{const n="error"===r.status,i=n?(e=>{if(!e)return null;const t=e.toLowerCase();return t.includes("type")||t.includes("format")||t.includes("формат")||t.includes("тип")||t.includes("not allowed")||t.includes("дозволен")||t.includes("name")||t.includes("invalid")||t.includes("назва")||t.includes("неприпустим")||t.includes("allowed characters")?null:t.includes("large")||t.includes("size")||t.includes("розмір")||t.includes("размер")?h("upload_error_hint_size"):t.includes("exists")||t.includes("вже існує")||t.includes("уже существует")?h("upload_error_hint_exists"):null})(r.error):null;return e(K.Item,{className:`${KR} ${n?ZR:""}`,actions:p(r),children:e(K.Item.Meta,{avatar:e(Z,{size:"small",icon:f(r.status),className:rL}),title:t("div",{className:nL,children:[e(uL,{ellipsis:!0,className:iL,children:r.name}),e(uL,{type:"secondary",className:oL,children:void 0!==r.size?ui(r.size):""})]}),description:"uploading"===r.status?e(q,{percent:r.progress,size:"small",status:"active",showInfo:!1,className:aL}):n?b?null:t("div",{className:QR,children:[e(uL,{type:"danger",className:eL,children:r.error||h("Error")}),i&&e(uL,{type:"secondary",className:tL,children:i})]}):null})})}})}),w&&t("div",{className:WR,children:[t("div",{className:GR,children:[e(Ce,{style:{color:d.colorError,marginRight:8,flexShrink:0}}),e(uL,{type:"danger",children:w})]}),e(uL,{type:"secondary",className:qR,children:h("Applies to all {{count}} files",{count:y.length})})]})]})]})})},{Header:hL}=J,{Title:fL}=T,pL=({activeLibraryItem:r,selectedFolder:i,isTrashFolder:o,onClearTrash:a,files:s,loading:l,onRefresh:c,refreshDisabled:u,showRefresh:d=!1})=>{const{t:h}=Yn(),f=r===rr&&(null!=o?o:i===lr),[p,g]=n.useState(!1),m={[rr]:h("My files"),[nr]:h("GIF"),[ir]:h("Stock images"),[or]:h("Icons"),[ar]:h("AI image generation")};let v;return n.useEffect(()=>{const e=setTimeout(()=>{g(f&&s.length>0&&!l)},200);return()=>clearTimeout(e)},[f,s.length,l]),v=r===rr?f?h("Trash"):i:m[r],e(hL,{className:"actions-header",children:t("div",{className:"header-title-container",children:[e(fL,{level:5,className:"header-title",children:v}),p&&a&&e(M,{type:"default",onClick:a,className:"clear-trash-button","aria-label":h("Clear Trash"),children:h("Clear")}),r===rr&&d&&c&&e(P,{title:h("Refresh"),children:e(M,{type:"text",className:"folder-refresh-button",icon:e(Ei,{size:16}),onClick:c,disabled:u})})]})})};function gL(e,t){return!e||!t||e<=0||t<=0?1:e/t}const mL=1200;function vL({items:e,getId:t,getPreviewSrc:r,getAltText:n,getWidth:i,getHeight:a,layoutMode:s="masonry",minColumnWidth:l=240,estimatedItemHeight:c=240,gap:u=20,overscanPx:h=800,prefetchThresholdPx:f=1200,resolveColumnCount:p,virtualizationThreshold:g=40}){var m,v;const[y,b]=o({scrollTop:0,viewportHeight:800,viewportWidth:mL,scrollHeight:0}),w=d(()=>function(e){return{getId:e,buildSignature:(t,r)=>{var n,i;const o=r.getPreviewSrc(t)||"",a=r.getAltText(t),s=null===(n=r.getWidth)||void 0===n?void 0:n.call(r,t),l=null===(i=r.getHeight)||void 0===i?void 0:i.call(r,t);return[e(t),o,a,null!=s?s:"",null!=l?l:""].join("::")},buildRowModel:(e,t,r)=>{var n,i;const o=null===(n=t.getWidth)||void 0===n?void 0:n.call(t,e),a=null===(i=t.getHeight)||void 0===i?void 0:i.call(t,e);return{id:r.id,signature:r.signature,item:e,previewSrc:t.getPreviewSrc(e),altText:t.getAltText(e),width:o,height:a,aspectRatio:gL(o,a)}}}}(t),[t]),x=d(()=>({getPreviewSrc:r,getAltText:n,getWidth:i,getHeight:a}),[n,a,r,i]),C=d(()=>{const e=Math.max(1,y.viewportWidth||mL);return p?Math.max(1,p(e)):Math.max(1,Math.floor((e+u)/(l+u)))},[u,l,p,y.viewportWidth]),_=d(()=>{const e=Math.max(1,y.viewportWidth||mL);return Math.max(1,(e-u*Math.max(0,C-1))/C)},[C,u,y.viewportWidth]),S=d(()=>{const t=new Array(C).fill(0),r=[];e:for(let n=0;n<e.length;n+=1){const o=e[n],l=null==i?void 0:i(o),d=null==a?void 0:a(o),h=l&&d&&l>0&&d>0?l/d:void 0,f=h?_/h:c;if("grid"===s){const e=Math.floor(n/C)*(f+u),t=n%C*(_+u);r.push({index:n,top:e,left:t,width:_,height:f,bottom:e+f});continue e}let p=0;for(let e=1;e<t.length;e+=1)t[e]<t[p]&&(p=e);const g=t[p],m=p*(_+u);t[p]=g+f+u,r.push({index:n,top:g,left:m,width:_,height:f,bottom:g+f})}const n=0===r.length?0:"grid"===s?Math.max(...r.map(e=>e.bottom)):Math.max(0,...t.map(e=>e-u));return{positionedItems:r,containerHeight:n}},[C,_,c,u,a,i,e,s]),k=d(()=>e.length<=g?{renderStrategy:"full"}:{renderStrategy:"positioned",positioned:{layout:S.positionedItems,viewportTop:y.scrollTop,viewportBottom:y.scrollTop+y.viewportHeight,overscanPx:h,containerHeight:S.containerHeight}},[e.length,S.containerHeight,S.positionedItems,h,y.scrollTop,y.viewportHeight,g]),{rowModels:A,renderWindow:I}=zs({items:e,context:x,adapter:w,options:k}),E=null!==(m=I.positionedItems)&&void 0!==m?m:A.map((e,t)=>{var r;return{row:e,layout:null!==(r=S.positionedItems[t])&&void 0!==r?r:{index:t,top:0,left:0,width:_,height:c,bottom:c}}}),F=null!==(v=I.containerHeight)&&void 0!==v?v:S.containerHeight,T=F>0&&y.scrollTop+y.viewportHeight>=F-f;return{rowModels:A,renderRows:I.rows,renderWindow:I,positionedItems:E,containerHeight:F,isNearEnd:T,viewportMetrics:y,handleViewportChange:e=>{b(t=>t.scrollTop===e.scrollTop&&t.viewportHeight===e.viewportHeight&&t.viewportWidth===e.viewportWidth&&t.scrollHeight===e.scrollHeight?t:e)}}}const yL=t=>{var r,{imageId:n,sourceUrl:i,shouldLoad:s=!0,loader:l,onLoad:c}=t,d=As(t,["imageId","sourceUrl","shouldLoad","loader","onLoad"]);const[h,f]=o(()=>l.getSnapshot(n,i)),p=u(null);return a(()=>(f(l.getSnapshot(n,i)),l.subscribe(n,i,f)),[n,l,i]),a(()=>(l.setActive(n,i,s),()=>{l.setActive(n,i,!1),l.release(n)}),[n,l,s,i]),h.shouldLoad?e("img",Object.assign({},d,{ref:p,src:i,loading:null!==(r=d.loading)&&void 0!==r?r:"lazy",onLoad:e=>{l.markLoaded(n),null==c||c(e)},onError:e=>{var t;l.markError(n),null===(t=d.onError)||void 0===t||t.call(d,e)}})):null};var bL={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",virtualCanvas:"virtualCanvas",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const wL=e=>{const t="undefined"!=typeof window?window.innerWidth:e;return t<=700?1:t<=1100?2:t<=1600?3:4},xL=e=>e.images.downsized.url,CL=({setImageGifList:n,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:d,customRequest:h})=>{const{t:f}=Yn(),{GifPlayIcon:p}=mo(),{options:g}=po(),{config:m}=g,v=cs({maxConcurrent:6}),[y,b]=o(null),[w,x]=o(new Set),[C,_]=o(!1),[k,A]=o(!1),[I,T]=o(!1),[O]=E.useForm(),P=u(s),M=u(null),R=u(null),L=u(null),N=u(0),j=u(0),D=u(new Set);a(()=>{P.current=s},[s]),a(()=>{O.setFieldsValue({keywords:s.keywords})},[]);const z=null==m?void 0:m.handleProxyUrl,B=async e=>z?Promise.resolve(z(e)):e,U=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await B(e.images.downsized.url)}),fixed_width:e.images.fixed_width?Object.assign(Object.assign({},e.images.fixed_width),{url:await B(e.images.fixed_width.url)}):void 0,fixed_width_downsampled:e.images.fixed_width_downsampled?Object.assign(Object.assign({},e.images.fixed_width_downsampled),{url:await B(e.images.fixed_width_downsampled.url)}):void 0})}))),V=async function({query:e,page:t}){var r;const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(r=null==m?void 0:m.REACT_APP_GIPHY_KEY)&&void 0!==r?r:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(n)}&limit=50&offset=${t}&lang=en`,i=await fetch(await B(e));return{data:await i.json()}}catch(e){console.warn(e)}},{positionedItems:H,containerHeight:$,isNearEnd:W,viewportMetrics:G,handleViewportChange:q}=vL({items:i,getId:e=>e.id,getPreviewSrc:xL,getAltText:e=>e.title,getWidth:e=>e.images.downsized.width?Number(e.images.downsized.width):void 0,getHeight:e=>e.images.downsized.height?Number(e.images.downsized.height):void 0,layoutMode:"masonry",minColumnWidth:240,estimatedItemHeight:220,prefetchThresholdPx:320,resolveColumnCount:wL}),Y=ys(q,[i.length]),X=()=>{M.current&&(clearTimeout(M.current),M.current=null)},K=e=>!D.current.has(e)&&(D.current.add(e),!0),Z=e=>{D.current.delete(e)},J=c(async()=>{var e,t,r;const i=null===(e=P.current.keywords)||void 0===e?void 0:e.trim();if(!i||C||k||!I)return;const o=`gif:${i}:${j.current}`;if(!K(o))return;const a=N.current;A(!0);try{const e=await V({query:P.current,page:j.current});if(a!==N.current)return;const i=null!==(r=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.data)&&void 0!==r?r:[];if(!Array.isArray(i)||0===i.length)return void T(!1);const o=await U(i);if(a!==N.current)return;n(e=>{const t=new Set(e.map(e=>e.id)),r=o.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),j.current+=i.length,T(50===i.length)}finally{Z(o),a===N.current&&A(!1)}},[I,C,k,n]),Q=async()=>{var e,t;X();const r=null===(e=P.current.keywords)||void 0===e?void 0:e.trim();if(!r)return R.current=null,L.current=null,N.current+=1,j.current=0,n([]),x(new Set),T(!1),void A(!1);if(L.current===r)return;if(R.current===r||C&&R.current===r)return;const i=`gif:${r}:0`;if(!K(i))return;const o=N.current+1;N.current=o,R.current=r,j.current=0,n([]),x(new Set),T(!1),A(!1),_(!0);try{const e=await V({query:P.current,page:0});if(o!==N.current)return;const i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.data;if(Array.isArray(i)&&i.length>0){const e=await U(i);if(o!==N.current)return;n(e),j.current=i.length,T(50===i.length)}else n([]),T(!1);L.current=r}catch(e){T(!1)}finally{Z(i),R.current===r&&(R.current=null),_(!1)}};return a(()=>()=>{X()},[]),a(()=>{!C&&!k&&I&&i.length>0&&W&&J()},[I,i.length,W,J,C,k]),e("div",{className:bL.gifTab,children:e("div",{className:bL.searchOutputWrapper,children:t("div",{id:"scrollableDiv",ref:Y,className:bL.scrollableDiv,children:[t(E,{form:O,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},P.current),{keywords:e.keywords});l(t),P.current=t,X(),M.current=setTimeout(Q,800)}},className:i.length>0?bL.searchResults:bL.search,children:[e(E.Item,{name:"keywords",className:bL.gifSearchInput,children:e(F,{onPressEnter:()=>{Q()},allowClear:!0,placeholder:f("Search GIFs"),ref:d,spellCheck:"false",prefix:e(Ti,{size:16,strokeWidth:null==m?void 0:m.iconStrokeWidth,onClick:()=>{Q()}})})}),i.length>0&&!C&&e("div",{className:`ant-divider ${bL.divider}`,role:"separator"})]}),!i.length&&!C&&e(r,{children:s.keywords?e(xo,{}):t("div",{className:bL.resultsContainer,children:[e("div",{className:bL.videoIcon,children:e(p,{className:bL.playButton})}),e("h1",{className:bL.title,children:f("Over 350,000 live images")}),e("p",{className:bL.subtitle,children:f("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&C&&e(rl,{}),i.length>0&&t(r,{children:[e("div",{className:bL.virtualCanvas,style:{height:$},children:H.map(({row:r,layout:n})=>{const i=r.item,o=w.has(i.id),a=xL(i),s=n.bottom>=G.scrollTop-240&&n.top<=G.scrollTop+G.viewportHeight+240;return t("div",{className:`${bL.listItem} ${o?bL.loaded:""}`,onClick:()=>(async(e,t)=>{var r;b(t),setTimeout(()=>{b(null)},2e3);let n=e.split("?")[0].split("#")[0].split("/"),i=n[n.length-1]||"uploaded-file";i.includes(".")&&(null===(r=i.split(".").pop())||void 0===r?void 0:r.length)&&i.split(".").pop().length<=5||(i+=".gif"),h(e,i)})(i.images.downsized.url,i.id,i.title),style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height,minHeight:n.height,maxHeight:"none",marginBottom:0},children:[e(yL,{imageId:i.id,sourceUrl:a,shouldLoad:s,loader:v,className:y===i.id?bL.loadedImage:"",width:"100%",height:"100%",alt:i.title,decoding:"async",onLoad:()=>{x(e=>{if(e.has(i.id))return e;const t=new Set(e);return t.add(i.id),t})}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),y===i.id&&e(S,{className:bL.antSpin})]},i.id)})}),k&&e(rl,{})]})]})})})};var _L={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",virtualCanvas:"virtualCanvas",scrollableDiv:"scrollableDiv",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const SL=e=>{const t="undefined"!=typeof window?window.innerWidth:e;return t<=650?1:t<=1e3?2:t<=1450?3:4},kL=(e,t)=>{const r=new URL(e);return r.searchParams.set("w",t.toString()),r.toString()},AL=({imageStockList:n,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:d,customRequest:h})=>{var f,p;const{t:g}=Yn(),{StockBigIcon:m,MixedViewIcon:v,LandscapeViewIcon:y,PortraitViewIcon:b,SquareViewIcon:w}=mo(),{options:x}=po(),{config:C}=x,_=cs({maxConcurrent:6}),[k,A]=o(!1),[I,T]=o(!1),[O,M]=o(!1),[R,L]=o(null),[N,j]=o(new Set),[D]=E.useForm(),B=null==C?void 0:C.handleProxyUrl,V=null!==(f=null==C?void 0:C.UNSPLASH_KEY)&&void 0!==f?f:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",H=(null===(p=null==C?void 0:C.locale)||void 0===p?void 0:p.slice(0,2))||"ru",$=u(s),W=u(null),G=u(null),q=u(0),Y=u(1),X=u(new Set),K=async e=>B?Promise.resolve(B(e)):e,Z=()=>{W.current&&(clearTimeout(W.current),W.current=null)},J=e=>!X.current.has(e)&&(X.current.add(e),!0),ee=e=>{X.current.delete(e)},te=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:{raw:await K(kL(e.urls.raw,1200)),small:await K(kL(e.urls.raw,540))}})));a(()=>{$.current=s},[s]),a(()=>{0===n.length&&D.setFieldsValue({color:"",orientation:""})},[n,D]),a(()=>{D.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const re=async function({query:e,page:t}){const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let n=`https://api.unsplash.com/search/photos?client_id=${V}&lang=${H}&per_page=30&query=${encodeURIComponent(r)}&page=${t}`;""!==e.color&&(n+=`&color=${e.color}`),""!==e.orientation&&(n+=`&orientation=${e.orientation}`);const i=await fetch(await K(n));return{data:await i.json()}}catch(e){console.warn(e)}},{positionedItems:ne,containerHeight:ie,isNearEnd:oe,viewportMetrics:ae,handleViewportChange:se}=vL({items:n,getId:e=>e.id,getPreviewSrc:e=>e.urls.small,getAltText:e=>e.description||e.user.name,getWidth:e=>e.width,getHeight:e=>e.height,layoutMode:"masonry",minColumnWidth:240,estimatedItemHeight:220,prefetchThresholdPx:320,resolveColumnCount:SL}),le=ys(se,[n.length]),ce=c(async()=>{var e,t;if(k||I||!O||!$.current.keywords.trim())return;const r=q.current,n=Y.current,o=`stock:${`${$.current.keywords.trim()}|${$.current.color}|${$.current.orientation}`}:${n}`;if(J(o)){T(!0);try{const o=await re({query:$.current,page:n});if(r!==q.current)return;const a=null!==(t=null===(e=null==o?void 0:o.data)||void 0===e?void 0:e.results)&&void 0!==t?t:[];if(0===a.length)return void M(!1);const s=await te(a);if(r!==q.current)return;i(e=>{const t=new Set(e.map(e=>e.id)),r=s.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),Y.current=n+1,M(30===a.length)}finally{ee(o),r===q.current&&T(!1)}}},[O,k,I,i]),ue=async()=>{var e,t;Z();const r=`${$.current.keywords.trim()}|${$.current.color}|${$.current.orientation}`;if(!$.current.keywords.trim())return void(G.current=null);if(G.current===r)return;const n=`stock:${r}:1`;if(!J(n))return;const o=q.current+1;q.current=o,A(!0),T(!1),M(!1),Y.current=1,i([]),j(new Set);try{const n=await re({query:$.current,page:1});if(o!==q.current)return;const a=null!==(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.results)&&void 0!==t?t:[];if(a.length>0){const e=await te(a);if(o!==q.current)return;i(e),Y.current=2,M(30===a.length)}else M(!1);G.current=r}finally{ee(n),A(!1)}};a(()=>()=>{Z()},[]),a(()=>{!k&&!I&&O&&n.length>0&&oe&&ce()},[O,n.length,oe,ce,k,I]);const de=async(e,t,r,n)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${V}`,r=await K(t),n=await fetch(r);return{data:await n.json()}}catch(e){console.warn(e)}}(t.download_location),L(r),setTimeout(()=>L(null),2e3);const o=e.raw,a=o.split("?")[0].split("#")[0].split("/");let s=a[a.length-1]||"uploaded-file";s.includes(".")&&(null===(i=s.split(".").pop())||void 0===i?void 0:i.length)&&s.split(".").pop().length<=5||(s+=".jpg"),h(o,s)};return e("div",{className:_L.stockTab,children:e("div",{className:_L.searchOutputWrapper,children:t("div",{className:_L.scrollableDiv,id:"scrollableDiv",ref:le,children:[t(E,{form:D,initialValues:vr,onValuesChange:(e,t)=>{const r=Object.assign(Object.assign({},vr),t);l(r),$.current=r,Z(),""!==r.keywords?W.current=setTimeout(ue,800):(G.current=null,q.current+=1,Y.current=1,i([]),j(new Set),M(!1),T(!1),l(Object.assign({},vr)),$.current=vr,D.resetFields())},className:n.length>0?_L.searchResults:_L.search,children:[t(U,{gutter:24,children:[e(z,{span:n.length>0?void 0:24,children:e(E.Item,{name:"keywords",className:_L.stockSearchInput,children:e(F,{allowClear:!0,placeholder:g("Search image"),ref:d,spellCheck:"false",prefix:e(Ti,{size:16,strokeWidth:null==C?void 0:C.iconStrokeWidth})})})}),!!n.length&&t(r,{children:[e(z,{children:e(E.Item,{name:"orientation",children:t(Q.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(P,{title:g("All"),placement:"top",children:e(Q.Button,{value:"",children:e(v,{})})}),e(P,{title:g("Landscape"),placement:"top",children:e(Q.Button,{value:"landscape",children:e(y,{})})}),e(P,{title:g("Portrait"),placement:"top",children:e(Q.Button,{value:"portrait",children:e(b,{})})}),e(P,{title:g("Squarish"),placement:"top",children:e(Q.Button,{value:"squarish",children:e(w,{})})})]})})}),e(z,{children:e(E.Item,{name:"color",children:t(Q.Group,{className:_L.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(P,{title:g("All"),placement:"top",children:e(Q.Button,{className:_L.allColors,value:"",children:"All"})}),e(P,{title:g("Black"),placement:"top",children:e(Q.Button,{className:_L.blackColor,value:"black",children:"B"})}),e(P,{title:g("Black and White"),placement:"top",children:e(Q.Button,{className:_L.bwColor,value:"black_and_white",children:"B&W"})}),e(P,{title:g("White"),placement:"top",children:e(Q.Button,{className:_L.whiteColor,value:"white",children:"W"})}),e(P,{title:g("Orange"),placement:"top",children:e(Q.Button,{className:_L.orangeColor,value:"orange",children:"O"})}),e(P,{title:g("Red"),placement:"top",children:e(Q.Button,{className:_L.redColor,value:"red",children:"R"})}),e(P,{title:g("Purple"),placement:"top",children:e(Q.Button,{className:_L.purpleColor,value:"purple",children:"P"})}),e(P,{title:g("Magenta"),placement:"top",children:e(Q.Button,{className:_L.magentaColor,value:"magenta",children:"M"})}),e(P,{title:g("Green"),placement:"top",children:e(Q.Button,{className:_L.greenColor,value:"green",children:"G"})}),e(P,{title:g("Teal"),placement:"top",children:e(Q.Button,{className:_L.tealColor,value:"teal",children:"T"})}),e(P,{title:g("Blue"),placement:"top",children:e(Q.Button,{className:_L.blueColor,value:"blue",children:"B"})})]})})})]})]}),n.length>0&&!k&&e("div",{className:`ant-divider ${_L.divider}`,role:"separator"})]}),!n.length&&!k&&e(r,{children:s.keywords?e(xo,{}):t("div",{className:_L.resultsContainer,children:[e("div",{className:_L.videoIcon,children:e(m,{className:_L.playButton})}),e("h1",{className:_L.title,children:g("Millions of free stock images")}),e("p",{className:_L.subtitle,children:g("Enter a search query and we'll find the perfect image for you")})]})}),!n.length&&k&&e(rl,{}),n.length>0&&t(r,{children:[e("div",{className:_L.virtualCanvas,style:{height:ie},children:ne.map(({row:r,layout:n})=>{const i=r.item,o=N.has(i.id),a=n.bottom>=ae.scrollTop-240&&n.top<=ae.scrollTop+ae.viewportHeight+240;return t("div",{className:`${_L.listItem} ${o?_L.loaded:""}`,onClick:()=>de(i.urls,i.links,i.id,i.description),style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height,minHeight:n.height,maxHeight:"none",marginBottom:0},children:[e(yL,{imageId:i.id,sourceUrl:i.urls.small,shouldLoad:a,loader:_,className:R===i.id?_L.loadedImage:"",width:"100%",height:"100%",alt:i.description,decoding:"async",onLoad:()=>{j(e=>{if(e.has(i.id))return e;const t=new Set(e);return t.add(i.id),t})}}),t("p",{className:_L.creatorInfo,onClick:e=>e.stopPropagation(),children:[g("Photo by")," ",e("a",{target:"_blank",href:`${i.user.links.html}?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:i.user.name})," ",g("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),R===i.id&&e(S,{className:_L.antSpin})]},i.id)})}),I&&e(rl,{})]})]})})})},IL=()=>{const{options:e}=po(),t=e.config;return c((e,r)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const r=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(r,t):r()})(e,r)},[null==t?void 0:t.pushToGTM])};var EL="slideshowContainer",FL="slideshowImage";const TL=({images:t,transitionDuration:r=1e3,frameHeight:n})=>{const[i,s]=o([]),[l,c]=o(n);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(n);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof n){const e=Math.min(n,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n]);const u=()=>{s(e=>e.map((t,r)=>r===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(u,1e3)}else s([])},[t]),e("div",{className:EL,style:{height:l,minHeight:130},children:i.map((t,n)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${n+1}`,className:FL,style:{opacity:t.opacity,transition:`opacity ${r}ms linear`,display:"block"}},n))})},OL=t=>{var{className:r,style:n,color:i,text:o,bordered:a}=t,s=As(t,["className","style","color","text","bordered"]);const l=o||"";return e(ee,Object.assign({style:n,color:i,bordered:a,className:r},s,{children:l}))},PL=({text:r,counter:n,limits:i,wrapperStyles:o})=>{const{t:a}=Yn(),{options:s}=po(),l=s.config,{token:c}=k.useToken(),u=+i>0,d=!u||n<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=n+" "+a("of")+" "+(u?i:"∞")+" "+(r||a("tests",{count:i}))+" "+a("was used",{count:n});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(OL,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var ML={imageAi:"imageAi",imageAiExample:"imageAiExample",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const RL=f(({className:t,onClick:r})=>e("div",{className:`${ML.arrow} ${ML.arrowNext} ${t||""}`,onClick:r,children:e(M,{className:`${ML.arrowBtn} ${ML.arrowBtnNext}`,size:"large",icon:e(ke,{})})}));RL.displayName="SampleNextArrow";const LL=f(({className:t,onClick:r})=>e("div",{className:`${ML.arrow} ${ML.arrowPrev} ${t||""}`,onClick:r,children:e(M,{className:`${ML.arrowBtn} ${ML.arrowBtnPrev}`,size:"large",icon:e(Ae,{})})}));LL.displayName="SamplePrevArrow";const NL=({customRequest:r,inputAiRef:n,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Yn(),{AiIcon_2:b}=mo(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:k,requestStatus:A,handleGenerate:I,convertBase64ToFile:T,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:R}=function({setFrameHeight:e,customRequest:t,aiTabRef:r,isImageUploaded:n,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Yn(),{options:m}=po(),v=m.config,y=Oo(),b=IL(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[k,A]=o(null),[I,E]=o(!1),[F,T]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||k||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),D.current=-1)},[l,k]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),j=c(e=>{const t=`${k}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(T(String(e.status)),100===e.progress){p(!1),h(e.images);const t=k,r=Array.isArray(e.images)?e.images:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),A(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=k,r=e.data?[String(e.data)]:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),A(null),P(!1)}}else p(!1),P(!1),k&&!R.current.has(k)&&(R.current.add(k),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(k)||void 0,data:{requestId:k,request:s,response:e},innerException:e}))},[s,h,T,g,p,k,y,P]),D=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>D.current&&(D.current=e,j(x[e]))}},[j,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:H}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:$}=H,W=$>0&&_>=$,G=!(!(null==v?void 0:v.limits)||!v.counters)&&fr,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!W&&!G,[W,G,_,$]),X=c(async()=>{T(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,r,n,i,o;const{data:a,error:l}=e||{};if(l)throw l;const c=a;if(401===(null==c?void 0:c.status)||401===(null===(t=null==c?void 0:c.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const u=(null==c?void 0:c.task)||(null===(r=null==c?void 0:c.data)||void 0===r?void 0:r.task),d=null!==(i=null!==(n=null==u?void 0:u.id)&&void 0!==n?n:k)&&void 0!==i?i:void 0;200===(null==c?void 0:c.status)||200===(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.status)?((null==u?void 0:u.id)&&(T(u.message),A(u.id)),(null==c?void 0:c.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",data:{request:s,taskId:d,response:null==c?void 0:c.data}}),z({task_id:null==u?void 0:u.id,entity_id:U})):(p(!1),P(!1),d&&!R.current.has(d)&&(R.current.add(d),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&k&&!R.current.has(k)&&(R.current.add(k),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:k,response:null==t?void 0:t.data,error:No(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,k]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(n)return;const r=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!r)return;const o=r[1],a=r[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[n,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,n;let i=350;if(r.current){const e=null===(t=r.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(n=r.current.getBoundingClientRect())||void 0===n?void 0:n.height)-48-e.clientHeight)}e(i)},0)},[r,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:$,isFieldsDisabled:W,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:F,setRequestStatus:T,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:I,setIsShiftPressed:E,currentReqId:k,setCurrentReqId:A,limitsInPlugin:G}}({setFrameHeight:C,customRequest:r,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[L,N]=o(!1),j=c(()=>N(!0),[]),D=c(()=>N(!1),[]),B=c(e=>f(e.target.value),[f]),V=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),I())},[O,I,P]),H=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:ML.imageAi,ref:w,children:[R&&e(PL,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e(U,{gutter:24,className:ML.row,children:t(z,{span:24,children:[e(E.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${ML.inputAffixWrapper}${L?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:n,onKeyDown:V,onKeyUp:H,onFocus:j,onBlur:D,autoSize:!0,allowClear:!0,className:`${ML.textAreaInputHybrid} ${ML.textarea}`,placeholder:y("Generate image"),value:h,onChange:B,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${ML.inputSuffix}`,children:m||k?e(se,{className:`${ML.inputIcon} input-icon`,spin:!0}):e(b,{className:`${ML.inputIcon} input-icon`,onClick:I})})]})}),t("div",{className:ML.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(te,{dotPosition:"top",arrows:!0,nextArrow:e(RL,{}),prevArrow:e(LL,{}),className:ML.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:ML.loading,children:t("div",{className:"spin",children:[e(se,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:A})]})}),p.length>0&&p.map((r,n)=>t("div",{className:ML.imageItem,children:[e(TL,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(M,{onClick:()=>T(`data:image/jpeg;base64, ${r}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},n))]})]})};var jL={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridLoadingMore:"iconsGridLoadingMore",iconsGridVirtualCanvas:"iconsGridVirtualCanvas",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridItemSelected:"iconsGridItemSelected",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const DL=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],zL=({query:r,onQueryChange:n,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Yn(),{options:u}=po(),{config:d}=u,h=r.length>0&&s;return t("div",{className:jL.iconsSearchFormCenteredContainer,children:[t(E,{layout:"inline",onFinish:i,className:h?jL.iconsSearchResults:jL.iconsSearchFormCentered,children:[e(E.Item,{className:jL.iconsSearchFormInput,children:e(F,{ref:l,className:jL.iconsSearchFormInputInput,allowClear:!0,prefix:e(Ti,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:r,onChange:e=>n(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(E.Item,{className:jL.iconsSearchFormStyleItem,children:e(O,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:jL.iconsSearchFormSelect,options:DL.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${jL.iconsSearchDivider}`,role:"separator"})]})},BL=n=>{const{t:i}=Yn(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=n;return t("div",{className:jL.iconsControls,children:[e("div",{className:jL.iconsControlsControls,children:"family"===o&&t(r,{children:[t("div",{className:jL.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(re,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:jL.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(re,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(R,{size:8,children:e(ne,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(r,{children:[t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ne,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ne,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ne,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:jL.iconsControlsHeader,children:e("div",{children:"family"===o?e(M,{className:jL.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},UL=e(se,{style:{fontSize:20},spin:!0}),VL=({items:n,loading:o,isCollectingResults:a=!1,hasMore:s=!1,hasQuery:l,mode:c,selectedHash:u,onItemClick:d,onInsert:h,onLoadMore:f,colorVars:p,svgTextMap:g,previewSize:m,selectedHashes:v,onToggleSelect:y})=>{const{t:b}=Yn(),{ThumbsUpIcon:w}=mo(),x=cs({maxConcurrent:6}),C=Boolean(v&&v.size>0),_=i.useRef(null),k=Math.max(100,(null!=m?m:50)+48),{positionedItems:A,containerHeight:I,isNearEnd:E,viewportMetrics:F,handleViewportChange:T}=vL({items:n,getId:e=>e.hash,getPreviewSrc:e=>e.imagePreviewUrl,getAltText:e=>e.name,getWidth:()=>1,getHeight:()=>1,layoutMode:"grid",minColumnWidth:k,gap:16,prefetchThresholdPx:240}),O=ys(T,[n.length,null!=m?m:50]);i.useEffect(()=>{s||(_.current=null)},[s,n.length]),i.useEffect(()=>{if(!o&&!a&&s&&n.length>0&&E){if(_.current===n.length)return;_.current=n.length,null==f||f()}},[s,a,E,n.length,o,f]);const P=e("div",l?{className:jL.iconsGridEmptyState,children:e(xo,{})}:{className:jL.iconsGridEmptyState,children:t("div",{className:jL.resultsContainer,children:[e("span",{className:jL.videoIcon,children:e(w,{className:jL.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:jL.title,children:b("Millions of icons")}),e("p",{className:jL.subtitle,children:b("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:O,className:jL.iconsGrid,children:[0!==n.length||o?t(r,{children:[e("div",{className:jL.iconsGridVirtualCanvas,style:{height:I},children:A.map(({row:r,layout:n})=>{var i,o,a,s,l,h,f,b,w,_,S;const k=r.item,A=Boolean(v&&v.has(k.hash)||u===k.hash),I=n.bottom>=F.scrollTop-180&&n.top<=F.scrollTop+F.viewportHeight+180;return t("div",{style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height},className:`${jL.iconsGridItem} ${A?jL.iconsGridItemSelected:""} ${C?jL.iconsGridShowCheckboxes:""}`,onClick:()=>{d(k),y&&"family"===c&&y(k.hash)},children:[e("div",{style:{height:null!=m?m:50},className:jL.iconsGridItemThumbnail,children:"family"===c&&g[k.hash]?e("div",{style:{color:null==p?void 0:p.colorHex,"--icon-grad-1":null!==(i=null==p?void 0:p.colorHex)&&void 0!==i?i:"#000","--icon-grad-2":null!==(o=null==p?void 0:p.colorHex2)&&void 0!==o?o:"#ff007a","--icon-color-1":null!==(a=null==p?void 0:p.colorHex)&&void 0!==a?a:"#000","--icon-color-2":null!==(s=null==p?void 0:p.colorHex2)&&void 0!==s?s:"#ff007a","--icon-color-3":null!==(l=null==p?void 0:p.colorHex3)&&void 0!==l?l:"#00C2FF","--icon-stroke-1":null!==(h=null==p?void 0:p.colorHex)&&void 0!==h?h:"#000","--icon-stroke-2":null!==(f=null==p?void 0:p.colorHex2)&&void 0!==f?f:"#ff007a","--icon-stroke-3":null!==(b=null==p?void 0:p.colorHex3)&&void 0!==b?b:"#00C2FF","--icon-fill-1":null!==(w=null==p?void 0:p.colorHex)&&void 0!==w?w:"#000","--icon-fill-2":null!==(_=null==p?void 0:p.colorHex2)&&void 0!==_?_:"#ff007a","--icon-fill-3":null!==(S=null==p?void 0:p.colorHex3)&&void 0!==S?S:"#00C2FF"},dangerouslySetInnerHTML:{__html:g[k.hash]},className:jL.iconsGridItemSvg}):e(yL,{imageId:k.hash,sourceUrl:k.imagePreviewUrl,shouldLoad:I,loader:x,alt:k.name,style:{maxHeight:null!=m?m:96},className:jL.iconsGridItemImg,decoding:"async"})}),e("div",{className:jL.iconsGridItemName,title:k.name,children:k.name}),y?e("div",{onClick:e=>{e.stopPropagation()},className:jL.iconsGridCheckbox,children:e(N,{checked:Boolean(v&&v.has(k.hash)),onChange:()=>y(k.hash)})}):null]},k.hash)})}),a&&e("div",{className:jL.iconsGridLoadingMore,children:e(S,{indicator:UL})})]}):P,o&&0===n.length&&e("div",{className:jL.iconsGridLoading,children:e(S,{indicator:UL})})]})},HL="path|rect|circle|ellipse|polygon|line|polyline|g";function $L(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const r={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},n=t.toLowerCase();return r[n]?r[n]:("currentcolor"===n||"inherit"===n||/^[a-zA-Z]+$/.test(t),null)}function WL(e,t){const r=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),n=e.match(r);return n?n[1].trim():null}function GL(e){let t=0;const r=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&WL(i[1],"fill")&&!/^none$/i.test(WL(i[1],"fill"));(o||a)&&(t+=1)}return t}function qL(e){let t=0;const r=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&WL(i[1],"stroke")&&!/^none$/i.test(WL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function YL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function XL(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),r=parseFloat(t);return Number.isNaN(r)||r<=0||r>10?null:Math.round(10*r)/10}function KL(e){const t=[],r=e.indexOf("</defs>"),n=r>=0?e.slice(r):e,i=new RegExp(`<(?:${HL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(n));){const e=XL(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${HL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(n));){const e=XL(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function ZL(e){const t=function(e){const t=[],r=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))});const n=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let i;for(;null!==(i=n.exec(e));){const e=i[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(n&&n[1]){const e=$L(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=$L(o[1]);e&&!r.has(e)&&(r.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=WL(a[1],"fill");if(e){const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))}const n=WL(a[1],"stroke");if(n){const e=$L(n);e&&!r.has(e)&&(r.add(e),t.push(n))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[n,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const n=e.match(i);if(n&&n[1]){const e=$L(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}}const n=e.match(/style\s*=\s*["']([^"']*)["']/i);if(n&&n[1])for(const e of["fill","stroke"]){const i=WL(n[1],e);if(i){const e=$L(i);e&&!r.has(e)&&(r.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:GL(e),strokesCount:qL(e),hasGradient:YL(e),strokeWidth:KL(e)}}const JL=new Map,QL="https://public-api.streamlinehq.com/v1";function eN(e,t,r,n){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>r?Promise.resolve(r(e)):e,s=null==n?void 0:n.trim(),l=i.useCallback(async e=>r?a(function(e){const{mode:t,q:r,offset:n,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",r),s.set("offset",String(n)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${QL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:r,q:n,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===r?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===r&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",n),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,r]),c=i.useCallback(async e=>{var t;const r=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),n={Accept:"application/json"};s&&(n["x-api-key"]=s);const i=await fetch(r,{method:"GET",headers:n,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let r=e;const n=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(r)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(r);if(!(/fill="url\(#/i.test(r)||/stroke="url\(#/i.test(r))){const e=function(e){var t,r,n,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=$L(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const f=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(r),t=t=>{const r=$L(t),n=r?e.get(r):void 0;return 1===n?"var(--icon-color-1)":2===n?"var(--icon-color-2)":3===n?"var(--icon-color-3)":"currentColor"};r=r.replace(/<svg([^>]*)>/i,(e,r)=>{let n=r;const i=r.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(n=n.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=r.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(n=n.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${n}>`}),r=r.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,r,n,i)=>{var o,a,s,l,c,u,d,h;let f=n;const p=n.match(/fill\s*=\s*["']([^"']*)["']/i),g=n.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=n.match(/stroke\s*=\s*["']([^"']*)["']/i),b=n.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${r}${f}${i}`})}return n&&(r=r.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,r)=>{let n=0;return`<linearGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</linearGradient>`}),r=r.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,r)=>{let n=0;return`<radialGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(r)&&(r=r.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(r)&&(r=r.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(r)||(r=r.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),r=r.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),r},[]),d=i.useCallback(async(t,n)=>{const i=[t,e?"css=1":"css=0",(null==n?void 0:n.colors)?`c=${n.colors}`:"",(null==n?void 0:n.backgroundColor)?`bg=${n.backgroundColor}`:"",null!=(null==n?void 0:n.strokeWidth)?`sw=${n.strokeWidth}`:"",null!=(null==n?void 0:n.size)?`s=${n.size}`:"",null!=(null==n?void 0:n.responsive)?`r=${n.responsive}`:"",null!=(null==n?void 0:n.strokeToFill)?`sf=${n.strokeToFill}`:""].filter(Boolean).join("|"),l=JL.get(i);if(l)return l;const c=await(async(e,t)=>{var n,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${QL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(r)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,n),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==n?void 0:n.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==n?void 0:n.colors)&&(f=u(f,{strokeWidth:null==n?void 0:n.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return JL.set(i,g),g},[o,u,e,r,a,s]),h=i.useCallback(async(e,t)=>{const n=await(async(e,t)=>{var n;const i=new URLSearchParams;i.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${QL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(r)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(n,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(new Error("Failed to read PNG blob")),r.readAsDataURL(c)})},[o,r,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const tN=({items:e,selectedHashes:t,getPngDataUrlForItem:r,dataUrlToBlob:n,clearSelection:o})=>{const{t:a}=Yn(),{options:s,state:l}=po(),c=Oo(),[u,d]=i.useState(!1),[h]=E.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=Wo(),{EmptyFolderIcon:w}=mo(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=ol({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),k=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),A=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,r,n;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(r=null==o?void 0:o.error)||void 0===r?void 0:r.message)||(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:r,items:n,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s,config:l}=e;let c=0,u=0;for(const e of r){const r=n.find(t=>t.hash===e);if(!r){u+=1;continue}const d=await a(r);if(!d){u+=1;continue}const h=Dr(`${(null===(t=r.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,l),f=await hi(o,h,i,!1,Br(l)),p=s(d,"image/png"),g=new File([p],f,{type:"image/png",lastModified:Date.now()});try{await o.uploadFile({name:f,size:g.size,type:g.type,folderId:i,data:g,extension:"png"}),c+=1}catch(e){u+=1}}return{successCount:c,failCount:u}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p,getFiles:d.getFiles,getFolders:d.getFolders},getPngDataUrlForItem:r,dataUrlToBlob:n,config:null==s?void 0:s.config});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,n,r,e,c,s,t,null==l?void 0:l.selectedFolder,a]),I=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),F=i.useCallback(()=>{C(""),p(!1)},[C]),T=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await A(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[A,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:I,resetAfterClose:F,handleCopyTreeSelect:k,handleIconsCopyOk:T,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}},rN=({apiKey:n,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Yn(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,k]=i.useState(""),[A,I]=i.useState("global"),[O,P]=i.useState(null),[L,N]=i.useState(null),[j,D]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[H,$]=i.useState(0),[W,q]=i.useState(!1),[Y,K]=i.useState(!1),[Z,J]=i.useState(!1),[Q,ee]=i.useState(null),[te,re]=i.useState({}),[ne,oe]=i.useState({}),[ae,se]=i.useState({}),[le,ce]=i.useState("#000000"),[ue,de]=i.useState("#ff007a"),[he,fe]=i.useState("#00C2FF"),[pe,ge]=i.useState(1),[me,ve]=i.useState(50),[ye,be]=i.useState(!0),[we,xe]=i.useState(!0),[Ce,_e]=i.useState(!1),Se=po(),{options:ke}=Se,Ae=i.useRef(!1),Ie=i.useRef(null),Ee=i.useRef(0),Fe=i.useRef(null),Te=i.useRef(!1),Oe=i.useRef(null),Pe=i.useRef(null===(c=null==ke?void 0:ke.config)||void 0===c?void 0:c.handleTranslate),Me=i.useRef(null===(u=null==ke?void 0:ke.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Pe.current=null===(e=null==ke?void 0:ke.config)||void 0===e?void 0:e.handleTranslate,Me.current=null===(t=null==ke?void 0:ke.config)||void 0===t?void 0:t.locale},[null===(d=null==ke?void 0:ke.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==ke?void 0:ke.config)||void 0===h?void 0:h.locale]);const Re=i.useRef(null),Le=i.useRef(null),Ne=i.useRef(null),je=i.useRef(new Set),[De,ze]=i.useState(new Set),Be=null!==(p=null===(f=null==ke?void 0:ke.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",Ue=null===(g=null==ke?void 0:ke.config)||void 0===g?void 0:g.handleProxyUrl,Ve=async e=>Ue?Promise.resolve(Ue(e)):e,{performSearch:He,fetchSvgDataUrl:$e,fetchPngDataUrl:We,normalizeSvgForCss:Ge}=eN(we,null===(m=null==ke?void 0:ke.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,Ue,Be),qe=i.useMemo(()=>{if("family"!==A||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(ae).some(t=>e.has(t))?ae:ne,r=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===r.length)return null;return function(e){const t=[],r=new Set;let n,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))}null==n&&null!=s.strokeWidth&&(n=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:n}}(r.map(e=>ZL(e)))},[U,A,ae,ne]);i.useMemo(()=>"family"===A&&(!!(null==qe?void 0:qe.hasGradient)||!!(O||"").toLowerCase().includes("gradient")),[qe,O,A]);const Ye=i.useMemo(()=>"family"===A&&U.some(e=>{const t=ne[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,A,ne]),Xe=i.useMemo(()=>"family"===A&&U.some(e=>{const t=ne[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,A,ne]),Ke=i.useMemo(()=>!!we&&(!!qe&&(qe.hasGradient||qe.colors.length>=2&&Ye)),[qe,we,Ye]),Ze=i.useMemo(()=>!!we&&(!!qe&&(qe.colors.length>=3&&Xe)),[qe,we,Xe]);i.useEffect(()=>(Ae.current=!0,()=>{var e,t,r;Ae.current=!1;try{null===(e=Re.current)||void 0===e||e.abort(),null===(t=Le.current)||void 0===t||t.abort(),null===(r=Ne.current)||void 0===r||r.abort()}catch(e){}}),[]);const Je=i.useRef(x),Qe=i.useCallback(async e=>{var t,r,n,i,o,a,s,l;const c=null!==(r=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==r?r:_;if(!c||0===c.trim().length)return;if(e.initial?Y:Z||Y)return;if(!Ae.current)return;e.initial&&(null===(n=Re.current)||void 0===n||n.abort());const u=new AbortController;Re.current=u,e.initial?(K(!0),V([]),$(0),q(!1)):J(!0);const d=e.initial?0:H,h=(e.initial,30),f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:A,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:O,g=c.trim(),m=`${f}|${p||""}|${g}|${j||""}|${d}|${h}`;if(!je.current.has(m)){je.current.add(m);try{const t=await He({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:j,signal:u.signal});if(!Ae.current)return;const r=await(async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await Ve(e.imagePreviewUrl)}))))(t.results);if(e.initial){const e=r.filter((e,t,r)=>r.findIndex(t=>t.hash===e.hash)===t);V(e)}else V(e=>{const t=new Set(e.map(e=>e.hash)),n=r.filter(e=>!t.has(e.hash));return n.length>0?[...e,...n]:e});q(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),$(d+r.length)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),ie.error(y("Request error"))}finally{Ae.current&&(e.initial?K(!1):J(!1)),je.current.delete(m)}}},[_,O,Z,Y,A,H,He,j,y]);i.useEffect(()=>{Oe.current=Qe},[Qe]),i.useEffect(()=>{if("family"===A){const e=window.setTimeout(()=>{Te.current=!1},100);return()=>window.clearTimeout(e)}Te.current=!1},[A]);const et=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const r=`${e.trim()}|${j||""}`;if(Fe.current===r&&"global"===A)return;const n=++Ee.current;let i=e.trim();if(Pe.current)try{i=await Pe.current(e,{locale:Me.current})}catch(t){console.error("IconsTab: translation error",t),i=e}n===Ee.current&&(I("global"),P(null),B(null),V([]),q(!1),$(0),ee(null),ze(new Set),k(i),await(null===(t=Oe.current)||void 0===t?void 0:t.call(Oe,{initial:!0,override:{query:i}})),Fe.current=r)},[A,j]),tt=i.useCallback(async()=>{x&&0!==x.trim().length&&(Ie.current&&(window.clearTimeout(Ie.current),Ie.current=null),await et(x))},[x,et]),rt=i.useCallback(()=>{Ee.current+=1,I("global"),P(null),N(null),B(null),D(null),k(""),V([]),J(!1),q(!1),$(0),Fe.current=null,ee(null),ze(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF")},[]);i.useEffect(()=>{const e=Je.current;e&&e.trim().length>=3&&et(e)},[]),i.useEffect(()=>{const e=x.trim();Ie.current&&(window.clearTimeout(Ie.current),Ie.current=null),e.length<3?rt():Ie.current=window.setTimeout(()=>{et(e)},700)},[x,j,rt,et]);const nt=i.useCallback(e=>{if("global"===A){if(!e.familySlug||!_)return;return Ie.current&&(window.clearTimeout(Ie.current),Ie.current=null),Te.current=!0,I("family"),P(e.familySlug),N(e.hash),B(e.categoryName||null),V([]),J(!1),q(!1),$(0),ee(null),ze(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF"),void Qe({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}ee(e.hash)},[_,Qe,A]),it=i.useCallback(()=>{const e=_.trim();I("global"),P(null),N(null),B(null),V([]),J(!1),q(!1),$(0),ee(null),ze(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF"),e&&Qe({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,Qe]);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=new Set(U.map(e=>e.hash));let r=U.map(e=>e.hash).filter(e=>!te[e]||!ne[e]);if(!L||t.has(L)||ae[L]||(r=[L,...r]),0===r.length)return;let n=!1;null===(e=Le.current)||void 0===e||e.abort();const i=new AbortController;return Le.current=i,Promise.all(r.map(e=>$e(e,{colors:we?void 0:le,strokeWidth:pe,size:me,responsive:ye,signal:i.signal}).then(t=>({h:e,r:t})).catch(()=>null))).then(e=>{if(n||!Ae.current)return;const t={},r={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,r[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&re(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&oe(e=>Object.assign(Object.assign({},e),r)),Object.keys(i).length>0&&se(e=>Object.assign(Object.assign({},e),i))}),()=>{n=!0,i.abort()}},[le,L,$e,U,A,ae,ye,me,pe,ne,te,we]),i.useEffect(()=>{if("family"!==A)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},r={};let n=!1;e.forEach(e=>{const i=ae[e]||ne[e];if(!i)return;const o=Ge(i,{strokeWidth:"number"==typeof pe?pe:void 0});o&&o!==ne[e]&&(t[e]=o,r[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,n=!0)}),n&&(Object.keys(t).length>0&&oe(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&re(e=>Object.assign(Object.assign({},e),r)))},[U,A,Ge,ae,pe,ne]);const ot=i.useRef(null);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=L&&ae[L]?L:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!ae[t])return;if(ot.current===O)return;const r=ae[t];if(!r)return;ot.current=O;const n=function(e){var t,r,n,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=$L(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const p=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(r),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const r=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r)){const e=r.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const n=r.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(n)return"#"+[1,2,3].map(e=>parseInt(n[e],10).toString(16).padStart(2,"0")).join("");const i=r.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[r.toLowerCase()])&&void 0!==t?t:$L(r)||"#000000"}(e)};n[0]&&ce(i(n[0])),n[1]&&de(i(n[1])),n[2]&&fe(i(n[2]))},[U,A,ae,O,L]),i.useEffect(()=>{"family"!==A&&(ot.current=null)},[A]);const at=i.useRef(null);i.useEffect(()=>{if("family"!==A||!O||0===U.length)return;const e=U[0];if(!e||!ae[e.hash])return;if(at.current===O)return;const t=ae[e.hash];if(!t)return;const r=ZL(t);"number"==typeof r.strokeWidth&&r.strokeWidth>0&&(at.current=O,ge(r.strokeWidth))},[U,A,ae,O]),i.useEffect(()=>{"family"!==A&&(at.current=null)},[A]);const st=i.useCallback(e=>function(e,t){const{colorHex:r,colorHex2:n,colorHex3:i}=t,o=[`--icon-grad-1: ${r}`,`--icon-grad-2: ${n}`,`--icon-stroke-1: ${r}`,`--icon-stroke-2: ${n}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${r}`,`--icon-fill-2: ${n}`,`--icon-fill-3: ${i}`,`color: ${r}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):r+=` style="${o}"`,`<svg${r}>`});return a=a.replace(/var\(--icon-color-1\)/g,r).replace(/var\(--icon-color-2\)/g,n).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,r).replace(/var\(--icon-fill-2\)/g,n).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,r).replace(/var\(--icon-stroke-2\)/g,n).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,r).replace(/var\(--icon-grad-2\)/g,n).replace(/currentColor/g,r),a}(e,{colorHex:le,colorHex2:ue,colorHex3:he}),[le,ue,he]),lt=i.useCallback(e=>{ze(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ct=i.useCallback(()=>{ze(new Set)},[]),ut=i.useMemo(()=>{if(1===De.size){const[e]=Array.from(De);return U.find(t=>t.hash===e)||null}return 0===De.size&&Q&&U.find(e=>e.hash===Q)||null},[U,Q,De]),dt=i.useCallback((e,t="image/png")=>{try{const r=e.split(",");if(r.length<2)return new Blob([],{type:t});const n=r[1]||"",i=atob(n),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),ht=i.useCallback(async(e,t)=>{try{const r=async e=>{const t="family"===A?st(e):e,r=function(e,t){const r=e.match(/\swidth="([0-9.]+)(px)?"/i),n=e.match(/\sheight="([0-9.]+)(px)?"/i);if(r&&n){const e=parseFloat(r[1]),i=parseFloat(n[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const r=e/i;return r>=1?{width:t,height:Math.max(1,Math.round(t/r))}:{width:Math.max(1,Math.round(t*r)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const r=parseFloat(e[2]),n=parseFloat(e[3]);if(Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0){const e=r/n;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,me);return async function(e,t,r){const n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);try{const e=new Image;return await new Promise((n,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*r));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),n(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,r.width,r.height)},n=async e=>{const n=await $e(e,{colors:we?void 0:le,strokeWidth:"number"==typeof pe?pe:void 0,size:me,responsive:ye,signal:t}),i=n.original||n.text;return r(i)};if("family"!==A)try{return await We(e.hash,{size:me,colors:we?void 0:le,strokeWidth:"number"==typeof pe?pe:void 0,signal:t})}catch(t){return e.hash?await n(e.hash):null}const i=ne[e.hash]||ae[e.hash];return i?r(i):e.hash?await n(e.hash):null}catch(e){return null}},[st,le,$e,We,A,ae,ye,me,pe,ne,we]),ft=i.useCallback(async e=>{var t;try{if(!Ae.current)return;_e(!0),null===(t=Ne.current)||void 0===t||t.abort();const r=new AbortController;Ne.current=r;const n=await ht(e,r.signal);if(!Ae.current||!n)return;await Promise.resolve(o(n))}catch(e){console.error("IconsTab: insert error",e),ie.error(y("Request error"))}finally{Ae.current&&_e(!1)}},[o,ht,y]);i.useCallback(()=>{var e;ee(null),ct();const t=null===(e=null==ke?void 0:ke.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[ct,ke]);const{isCopyIconsModalVisible:pt,isCopyLoading:gt,copyForm:mt,openCopyModal:vt,closeCopyModal:yt,resetAfterClose:bt,handleCopyTreeSelect:wt,handleIconsCopyOk:xt,fetchChildFolders:Ct,generateMenuItemsFromFolders:_t,handleCreateFolderAndCopy:St}=tN({items:U,selectedHashes:De,getPngDataUrlForItem:ht,dataUrlToBlob:dt,clearSelection:ct}),kt=Boolean(_.trim())&&(U.length>0||Y),At=kt&&De.size>0;return t(r,{children:[t("div",{className:`${jL.iconsTab} ${_.trim()?jL.hasSearch:""}`,children:[kt&&At?t("div",{className:jL.iconsHeaderContainer,children:[t("div",{className:jL.iconsHeaderContainerLeft,children:[t(T.Text,{type:"secondary",children:[De.size," ",y("selected")]}),e(M,{icon:e(Fi,{size:16}),onClick:ct,children:y("Deselected")})]}),e(R,{children:e(M,{icon:e(gi,{size:16}),onClick:vt,children:y("Copy to folder")})})]}):e(zL,{query:x,onQueryChange:C,onSubmit:tt,styleFilter:j,onStyleChange:D,hasResults:U.length>0||Y,inputRef:l}),"family"===A?e(BL,{mode:A,familySlug:O,categoryName:z,colorHex:le,setColorHex:ce,colorHex2:ue,setColorHex2:de,colorHex3:he,setColorHex3:fe,sizePx:me,setSizePx:ve,strokeWidth:pe,setStrokeWidth:ge,responsiveSvg:ye,setResponsiveSvg:be,useCssColor:we,setUseCssColor:xe,showSecondColor:Ke,showThirdColor:Ze,styleFilter:j,onBack:it}):null,e(VL,{items:U,loading:Y,isCollectingResults:Z,hasMore:W,hasQuery:Boolean(_.trim()),mode:A,selectedHash:Q,onItemClick:nt,onInsert:ft,onLoadMore:()=>{Qe({initial:!1})},colorVars:{colorHex:le,colorHex2:ue,colorHex3:he},svgTextMap:ne,previewSize:me,selectedHashes:De,onToggleSelect:lt}),ut?t("div",{className:jL.iconsBottomBar,children:[e(X,{className:"zero-divider"}),e("div",{className:jL.iconsBottomBarContent,children:e(R,{children:e(M,{size:"large",type:"primary",style:{height:40},loading:Ce,onClick:()=>ft(ut),children:y("Choose")})})})]}):null]}),e(G,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:pt,onCancel:()=>{gt||yt()},maskClosable:!gt,closable:!gt,keyboard:!gt,footer:t("div",{className:nl.formFooter,children:[t(M,{className:nl.folderButton,onClick:St,loading:gt,children:[e(wi,{size:18,strokeWidth:null===(v=ke.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(M,{type:"primary",className:nl.folderButton,onClick:()=>{yt()},loading:gt,children:y("Done")})]}),afterClose:()=>bt(),children:t("div",{className:jL.copyToFolderModalBody,children:[gt?e("div",{className:jL.copyToFolderModalLoadingOverlay,children:e(S,{size:"large"})}):null,e(E,{form:mt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:nl.foldersWrapper,children:[e(E.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:nl.formItem,children:e(tl,{onSelect:wt,generateMenuItems:()=>_t({targetForm:mt,onTreeSelect:wt,onComplete:xt,actionButtonText:y("Copy here")}),fetchChildFolders:Ct,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(E.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(E.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},nN=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const r=document.createElement("style");if(r.type="text/css",r.dataset.themeVariablesFm="true",r.setAttribute("data-file-manager","true"),Object.entries(e).length){let n="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(n+=`\t--${e}: ${t};\n`)}),n=`.em-filemanager {\n${n}}`,r.appendChild(document.createTextNode(n));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(r,i):t.insertBefore(r,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:iN,Content:oN}=J,aN={keywords:""},sN=()=>{var s,l,d;const h=Wo(),f=ss(),p=(()=>{var e,t;const{state:r,actions:n,options:i}=po(),{selectedFolder:o,pathHistory:a,folders:s}=r,{t:l}=Yn(),{setSelectedFolder:u,setPathHistory:d}=n,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const r=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!r)return[];const n=new Set(t);return n.add(e),r.parentId?r.parentId===r.id?(console.warn(`Cycle detected: folder ${r.id} is a parent of itself`),[{id:r.id,name:r.name+" (ошибка)"}]):[...f(r.parentId,n),{id:r.id,name:r.name}]:[{id:r.id,name:r.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const r=!0===(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),n=h();try{if(!r)return void localStorage.removeItem(n);e?localStorage.setItem(n,e):localStorage.removeItem(n)}catch(e){}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}const t=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!t)return void console.warn("⚠️ Folder not found:",e);const r=f(e),n=[{id:"folders",name:l("Folders")},...r];null==d||d(n),i.onPathChange&&i.onPathChange(n.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),r=t[t.length-1],n="folders"===r.id?void 0:r.id;null==u||u(n||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),g=(()=>{const{state:e,actions:t}=po(),{pagination:r}=e,{setPagination:n}=t,i=c((e,t)=>{const i=t||r.pageSize;null==n||n({current:e,pageSize:i,total:r.total})},[r.pageSize,r.total,n]);return{state:{pagination:r},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=n.useState(()=>{const e=localStorage.getItem(ls);return e?Math.max(290,parseInt(e,10)):298}),[r,i]=n.useState(!1),[o,a]=n.useState(!1),[s,l]=n.useState(0),c=n.useCallback(()=>{t(298),localStorage.setItem(ls,298..toString())},[]),u=n.useCallback(r=>{r.preventDefault(),r.stopPropagation(),i(!0),document.body.classList.add("resizing");const n=r.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const r=Math.max(Math.min(o+e.clientX-n,600),290);s=r,t(r),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(ls,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return n.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:r,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[r,n]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>ui(e.size),[]),f=c((e,r)=>{const i=r.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),n(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,r)=>{const i={id:d(),folderId:e,name:r,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),n(!0),a(!1),i.id},[d]),g=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,r))}):t))},[]),m=c((e,r)=>{r&&l.current.set(e,r),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==r?void 0:r.name)&&(e.name=r.name),(null==r?void 0:r.size)&&void 0===t.size&&(e.size=ui(r.size)),e}return t}))},[]),v=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:r}):t))},[]),y=c(()=>{n(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:r,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=Ga(),{deleteItems:b}=Go(),w=Oo(),{t:C}=Yn(),{options:_,state:k,actions:A}=po(),I=_,E=null==I?void 0:I.onChangeSelection,F=k,T=null==I?void 0:I.config,{dataProviders:O}=I,{form:P,urlForm:R,renameForm:L,moveForm:N,renameFolderForm:j,copyForm:D,isModalVisible:z,isUrlModalVisible:B,isMoveModalVisible:U,isRenameFolderModalVisible:V,isCopyModalVisible:H,isDeleteConfirmVisible:$,folderToRename:W,activeLibraryItem:G}=k,{setIsUrlModalVisible:q,setActiveLibraryItem:Y}=A,{config:K}=_,{DropZoneFileIcon:Z}=mo(),[Q,ee]=o(!1),[te,re]=o(!1),[ne,ie]=o(!1),oe=u(0),ae=u(!1);ae.current=te;const se=i.useRef(null),le=i.useRef([]),[ce,ue]=o(!1),[de,he]=o(!1),fe=Za(e=>e.selectedFiles),pe=Za(e=>e.clearSelection),ge=Za(e=>e.syncVisibleFiles),{folders:me,loading:ve}=h.state,{fetchFolders:ye,fetchChildFolders:be,handleCreateFolder:we,handleModalOk:xe,handleModalCancel:Ce,generateMenuItems:_e}=h.actions,Se=(e=>{var t;const{state:r,actions:n,options:i}=po(),{t:o}=Yn(),a=Oo(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=r,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=n,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,r;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error(o("renameFolder is not implemented in dataProviders"));const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(r=s.parentId)&&void 0!==r?r:null}}),y(),await e(),l!==s.id&&n.setSelectedFolder&&n.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),error:{message:e instanceof Error?e.message:String(e)}}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(ye),{files:ke,loading:Ae,isRenamingFile:Ie,fileToRename:Ee}=f.state,{fetchFiles:Te,handleDeleteFile:Oe,handleDeleteFolder:Pe,handleAddFile:Me,handleAddFileByUrl:Re,showRenameModal:Le,handleRenameCancel:Ne,handleRenameOk:je,handleDroppedFiles:De,showMoveModal:ze,handleMoveCancel:Be,handleMoveOk:Ue,handleCopyOk:Ve,handleCopyCancel:He,showDeleteConfirm:$e,handleDeleteConfirmCancel:We,handleDeleteConfirmOk:Ge}=f.actions,{selectedFolder:qe,pathHistory:Ye}=p.state,{handleFolderSelect:Xe,handleItemClick:Ke}=p.actions,{pagination:Ze}=g.state,Je=Eo(Te),{searchTerm:Qe,sortBy:et,sortOrder:tt}=Je.state,{handleSearch:rt,handleSort:nt,handlePaginationChange:it}=Je.actions,ot=c(async()=>{const e=(e=>Uo(e))(Ye||[]);try{await $o({options:I,pathFolder:e,dataProviders:null==I?void 0:I.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await ye(),await Te({folderId:qe||"",page:Ze.current,limit:Ze.pageSize,search:Qe,sortBy:et,sortOrder:tt,itemType:"all"})},[Te,ye,I,Ze,Ye,Qe,qe,et,tt]),at=(({files:e,fetchFiles:t,selectedFolder:r})=>{var i;const{t:o}=Yn(),a=Oo(),{options:s,actions:l,state:c}=n.useContext(fo),{setActiveLibraryItem:u}=l,{activeLibraryItem:d}=c,h=Ga(),[f,p]=n.useState(!1),[g,m]=n.useState(null),v=n.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return gr.includes(t)}const r=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!r&&gr.includes(r)},[]),y=n.useCallback(async(e,t)=>{var r,n;const{dataProviders:i}=s;if(!1===(null===(n=null===(r=s.config)||void 0===r?void 0:r.features)||void 0===n?void 0:n.enableUpdateFile))throw new qo(o("Updating files is disabled by configuration"),"UnsupportedOperation");if(!e.id||!e.thumbnail||!(null==i?void 0:i.updateFile))throw new qo(o("Failed to save changes"),"UnsupportedOperation");const a=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),l=Fr(a),c=e.name.lastIndexOf("."),u=`${c>0?e.name.substring(0,c):e.name}.${l}`,d=(null==t?void 0:t.blob)||Mr(e.thumbnail,a);return i.updateFile(e.id,{name:u,type:a,data:d})},[s,o]),b=n.useCallback(async(e,t)=>{var r,n,i;if(!e.thumbnail)throw new qo(o("Failed to save changes"),"ValidationError");const a=!(!0===(null===(r=s.config)||void 0===r?void 0:r.saveCopyToCurrentFolder))||(null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id),l=a?void 0:null!==(i=e.folderId)&&void 0!==i?i:void 0,c=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),u=(null==t?void 0:t.blob)||Mr(e.thumbnail,c),d=new File([u],e.name,{type:c,lastModified:Date.now()}),f=await h.uploadFileWithProvider(d,l,void 0,a);if(!f)throw new qo(o("Failed to save image copy"),"FileWriteError");return f},[h,null===(i=s.config)||void 0===i?void 0:i.saveCopyToCurrentFolder,o]),w=n.useCallback(t=>{let r;if(t)r=t;else{const t=Za.getState().selectedFiles;if(1!==t.size)return;const n=Array.from(t)[0];if(r=e.find(e=>e.id===n),!r||r.isFolder||!v(r))return}u&&u(sr),m(r),p(!0)},[e,v,p,u]),x=n.useCallback(()=>{u&&d===sr&&u(rr),p(!1),m(null)},[d,u]),C=n.useCallback(async(e,n)=>{var i,l,c,u,d,h;try{const c=await y(e,n);return a.success({id:"IMAGE_UPDATE_SUCCESS",message:o("Success"),description:o("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(i=null==c?void 0:c.id)&&void 0!==i?i:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&s.onEditorOk&&s.onEditorOk(c,{mode:n.mode}),await t({folderId:r||""}),x(),null!=c?c:void 0}catch(t){const r=No(t),n=null!==(u=null!==(c=Ro(null==r?void 0:r.code,o))&&void 0!==c?c:null==r?void 0:r.message)&&void 0!==u?u:o("Failed to save changes");throw a.error({id:"IMAGE_SAVE_FAILED",message:n,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[y,s,t,r,a,x,o]),_=n.useCallback(async(e,n)=>{var i,l,c,u,d,h;try{const c=await b(e,n);return a.success({id:"IMAGE_SAVE_COPY_SUCCESS",message:o("Success"),description:o("Image copy saved successfully"),placement:"bottomRight",data:{itemId:null!==(i=null==c?void 0:c.id)&&void 0!==i?i:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&s.onEditorOk&&s.onEditorOk(c,{mode:n.mode}),await t({folderId:r||""}),x(),null!=c?c:void 0}catch(t){const r=No(t),n=null!==(u=null!==(c=Ro(null==r?void 0:r.code,o))&&void 0!==c?c:null==r?void 0:r.message)&&void 0!==u?u:o("Failed to save image copy");throw a.error({id:"IMAGE_SAVE_COPY_FAILED",message:n,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[b,s,t,r,a,x,o]);return{isPixieEditorVisible:f,editingFile:g,handleEdit:w,handlePixieEditorSave:C,handlePixieEditorSaveCopy:_,handlePixieEditorClose:x}})({files:ke||[],fetchFiles:Te,selectedFolder:qe||null}),[st,lt]=o(!1),ct=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,r=e.currentTarget;t&&r.contains(t)||(oe.current+=1,oe.current>0&&ee(!0))},[]),ut=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,r=e.currentTarget;if(t&&!r.contains(t))oe.current=Math.max(0,oe.current-1),oe.current<=0&&ee(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&r.contains(e))return}},[]),dt=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),ht=c(e=>{e.preventDefault(),e.stopPropagation(),ee(!1),oe.current=0;const t=(()=>{var t;const r=e.dataTransfer;if(!r)return[];if(null===(t=r.files)||void 0===t?void 0:t.length)return Array.from(r.files);const n=[];if(r.items)for(let e=0;e<r.items.length;e++){const t=r.items[e].getAsFile();t&&n.push(t)}return n})();t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{lt(!1)}))},[De]),ft=c(()=>{ee(!1),oe.current=0,document.body.removeAttribute("data-fm-dragging"),ie(!1),re(!1)},[]);i.useEffect(()=>{le.current=ke||[]},[ke]);const pt=null==F?void 0:F.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=!1;const r=r=>{var n,i;!t&&(null===(i=null===(n=r.dataTransfer)||void 0===n?void 0:n.types)||void 0===i?void 0:i.includes("Files"))&&(t=!0,ie(!0),e(!0),pt===rr&&re(!0))},n=r=>{const n=r.relatedTarget;(!n||!document.documentElement.contains(n))&&t&&(t=!1,ie(!1),re(!1),e(!1))};return window.addEventListener("dragenter",r,!0),window.addEventListener("dragleave",n,!0),()=>{window.removeEventListener("dragenter",r,!0),window.removeEventListener("dragleave",n,!0),document.body.removeAttribute("data-fm-dragging")}},[pt]),a(()=>{const e=e=>{var t,r;if(document.body.removeAttribute("data-fm-dragging"),ie(!1),!(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files")))return;e.preventDefault();const n=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const r=[];if(e.items)for(let t=0;t<e.items.length;t++){const n=e.items[t].getAsFile();n&&r.push(n)}return r})(e.dataTransfer);if(!n.length)return;const i=e.target,o=i.closest(`.${xs.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(ae.current||Q||o||a)&&(e.preventDefault(),e.stopPropagation(),re(!1),ee(!1),oe.current=0,lt(!0),De(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>lt(!1)))},t=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||(document.body.setAttribute("data-fm-dragging","true"),ie(!0)),pt!==rr||ae.current||re(!0))},r=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"),ie(!0))},n={capture:!0,passive:!1};return window.addEventListener("drop",e,n),window.addEventListener("dragover",t,n),window.addEventListener("dragenter",r,n),()=>{window.removeEventListener("drop",e,n),window.removeEventListener("dragover",t,n),window.removeEventListener("dragenter",r,n)}},[Q,De,pt]),a(()=>{const e=e=>{Q&&ft(),re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[Q,ft]),a(()=>{let e=null;const t=t=>{Q&&(e=setTimeout(()=>{Q&&ft()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[Q,ft]),a(()=>{const e=e=>{"Escape"===e.key&&Q&&ft()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Q,ft]),a(()=>{const e=e=>{Q&&setTimeout(()=>{Q&&ft()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[Q,ft]);const gt=i.useCallback(async()=>{await Ge(),await ye(),qe===lr&&be&&await be(lr),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[ye,be,Ge,qe]),mt=i.useCallback(()=>{he(!0)},[]),vt=i.useCallback(async()=>{var e,t;if(qe!==lr)return console.error("Clear trash called outside of trash folder"),void he(!1);try{if(null==O?void 0:O.cleanTrash){const t=await O.cleanTrash();await Te({folderId:lr}),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}else{const e=le.current||[];if(0===e.length)return void he(!1);const r=e.map(e=>({id:e.id,isFolder:e.isFolder})),n=await b({items:r,selectedFolder:lr,getItemNameById:t=>{var r;return(null===(r=e.find(e=>e.id===t))||void 0===r?void 0:r.name)||t||""},showNotifications:!1});await Te({folderId:lr}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=n;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:C("Trash partially cleared"),description:C("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}he(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:C("Error clearing trash"),placement:"bottomRight"}),he(!1)}},[qe,O,Te,w,C,b]),yt=i.useCallback(()=>{he(!1)},[]),bt=i.useCallback(async e=>{var t;await Ue(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ue]),wt=i.useCallback(async e=>{var t;await Ve(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ve]),xt=i.useCallback(async()=>{let e=[],t=new Map;const r=null==I?void 0:I.config;await Me({onStartBatch:n=>{e=v.startUpload(qe||void 0,n),t=new Map,n.forEach((n,i)=>{const o=e[i];o&&(t.set(n.name,o),t.set(Dr(n.name,r),o))})},onStart:n=>{if(0===e.length){e=v.startUpload(qe||void 0,[n]);const i=e[0];i&&(t.set(n.name,i),t.set(Dr(n.name,r),i))}},onProgress:(e,r)=>{const n=t.get(e);n&&v.updateProgress(n,r)},onComplete:async e=>{var r;const n=t.get(e);if(n){await new Promise(e=>setTimeout(e,100));const t=null==ke?void 0:ke.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(n,t)}await(null===(r=se.current)||void 0===r?void 0:r.refreshFileCounts())},onError:(r,n,i)=>{var o;const a=null!==(o=t.get(r))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,n)},onBatchComplete:async r=>{var n,i,o,a,s,l,c,u;for(let u=0;u<r.successes.length;u++){const d=r.successes[u],h=null===(n=r.uploadedFiles)||void 0===n?void 0:n.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:qe)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ke?void 0:ke.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}r.errors.forEach(({fileName:e,error:r})=>{const n=t.get(e);n&&v.markAsError(n,r)}),await(null===(u=se.current)||void 0===u?void 0:u.refreshFileCounts())}})},[Me,v,ke,qe,null==I?void 0:I.config]),Ct=i.useCallback(async(e,t,r,n)=>{var i,o;try{ue(!0);let a=r||"uploaded-file";if(!r&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(qe||void 0,a);try{const r=await Re(e,t,!0,null!=n?n:"uploadByUrl");if(v.updateProgress(s,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=se.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=No(e),r=Bo(t,C);v.markAsError(s,r)}}finally{ue(!1)}},[Re,v,qe,ke,C]),_t=i.useCallback(async({file:e})=>{var t;const r=v.startUpload(qe||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);const o=n&&n.folderId||qe||null;return Xe&&Xe(o&&"folders"!==o?o:"folders"),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts()),n}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[y,v,qe,ke,Xe]),St=i.useCallback(async e=>{var t;if(De){const r=v.startUpload(qe||void 0,e);e.forEach(async(e,t)=>{const n=r[t];if(!n)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(n,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await De(e),r.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}},[De,v,qe]),kt=i.useCallback(async e=>{var t;await Pe(e),await ye(),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Pe,ye]),At=(({files:e,clearSelection:t,showRenameModal:r,showMoveModal:i,showCopyModal:o,handleDeleteFile:a,handleDeleteFolder:s,showDeleteConfirm:l,onEdit:c})=>{const u=n.useCallback(()=>{t()},[t]),d=n.useCallback(e=>{const t=Za.getState().selectedFiles;if(t&&1===t.size||e){const n=e||Array.from(t)[0];r(n)}},[r]),h=n.useCallback(t=>{const r=Za.getState().selectedFiles;if(r&&r.size>0||(null==t?void 0:t.id)){if(l)return void l();(t?[t.id]:r).forEach(t=>{const r=e.find(e=>e.id===t);r?r.isFolder?s(t):a(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[e,a,s,l]);return{handleClearSelection:u,handleRename:d,handleDeleteSelected:h,handleCopy:n.useCallback(()=>{o()},[o]),handleMove:n.useCallback(()=>{i()},[i]),handleEdit:n.useCallback(()=>{c()},[c])}})({files:ke||[],clearSelection:pe,showRenameModal:Le,showMoveModal:ze,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:Oe,handleDeleteFolder:kt,showDeleteConfirm:$e,onEdit:at.handleEdit}),It=ve||Ae||st;a(()=>{Sr()},[]),x(()=>{G!==rr?pe():ge(ke||[])},[G,ke,ge,pe]),a(()=>{if(!E||G!==rr)return;if(!ur.current)return void(ur.current=!0);const e=(Array.isArray(ke)?ke:[]).filter(e=>fe.has(e.id));E(e)},[G,ke,fe,E]),i.useEffect(()=>{if(!Xe||0===me.length)return;const e=!1!==(null==T?void 0:T.rememberLastFolder),t=`em_fm:lastFolder:${(null==T?void 0:T.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),r=e&&me.some(t=>t.id===e);if(r)return void Xe(e)}catch(e){}qe||Xe("folders")},[qe,Xe,me,null==T?void 0:T.rememberLastFolder,null==T?void 0:T.projectId]);const{handleRenameFolderCancel:Et,handleRenameFolderOk:Ft}=Se.actions;a(()=>{const e=async e=>{if(G!==rr)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const r=e.clipboardData;if(!r)return;const n=Array.from(r.items),i=n.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await St(t)))}const o=n.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const r=t.trim();if(r.startsWith("http://")||r.startsWith("https://"))e.preventDefault(),await Ct(r);else if(r.includes("<meta")||r.includes("http")){const t=r.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await Ct(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[G,Ct,St]);const Tt=u(Ze);a(()=>{Tt.current=Ze},[Ze]);const Ot=c(e=>{it(e.current||Tt.current.current,e.pageSize||Tt.current.pageSize)},[it]),Pt=c(e=>{null==Ke||Ke(e)},[Ke]),Mt=i.useCallback(e=>{const{sortBy:t,sortOrder:r}=(e=>{const[t,r]=e.split("-");return{sortBy:t,sortOrder:r}})(e);nt(t,r)},[nt]),[Rt,Lt]=o(aN),[Nt,jt]=o([]),Dt=u(null),[zt,Bt]=o(vr),[Ut,Vt]=o([]),Ht=u(null),[$t,Wt]=o(""),Gt=u(null),[qt,Yt]=o(""),[Xt,Kt]=o([]),Zt=i.useRef(void 0),[Jt,Qt]=o(!1),[er,tr]=o(!1),cr=i.useRef(null),ur=i.useRef(!1),dr=i.useRef(G),hr=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const r=e.substring(0,t),n=r.match(/^data:([^;]+)/),i=n&&n[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(r)){const r=e.substring(t+1),n=atob(r),a=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)a[e]=n.charCodeAt(e);o=new Blob([a],{type:i})}else{const r=decodeURIComponent(e.substring(t+1));o=new Blob([r],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),fr=i.useCallback(async e=>{var t;const r=v.startUpload(qe||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[v,ke,y,qe]),pr=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=hr(e);if(!t)return;return void await fr(t)}e&&await Ct(e,void 0,void 0,"iconStock")},[hr,Ct,fr]),yr=c(async()=>{const e=null==K?void 0:K.fileForEdit;if(Zt.current===e)return;if(G===sr&&e&&!at.editingFile){Zt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==at||at.handleEdit({thumbnail:e,saveWithoutFolder:!0}));const t=await y.resolveFileForEditByUrl(e);Zt.current===e&&(null==at||at.handleEdit(t))}}catch(t){Zt.current===e&&(Zt.current=null),console.error("Failed to open file in editor:",t),null==at||at.handlePixieEditorClose()}}},[null==K?void 0:K.fileForEdit,G,at,y]);a(()=>{yr()},[yr]),a(()=>{var e,t,r,n;const i=dr.current;dr.current=G,G===rr?(jt([]),Lt(aN),Vt([]),Bt(vr),Kt([]),Yt(""),tr(!1),Qt(!1),i===rr||i!==ir&&i!==nr&&i!==ar||rt("")):G===ar?null===(e=cr.current)||void 0===e||e.focus():G===nr?null===(t=Dt.current)||void 0===t||t.focus():G===ir?null===(r=Ht.current)||void 0===r||r.focus():G===or&&(null===(n=Gt.current)||void 0===n||n.focus())},[G,rt]);const br=i.useCallback(async()=>{var e;await Ft(),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts())},[Ft]),wr=fe.size,xr=i.useMemo(()=>{var e,t,r;if(1!==wr)return!1;const[n]=Array.from(fe),i=ke.find(e=>e.id===n);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(r=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==r?r:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&mr.includes(s)},[wr,fe,ke]),Cr=c(e=>{var t;return e?(null===(t=e.files)||void 0===t?void 0:t.length)?Array.from(e.files):e.items?Array.from(e.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[]:[]},[]);return t(r,{children:[ne&&pt===rr&&Fe(e("div",{className:xs.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&!ae.current&&re(!0)},onDragEnter:e=>{var t,r;e.preventDefault(),e.stopPropagation(),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&re(!0)},onDragLeave:e=>{const t=e.relatedTarget;t&&document.documentElement.contains(t)||(re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging"))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),ie(!1),re(!1),document.body.removeAttribute("data-fm-dragging");const t=Cr(e.dataTransfer);t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true"}),document.body),te&&Fe(e("div",{className:xs.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging");const t=Cr(e.dataTransfer);t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true",children:t("div",{className:xs.dragOverlayInner,children:[e("div",{className:xs.uploadIcon,children:e(Z,{})}),e("div",{className:xs.textTitle,children:C("Drop files here to upload")}),e("div",{className:xs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),document.body),e(J,{className:"file-manager__layout",children:t("div",{className:xs.filesContainer,"data-files-container":"true",onDragOver:dt,onDragLeave:ut,onDragEnter:ct,onDrop:ht,children:[Q&&e("div",{className:xs.dragOverlay,children:t("div",{className:xs.dragOverlayInner,children:[e("div",{className:xs.uploadIcon,children:e(Z,{})}),e("div",{className:xs.textTitle,children:C("Drop files here to upload")}),e("div",{className:xs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(J,{className:"file-manager__content",children:[t(iN,{width:320,theme:"light",className:"file-manager-sider",children:[e(cl,{ref:se,selectedFolder:qe||"folders",generateMenuItems:_e,onFolderSelect:e=>null==Xe?void 0:Xe(e),folders:me||[],fetchFolders:ye,fetchChildFolders:be,handleAddFile:xt,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleDeleteFolder:kt,handleCreateFolder:we,activeLibraryItem:G,setActiveLibraryItem:e=>null==Y?void 0:Y(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(J,{className:"file-manager__main-content",children:[st&&e(rl,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(oN,{className:"main-content",children:[e(pL,{activeLibraryItem:G,selectedFolder:(null===(s=null==me?void 0:me.find(e=>(null==e?void 0:e.id)===qe))||void 0===s?void 0:s.name)||C("Folders"),isTrashFolder:"Trash"===qe,onClearTrash:mt,files:ke||[],loading:It,onRefresh:ot,refreshDisabled:Ae||ve,showRefresh:!(!(null===(l=null==I?void 0:I.apiEndpoints)||void 0===l?void 0:l.clearCache)&&!(null===(d=null==I?void 0:I.dataProviders)||void 0===d?void 0:d.clearCache))}),e(X,{className:"zero-divider"}),G===rr&&e(Ws,{searchTerm:Qe,handleAddFile:xt,files:ke||[],handleSearch:rt,sortBy:et,sortOrder:tt,handleSortOptionChange:Mt,pagination:Ze,setPagination:Ot,loading:It,handleItemClick:Pt,onClearSelection:At.handleClearSelection,onRename:At.handleRename,onCopy:At.handleCopy,onMove:At.handleMove,onDelete:At.handleDeleteSelected,showRenameModal:Le,showDeleteConfirm:$e,showCopyModal:f.actions.showCopyModal||(()=>{}),showMoveModal:ze,onEdit:at.handleEdit,getFileData:y.getFileData}),G===nr&&e(CL,{imageGifList:Nt,setImageGifList:jt,currentReqGif:Rt,setCurrentReqGif:Lt,inputRef:Dt,customRequest:(e,t)=>Ct(e,void 0,t,"gif")}),G===ir&&e(AL,{imageStockList:Ut,setImageStockList:Vt,currentReq:zt,setCurrentReq:Bt,inputRef:Ht,customRequest:(e,t)=>Ct(e,void 0,t,"imageStock")}),G===or&&e(rN,{apiKey:null==K?void 0:K.STREAMLINE_API_KEY,customRequest:pr,query:$t,setQuery:Wt,inputRef:Gt}),G===ar&&!!(null==K?void 0:K.sseQuery)&&e(NL,{imageAiList:Xt,setImageAiList:Kt,aiImageRequest:qt,setAiImageRequest:Yt,inputAiRef:cr,customRequest:_t,isLoadingAi:Jt,setIsLoadingAi:Qt,isImageUploaded:er,setIsImageUploaded:tr}),G===sr&&e(r,{}),e(r,{children:xr&&t(r,{children:[e(X,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(M,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(_.onEditorOk){const e=Array.from(fe)[0],t=ke.find(t=>t.id===e);t&&_.onEditorOk(t)}},children:C("Choose")})})]})})]})]})]}),ce&&!v.isUploadVisible&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(S,{size:"large"})}),e(sl,{isModalVisible:z,handleModalOk:xe,handleModalCancel:Ce,form:P,selectedFolder:qe||null,folders:me||[],isUrlModalVisible:B,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleAddFileByUrl:Ct,urlForm:R,isRenameModalVisible:Ie,handleRenameOk:()=>null==je?void 0:je(),handleRenameCancel:()=>null==Ne?void 0:Ne(),renameForm:L,fileToRename:Ee,files:ke||[],isMoveModalVisible:U,handleMoveOk:bt,handleMoveCancel:Be,moveForm:N,selectedFiles:fe||new Set,isRenameFolderModalVisible:V,handleRenameFolderOk:br,handleRenameFolderCancel:Et,renameFolderForm:j,folderToRename:W,isCopyModalVisible:H,handleCopyOk:wt,handleCopyCancel:He,copyForm:D,isDeleteConfirmVisible:$,handleDeleteConfirmOk:gt,handleDeleteConfirmCancel:()=>null==We?void 0:We(),isClearTrashConfirmVisible:de,handleClearTrashConfirm:vt,handleClearTrashCancel:yt,fetchChildFolders:be}),e(NR,{visible:at.isPixieEditorVisible,onClose:at.handlePixieEditorClose,file:at.editingFile,onSave:at.handlePixieEditorSave,onSaveCopy:at.handlePixieEditorSaveCopy}),e(dL,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const r=v.getUploadedFile(e.id)||e;null===(t=_.onEditorOk)||void 0===t||t.call(_,r)}})]})})]})},lN=f(({config:n={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.folderNameProcessing)},n),[n]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(hr).matches?ur:cr;e=e===dr?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),nN(b)},[b]),a(()=>{b.locale&&b.locale!==On.language&&On.changeLanguage(b.locale),b.customLocale&&b.locale&&On.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null),x=i.useMemo(()=>({apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y}),[h,c,d,o,s,l,b,f,p,g,m,v,y]);return e(I,{className:"em-filemanager",children:t(r,{children:[e(A,{getPopupContainer:()=>w.current||document.body,children:e(go,{options:x,children:e(sN,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});lN.displayName="FileManagerApp";const cN=t=>{var r,n,i;return e(Xn,{i18n:On,children:e(wr,{externalTheme:null!==(n=null===(r=t.config)||void 0===r?void 0:r.theme)&&void 0!==n?n:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(oe,{children:e(lN,Object.assign({},t))})})})},uN=new Map,dN=(t,r)=>{var n;let i;Sr();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?Cr("imageCenter",e):Cr(t)};if(t instanceof HTMLElement){i=t;o={config:a(r),apiEndpoints:null==r?void 0:r.apiEndpoints}}else{i=t.element;const e=a(t.config),r=Object.assign(Object.assign({},null===(n=t.config)||void 0===n?void 0:n.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:r,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=_(i);s.render(e(cN,Object.assign({},o))),uN.set(i.id||`container_${Date.now()}`,s)},hN=e=>{const t=e.id||Object.keys(uN).find(e=>e.startsWith("container_"));if(t&&uN.has(t)){const e=uN.get(t);null==e||e.unmount(),uN.delete(t)}else{console.warn("Couldn t find the root to unmount");try{_(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},fN=new Map,pN=n=>{const{onClose:o,onSave:s,dataProviders:l,theme:c,locale:d,hasPagination:h,disablePagination:f,paginationAvailable:p,dedupeUploadNamesOnClient:g,saveCopyToCurrentFolder:m}=n,v=i.useMemo(()=>{var e,t;return{theme:null!=c?c:"light",locale:d,baseUrl:n.baseUrl,assetsUrl:n.assetsUrl,compressMaxSize:n.compressMaxSize,compressMaxWidthOrHeight:n.compressMaxWidthOrHeight,compessorUrl:null!==(e=n.compessorUrl)&&void 0!==e?e:n.compressorUrl,compressorUrl:null!==(t=n.compressorUrl)&&void 0!==t?t:n.compessorUrl,showNotifications:n.showNotifications,handleFileProxy:n.handleFileProxy,hasPagination:h,disablePagination:f,paginationAvailable:p,dedupeUploadNamesOnClient:g,saveCopyToCurrentFolder:m}},[c,d,n.baseUrl,n.assetsUrl,n.compressMaxSize,n.compressMaxWidthOrHeight,n.compessorUrl,n.compressorUrl,n.showNotifications,n.handleFileProxy,h,f,p,g,m]),y=i.useCallback(async(e,t,r,n)=>{if(!e&&!t||!(null==l?void 0:l.getFiles))return null;try{const i=await l.getFiles({folderId:n?void 0:null!=r?r:void 0,noFolder:n,search:t||void 0,itemType:"file",page:1,limit:1}),[o]=i.files;return o?e&&o.id!==e?null:o:null}catch(e){return console.warn("Standalone Pixie: failed to resolve uploaded file from provider",e),null}},[l]),b=i.useMemo(()=>{if(n.file)return n.file;const e=n.name||"edited-image",t=n.extension||(n.type?n.type.split("/")[1]:"png"),r=n.type||`image/${t}`;return{thumbnail:n.imageDataUrl||"",name:e,id:void 0,type:r,extension:t,saveWithoutFolder:!0}},[n.file,n.imageDataUrl,n.name,n.extension,n.type]),w=i.useCallback(async(e,t)=>{if((null==l?void 0:l.updateFile)&&e.thumbnail)try{const r=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),n=Fr(r),i=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,o=(null==t?void 0:t.blob)||Mr(e.thumbnail,r);return await l.updateFile(e.id,{name:i,type:r,data:o})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[l]),x=i.useCallback(async(e,t)=>{var r,n,i,o,a,s;if(!e.thumbnail)return null;try{const c=!0!==v.saveCopyToCurrentFolder||(null!==(r=e.saveWithoutFolder)&&void 0!==r?r:!e.id),u=c?"":e.folderId||"",d=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),h=(null==t?void 0:t.blob)||Mr(e.thumbnail,d),f=Dr(e.name,v),p=await hi(l,f,u,c,Br(v)),g=new File([h],p,{type:d,lastModified:Date.now()});if(null==l?void 0:l.uploadFiles){const t=await l.uploadFiles({items:[{name:g.name,size:g.size,type:g.type,folderId:u,noFolder:c,data:g,extension:Fr(d)}],folderId:u}),r=null===(n=t.detailed)||void 0===n?void 0:n[0];if(t.success&&(null==r?void 0:r.success)&&r.data){const t=r.data;if(t.url||t.thumbnailUrl||t.thumbnail)return{id:t.id||e.id||"",name:t.name||e.name,folderId:null!==(i=t.folderId)&&void 0!==i?i:u,type:t.type||g.type,size:null!==(o=t.size)&&void 0!==o?o:g.size,extension:t.extension||Fr(d),url:t.url,thumbnailUrl:t.thumbnailUrl,thumbnail:t.thumbnail,date:t.date,dimensions:t.dimensions,aspectRatio:t.aspectRatio,sourceUrl:t.sourceUrl,isFolder:!1,selected:!1};const n=await y(r.data.id,r.data.name||g.name,null!==(a=r.data.folderId)&&void 0!==a?a:u,c);return n||{id:r.data.id||e.id||"",name:r.data.name||e.name,folderId:null!==(s=r.data.folderId)&&void 0!==s?s:u,type:g.type,size:g.size,extension:Fr(d),url:r.data.url,thumbnailUrl:r.data.thumbnailUrl,thumbnail:r.data.thumbnail,isFolder:!1,selected:!1}}}return(null==l?void 0:l.uploadFile)?await l.uploadFile({name:g.name,size:g.size,type:g.type,folderId:u,noFolder:c,data:g,extension:Fr(d)}):null}catch(e){return console.error("Error saving file copy:",e),null}},[l,y,v]),C=i.useCallback(async(e,t)=>{if((null==l?void 0:l.updateFile)&&e.id&&e.thumbnail)try{const r=await w(e,t);r&&(e=r)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return s&&await s(e,t),o&&o(),e},[l,s,o,w]),_=i.useCallback(async(e,t)=>{let r=e;if(e.thumbnail)try{const n=await x(e,t);n&&(r=n)}catch(e){console.error("Standalone Pixie: saveFileCopyToServer error",e)}return s&&await s(r,t),o&&o(),r},[o,s,x]),S=u(null);return a(()=>{d&&d!==On.language&&On.changeLanguage(d)},[d]),e(I,{className:"em-filemanager",children:t(r,{children:[e(A,{getPopupContainer:()=>S.current||document.body,children:e(Xn,{i18n:On,children:e(wr,{externalTheme:null!=c?c:"light",children:e(oe,{children:e(go,{options:{dataProviders:l,handleNotify:n.handleNotify,handleError:n.handleError,handleSuccess:n.handleSuccess,config:v},children:e(NR,{visible:!0,onClose:o,file:b,onSave:C,onSaveCopy:_})})})})})}),e("div",{ref:S,className:"file-manager-modal-root"})]})})},gN=t=>{Sr();const r=t.element,n=_(r);n.render(e(pN,Object.assign({},t))),fN.set(r.id||`pixie_container_${Date.now()}`,n)},mN=e=>{const t=Array.from(fN.keys()).find(e=>e.startsWith("pixie_container_")),r=e.id||t;if(r&&fN.has(r)){const e=fN.get(r);null==e||e.unmount(),fN.delete(r)}else{console.warn("Couldn t find the root to unmount Pixie");try{_(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},vN=e=>{var t,r;const{mode:n,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&hN(c),u&&mN(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(n){case"fileManager":c=i,dN(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>hN(c);break;case"pixieEditor":u=i,gN(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>mN(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,dN(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),gN(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>hN(c),d.unmountPixieEditor=()=>mN(u);break}}return d};function yN(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var bN={init:dN,unmount:hN,initPixieEditor:gN,unmountPixieEditor:mN,initFileManager:vN};export{Ws as FileContent,qo as FileManagerApiError,lN as FileManagerApp,cN as FileManagerAppWithContext,sl as FileModals,cl as FolderSidebar,pN as PixieOnlyApp,bN as default,dN as init,vN as initFileManager,gN as initPixieEditor,Sr as installResizeObserverErrorHandler,yN as mapHttpStatusToErrorCode,kr as uninstallResizeObserverErrorHandler,hN as unmount,mN as unmountPixieEditor};
|
|
61
|
+
function nR(){return nR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},nR.apply(this,arguments)}new Promise(()=>{});const iR=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"];try{window.__reactRouterVersion="6"}catch{}const oR=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",aR=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,sR=n.forwardRef(function(e,t){let r,{onClick:i,relative:o,reloadDocument:a,replace:s,state:l,target:c,to:u,preventScrollReset:d,unstable_viewTransition:h}=e,f=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&(i[r]=e[r]);return i}(e,iR),{basename:p}=n.useContext(qM),g=!1;if("string"==typeof u&&aR.test(u)&&(r=u,oR))try{let e=new URL(window.location.href),t=u.startsWith("//")?new URL(e.protocol+u):new URL(u),r=function(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}(t.pathname,p);t.origin===e.origin&&null!=r?u=r+t.search+t.hash:g=!0}catch{}let m=function(e,t){let{relative:r}=void 0===t?{}:t;KM()||MM(!1);let{basename:i,navigator:o}=n.useContext(qM),{hash:a,pathname:s,search:l}=eR(e,{relative:r}),c=s;return"/"!==i&&(c="/"===s?i:BM([i,s])),o.createHref({pathname:c,search:l,hash:a})}(u,{relative:o}),v=function(e,t){let{target:r,replace:i,state:o,preventScrollReset:a,relative:s,unstable_viewTransition:l}=void 0===t?{}:t,c=QM(),u=ZM(),d=eR(e,{relative:s});return n.useCallback(t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,r)){t.preventDefault();let r=void 0!==i?i:RM(u)===RM(d);c(e,{replace:r,state:o,preventScrollReset:a,relative:s,unstable_viewTransition:l})}},[u,c,d,i,o,r,e,a,s,l])}(u,{replace:s,state:l,target:c,preventScrollReset:d,relative:o,unstable_viewTransition:h});return n.createElement("a",nR({},f,{href:r||m,onClick:g||a?i:function(e){i&&i(e),e.defaultPrevented||v(e)},ref:t,target:c}))});var lR,cR;!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"}(lR||(lR={})),function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(cR||(cR={}));const uR=nf(e("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutlineOutlined"),dR=nf(e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined"),hR={opacity:0,y:50,scale:.3},fR={opacity:1,y:0,scale:1},pR={opacity:0,scale:.5};function gR(){const r=Fm(e=>e.toasts);return e("div",{className:"pointer-events-none relative",children:e(Ax,{initial:!1,children:r.map(r=>e("div",{className:ef("fixed z-toast mx-auto p-20","bottom-center"===r.position?"bottom-0 left-0 right-0":"bottom-0 right-0"),children:t(bx.div,{initial:r.disableEnterAnimation?void 0:hR,animate:r.disableEnterAnimation?void 0:fR,exit:r.disableExitAnimation?void 0:pR,className:ef("pointer-events-auto mx-auto flex max-h-100 min-h-50 w-min min-w-288 max-w-500 items-center gap-10 rounded-lg border bg-paper bg-paper py-6 pl-16 pr-6 text-sm text-main shadow-lg"),onPointerEnter:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onPointerLeave:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},role:"alert","aria-live":"danger"===r.type?"assertive":"polite",children:["danger"===r.type&&e(uR,{className:"flex-shrink-0 text-danger",size:"md"}),"loading"===r.type&&e(aO,{size:"sm",className:"flex-shrink-0",isIndeterminate:!0}),"positive"===r.type&&e(dR,{className:"flex-shrink-0 text-positive",size:"md"}),e("div",{className:"mr-auto w-max overflow-hidden overflow-ellipsis","data-testid":"toast-message",children:e(XA,{value:r.message})}),r.action&&e(L_,{variant:"text",color:"primary",size:"sm",className:"flex-shrink-0",onFocus:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onBlur:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},onClick:()=>Tm().remove(r.id),elementType:sR,to:r.action.action,children:e(XA,{value:r.action.label})}),"loading"!==r.type&&e(qA,{onFocus:()=>{var e;return null==(e=r.timer)?void 0:e.pause()},onBlur:()=>{var e;return null==(e=r.timer)?void 0:e.resume()},type:"button",className:"flex-shrink-0",onClick:()=>{Tm().remove(r.id)},size:"sm",children:e(lI,{})})]})},r.id))})})}function mR(e){return $x()?e.metaKey:e.ctrlKey}function vR(e){switch(e.key){case"z":mR(e)&&(e.preventDefault(),e.stopPropagation(),e.shiftKey?bm().history.redo():bm().history.undo());break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),bm().objects.move("up");break;case"ArrowRight":e.preventDefault(),e.stopPropagation(),bm().objects.move("right");break;case"ArrowDown":e.preventDefault(),e.stopPropagation(),bm().objects.move("down");break;case"ArrowLeft":e.preventDefault(),e.stopPropagation(),bm().objects.move("left");break;case"Delete":e.preventDefault(),e.stopPropagation(),bm().objects.delete();break;case"v":mR(e)&&(e.preventDefault(),e.stopPropagation(),async function(){try{const e=await navigator.clipboard.read();for(const t of e)for(const e of t.types)if(e.startsWith("image/")){const r=await t.getType(e),n=new FileReader;return n.onload=e=>{var t;null!=(t=e.target)&&t.result&&bm().import.addImageFromData(e.target.result)},void n.readAsDataURL(r)}}catch(e){console.error(e)}}())}}const yR=new Map,bR=new Map,wR={};async function*xR(e){const t=e.createReader();let r;do{r=await new Promise((e,r)=>{t.readEntries(e,r)});for(const e of r)if(e.isFile){if(".DS_Store"===e.name)continue;const t=await CR(e);yield new s_(t,e.fullPath)}else e.isDirectory&&(yield*xR(e))}while(r.length>0)}function CR(e){return new Promise((t,r)=>e.file(t,r))}function _R(e){return null!=wR.dragTargetId?yR.get(wR.dragTargetId):e.dataTransfer.types.includes("Files")?{type:"nativeFile",el:null,ref:null,getData:()=>async function(e){const t=[];for await(const r of e)t.push(r);return t}(async function*(e){const t=[];for(const r of e.items)if("file"===r.kind){const e=r.webkitGetAsEntry();e&&t.push(e)}for(const e of t)if(e.isFile){if(".DS_Store"===e.name)continue;const t=await CR(e);yield new s_(t,e.fullPath)}else e.isDirectory&&(yield*xR(e))}(e.dataTransfer))}:void 0}function SR(){const r=vm(e=>{var t;return null==(t=e.config.ui)?void 0:t.visible})??!0,n=vm(e=>{var t,r;return null==(r=null==(t=e.config.ui)?void 0:t.nav)?void 0:r.position})??"bottom",i=vm(e=>{var t,r;return null==(r=null==(t=e.config.ui)?void 0:t.menubar)?void 0:r.position})??"top",o=vm(e=>{var t;return null==(t=e.config.ui)?void 0:t.allowEditorClose})??!0,s=u(null),l=u(null),{isModal:d,isMobile:h}=cI(),f=c(async e=>{var t,r;if(ym().activeTool||ym().dirty||"nativeFile"!==e.type)return;const n=await e.getData();bm().import.fileIsValid(n[0])&&((null==(r=null==(t=ym().config.tools)?void 0:t.import)?void 0:r.openDroppedImageAsBackground)?await bm().import.openBackgroundImage(n[0]):await bm().import.openUploadedFile(n[0]))},[]),{droppableProps:p}=function({id:e,disabled:t,ref:r,...n}){const i=u({dragOverElements:new Set,dropActivateTimer:void 0}).current,o=u(n);o.current=n,x(()=>(bR.set(e,{...bR.get(e),disabled:t,id:e,ref:r}),()=>{bR.delete(e)}),[e,o,t,r]);const a=e=>{var t;const n=o.current,i=n.allowDragEventsFromItself||r.current!==(null==(t=e.ref)?void 0:t.current);return!(!(null!=e&&e.type&&i&&n.types.includes(e.type))||n.acceptsDrop&&!n.acceptsDrop(e))},s=e=>{var t,r;const n=_R(e);n&&(null==(r=(t=o.current).onDragLeave)||r.call(t,n))};return{droppableProps:t?{}:{onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation();const n=_R(e);n&&a(n)&&(null==(r=(t=o.current).onDragOver)||r.call(t,n,e))},onDragEnter:e=>{var t,r;if(e.stopPropagation(),i.dragOverElements.add(e.target),i.dragOverElements.size>1)return;const n=_R(e);n&&a(n)&&(null==(r=(t=o.current).onDragEnter)||r.call(t,n),clearTimeout(i.dropActivateTimer),"function"==typeof o.current.onDropActivate&&(i.dropActivateTimer=setTimeout(()=>{var e,t;n&&(null==(t=(e=o.current).onDropActivate)||t.call(e,n))},400)))},onDragLeave:e=>{e.stopPropagation(),i.dragOverElements.delete(e.target);for(const t of i.dragOverElements)e.currentTarget.contains(t)||i.dragOverElements.delete(t);if(i.dragOverElements.size>0)return;const t=_R(e);t&&a(t)&&(s(e),clearTimeout(i.dropActivateTimer))},onDrop:async e=>{var t,r,n,l;e.preventDefault(),e.stopPropagation(),i.dragOverElements.clear(),s(e),clearTimeout(i.dropActivateTimer);const c=_R(e);c&&(null==(r=(t=o.current).onDragLeave)||r.call(t,c),a(c)&&(null==(l=(n=o.current).onDrop)||l.call(n,c)))}}}}({id:"pixie-root",ref:l,types:["nativeFile"],onDrop:f});a(()=>{var e,t;ym().fabric||(vm.setState({canvasRef:s}),A_(s.current),null!=(e=ym().config.ui)&&e.defaultTool&&ym().setActiveTool(null==(t=ym().config.ui)?void 0:t.defaultTool,null),bm().canvas.loadInitialContent().then(()=>{var e,t;null==(t=(e=ym().config).onLoad)||t.call(e,ym().editor)}));const r=I_(l,()=>{ym().setStageSize(E_(l.current))}),n=I_(s,()=>{ym().setCanvasSize(E_(s.current))});return()=>{r(),n()}},[l]);const g=ef("pixie-root flex flex-col overflow-hidden bg-background text-main no-tap-highlight w-full h-full",{relative:!d,"fixed inset-0 w-full h-full z-20":d,"shadow-lg border rounded-md m-auto max-h-[calc(100vh-90px)] max-w-[calc(100vw-90px)]":d&&!h});return t(Ix,{features:Fx,strict:!0,children:[d&&r&&!h&&o&&e(qA,{className:"z-20 fixed right-2 top-2 text-white",size:"lg",onClick:()=>{ym().editor.close()},children:e(lI,{})}),d&&r&&e(Kk,{position:"fixed",disableInitialTransition:!0}),t(bx.div,{initial:!1,variants:{visible:{opacity:1,scale:1,display:"flex"},hidden:{opacity:0,transitionEnd:{display:"none"}}},animate:r?"visible":"hidden",className:g,children:["top"===i&&e(mI,{}),"top"===n&&e(dM,{className:"pt-14"}),t("main",{className:"relative flex-auto my-20 overflow-hidden outline-none",tabIndex:-1,...Ux(p,{onKeyDownCapture:vR}),ref:l,children:[e(yI,{}),e(KE,{ref:s})]}),e(eP,{}),"bottom"===n&&e(dM,{}),"bottom"===i&&e(mI,{}),e(FM,{}),e(gR,{})]})]})}!function(){fabric.Object.ENLIVEN_PROPS.push("eraser");var e=fabric.Object.prototype._drawClipPath,t=fabric.Object.prototype.needsItsOwnCache,r=fabric.Object.prototype.toObject,n=fabric.Object.prototype.getSvgCommons,i=fabric.Object.prototype._createBaseClipPathSVGMarkup,o=fabric.Object.prototype._createBaseSVGMarkup;fabric.Object.prototype.cacheProperties.push("eraser"),fabric.Object.prototype.stateProperties.push("eraser"),fabric.util.object.extend(fabric.Object.prototype,{erasable:!0,eraser:void 0,needsItsOwnCache:function(){return t.call(this)||!!this.eraser},_drawClipPath:function(t,r){if(e.call(this,t,r),this.eraser){var n=this._getNonTransformedDimensions();this.eraser.isType("eraser")&&this.eraser.set({width:n.x,height:n.y}),e.call(this,t,this.eraser)}},toObject:function(e){var t=r.call(this,["erasable"].concat(e));return this.eraser&&!this.eraser.excludeFromExport&&(t.eraser=this.eraser.toObject(e)),t},getSvgCommons:function(){return n.call(this)+(this.eraser?'mask="url(#'+this.eraser.clipPathId+')" ':"")},_createEraserSVGMarkup:function(e){return this.eraser?(this.eraser.clipPathId="MASK_"+fabric.Object.__uid++,['<mask id="',this.eraser.clipPathId,'" >',this.eraser.toSVG(e),"</mask>","\n"].join("")):""},_createBaseClipPathSVGMarkup:function(e,t){return[this._createEraserSVGMarkup(t&&t.reviver),i.call(this,e,t)].join("")},_createBaseSVGMarkup:function(e,t){return[this._createEraserSVGMarkup(t&&t.reviver),o.call(this,e,t)].join("")}});var a=fabric.Group.prototype._restoreObjectsState;fabric.util.object.extend(fabric.Group.prototype,{_addEraserPathToObjects:function(e){this._objects.forEach(function(t){fabric.EraserBrush.prototype._addPathToObjectEraser.call(fabric.EraserBrush.prototype,t,e)})},applyEraserToObjects:function(){var e=this,t=this.eraser;if(t){delete this.eraser;var r=e.calcTransformMatrix();t.clone(function(t){var n=e.clipPath;t.getObjects("path").forEach(function(t){var i=fabric.util.multiplyTransformMatrices(r,t.calcTransformMatrix());fabric.util.applyTransformToObject(t,i),n?n.clone(function(n){var i=fabric.EraserBrush.prototype.applyClipPathToPath.call(fabric.EraserBrush.prototype,t,n,r);e._addEraserPathToObjects(i)},["absolutePositioned","inverted"]):e._addEraserPathToObjects(t)})})}},_restoreObjectsState:function(){return!0===this.erasable&&this.applyEraserToObjects(),a.call(this)}}),fabric.Eraser=fabric.util.createClass(fabric.Group,{type:"eraser",originX:"center",originY:"center",drawObject:function(e){e.save(),e.fillStyle="black",e.fillRect(-this.width/2,-this.height/2,this.width,this.height),e.restore(),this.callSuper("drawObject",e)},_getBounds:function(){},_toSVG:function(e){var t=["<g ","COMMON_PARTS"," >\n"],r=["<rect ",'fill="white" ','x="',-this.width/2,'" y="',-this.height/2,'" width="',this.width,'" height="',this.height,'" />\n'].join("");t.push("\t\t",r);for(var n=0,i=this._objects.length;n<i;n++)t.push("\t\t",this._objects[n].toSVG(e));return t.push("</g>\n"),t}}),fabric.Eraser.fromObject=function(e,t){var r=e.objects;fabric.util.enlivenObjects(r,function(r){var n=fabric.util.object.clone(e,!0);delete n.objects,fabric.util.enlivenObjectEnlivables(e,n,function(){t&&t(new fabric.Eraser(r,n,!0))})})};var s=fabric.Canvas.prototype._renderOverlay;fabric.util.object.extend(fabric.Canvas.prototype,{isErasing:function(){return this.isDrawingMode&&this.freeDrawingBrush&&"eraser"===this.freeDrawingBrush.type&&this.freeDrawingBrush._isErasing},_renderOverlay:function(e){s.call(this,e),this.isErasing()&&!this.freeDrawingBrush.inverted&&this.freeDrawingBrush._render()}}),fabric.EraserBrush=fabric.util.createClass(fabric.PencilBrush,{type:"eraser",inverted:!1,_isErasing:!1,_isErasable:function(e){return!1!==e.erasable},_prepareCollectionTraversal:function(e,t,r){e.forEachObject(function(n){n.forEachObject&&"deep"===n.erasable?this._prepareCollectionTraversal(n,t,r):!this.inverted&&n.erasable&&n.visible?(n.visible=!1,e.dirty=!0,r.visibility.push(n),r.collection.push(e)):this.inverted&&n.visible&&(n.erasable&&n.eraser?(n.eraser.inverted=!0,n.dirty=!0,e.dirty=!0,r.eraser.push(n),r.collection.push(e)):(n.visible=!1,e.dirty=!0,r.visibility.push(n),r.collection.push(e)))},this)},preparePattern:function(){this._patternCanvas||(this._patternCanvas=fabric.util.createCanvasElement());var e=this._patternCanvas;e.width=this.canvas.width,e.height=this.canvas.height;var t=e.getContext("2d");if(this.canvas._isRetinaScaling()){var r=this.canvas.getRetinaScaling();this.canvas.__initRetinaScaling(r,e,t)}var n=this.canvas.backgroundImage,i=n&&this._isErasable(n),o=this.canvas.overlayImage,a=o&&this._isErasable(o);if(!this.inverted&&(n&&!i||this.canvas.backgroundColor))i&&(this.canvas.backgroundImage=void 0),this.canvas._renderBackground(t),i&&(this.canvas.backgroundImage=n);else if(this.inverted&&n&&i){var l=this.canvas.backgroundColor;this.canvas.backgroundColor=void 0,this.canvas._renderBackground(t),this.canvas.backgroundColor=l}t.save(),t.transform.apply(t,this.canvas.viewportTransform);var c={visibility:[],eraser:[],collection:[]};if(this._prepareCollectionTraversal(this.canvas,t,c),this.canvas._renderObjects(t,this.canvas._objects),c.visibility.forEach(function(e){e.visible=!0}),c.eraser.forEach(function(e){e.eraser.inverted=!1,e.dirty=!0}),c.collection.forEach(function(e){e.dirty=!0}),t.restore(),!this.inverted&&(o&&!a||this.canvas.overlayColor))a&&(this.canvas.overlayImage=void 0),s.call(this.canvas,t),a&&(this.canvas.overlayImage=o);else if(this.inverted&&o&&a){l=this.canvas.overlayColor;this.canvas.overlayColor=void 0,s.call(this.canvas,t),this.canvas.overlayColor=l}},_setBrushStyles:function(e){this.callSuper("_setBrushStyles",e),e.strokeStyle="black"},_saveAndTransform:function(e){this.callSuper("_saveAndTransform",e),this._setBrushStyles(e),e.globalCompositeOperation=e===this.canvas.getContext()?"destination-out":"source-over"},needsFullRender:function(){return!0},onMouseDown:function(e,t){this.canvas._isMainEvent(t.e)&&(this._prepareForDrawing(e),this._captureDrawingPath(e),this.preparePattern(),this._isErasing=!0,this.canvas.fire("erasing:start"),this._render())},_render:function(){var e;this.inverted||(e=this.canvas.getContext(),this.callSuper("_render",e)),e=this.canvas.contextTop,this.canvas.clearContext(e),this.callSuper("_render",e),e.save();var t=1/this.canvas.getRetinaScaling();e.scale(t,t),e.globalCompositeOperation="source-in",e.drawImage(this._patternCanvas,0,0),e.restore()},createPath:function(e){var t=this.callSuper("createPath",e);return t.globalCompositeOperation=this.inverted?"source-over":"destination-out",t.stroke=this.inverted?"white":"black",t},applyClipPathToPath:function(e,t,r){var n=fabric.util.invertTransform(e.calcTransformMatrix()),i=t.calcTransformMatrix(),o=t.absolutePositioned?n:fabric.util.multiplyTransformMatrices(n,r);return t.absolutePositioned=!1,fabric.util.applyTransformToObject(t,fabric.util.multiplyTransformMatrices(o,i)),e.clipPath=e.clipPath?fabric.util.mergeClipPaths(t,e.clipPath):t,e},clonePathWithClipPath:function(e,t,r){var n=t.calcTransformMatrix(),i=t.clipPath,o=this;e.clone(function(e){i.clone(function(t){r(o.applyClipPathToPath(e,t,n))},["absolutePositioned","inverted"])})},_addPathToObjectEraser:function(e,t){var r=this;if(e.forEachObject&&"deep"===e.erasable){var n=e._objects.filter(function(e){return e.erasable});n.length>0&&e.clipPath?this.clonePathWithClipPath(t,e,function(e){n.forEach(function(t){r._addPathToObjectEraser(t,e)})}):n.length>0&&n.forEach(function(e){r._addPathToObjectEraser(e,t)})}else{var i=e.eraser;i||(i=new fabric.Eraser,e.eraser=i),t.clone(function(t){var n=fabric.util.multiplyTransformMatrices(fabric.util.invertTransform(e.calcTransformMatrix()),t.calcTransformMatrix());fabric.util.applyTransformToObject(t,n),i.addWithUpdate(t),e.set("dirty",!0),e.fire("erasing:end",{path:t}),e.group&&Array.isArray(r.__subTargets)&&r.__subTargets.push(e)})}},applyEraserToCanvas:function(e){var t=this.canvas,r={};return["backgroundImage","overlayImage"].forEach(function(n){var i=t[n];i&&i.erasable&&(this._addPathToObjectEraser(i,e),r[n]=i)},this),r},_finalizeAndAddPath:function(){var e=this.canvas.contextTop,t=this.canvas;e.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate)),t.clearContext(t.contextTop),this._isErasing=!1;var r=this._points&&this._points.length>1?this.convertPointsToSVGPath(this._points):null;if(!r||this._isEmptySVGPath(r))return t.fire("erasing:end"),void t.requestRenderAll();var n=this.createPath(r);n.setCoords(),t.fire("before:path:created",{path:n});var i=this.applyEraserToCanvas(n),o=this;this.__subTargets=[];var a=[];t.forEachObject(function(e){e.erasable&&e.intersectsWithObject(n,!0,!0)&&(o._addPathToObjectEraser(e,n),a.push(e))}),t.fire("erasing:end",{path:n,targets:a,subTargets:this.__subTargets,drawables:i}),delete this.__subTargets,t.requestRenderAll(),this._resetShadow(),t.fire("path:created",{path:n})}})}(),Cl.enableBoundaryChecking(!1);const kR=class t{constructor(t){if(dl(this,"tools",{}),dl(this,"fabric",null),t.sentryDsn&&function(e){const t={...e};Ed(t,"react"),zh(t)}({dsn:t.sentryDsn}),function(e,t){void 0===t&&(t={});var r=t.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===r&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}('/*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/.pi *,.pi :after,.pi :before{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity));border-style:solid;border-width:0;box-sizing:border-box}.pi :after,.pi :before{--tw-content:""}.pi hr{border-top-width:1px;color:inherit;height:0}.pi abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6{font-size:inherit;font-weight:inherit}.pi a{color:inherit;text-decoration:inherit}.pi b,.pi strong{font-weight:bolder}.pi code,.pi kbd,.pi pre,.pi samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.pi small{font-size:80%}.pi sub,.pi sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.pi sub{bottom:-.25em}.pi sup{top:-.5em}.pi table{border-collapse:collapse;border-color:inherit;text-indent:0}.pi button,.pi input,.pi optgroup,.pi select,.pi textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}.pi button,.pi select{text-transform:none}.pi [type=button],.pi [type=reset],.pi [type=submit],.pi button{-webkit-appearance:button;background-color:transparent;background-image:none}.pi :-moz-focusring{outline:auto}.pi :-moz-ui-invalid{box-shadow:none}.pi progress{vertical-align:baseline}.pi ::-webkit-inner-spin-button,.pi ::-webkit-outer-spin-button{height:auto}.pi [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.pi ::-webkit-search-decoration{-webkit-appearance:none}.pi ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.pi summary{display:list-item}.pi blockquote,.pi dd,.pi dl,.pi figure,.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6,.pi hr,.pi p,.pi pre{margin:0}.pi fieldset{margin:0;padding:0}.pi legend{padding:0}.pi menu,.pi ol,.pi ul{list-style:none;margin:0;padding:0}.pi textarea{resize:vertical}.pi input::-moz-placeholder,.pi textarea::-moz-placeholder{color:#9ca3af;opacity:1}.pi input::placeholder,.pi textarea::placeholder{color:#9ca3af;opacity:1}.pi [role=button],.pi button{cursor:pointer}.pi :disabled{cursor:default}.pi audio,.pi canvas,.pi embed,.pi iframe,.pi img,.pi object,.pi svg,.pi video{display:block;vertical-align:middle}.pi img,.pi video{height:auto;max-width:100%}.pi [hidden]{display:none}.pi *,.pi :after,.pi :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi ::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi .\\!container{width:100%!important}.pi .container{width:100%}@media (min-width:640px){.pi .\\!container{max-width:640px!important}.pi .container{max-width:640px}}@media (min-width:768px){.pi .\\!container{max-width:768px!important}.pi .container{max-width:768px}}@media (min-width:1024px){.pi .\\!container{max-width:1024px!important}.pi .container{max-width:1024px}}@media (min-width:1280px){.pi .\\!container{max-width:1280px!important}.pi .container{max-width:1280px}}@media (min-width:1536px){.pi .\\!container{max-width:1536px!important}.pi .container{max-width:1536px}}.pi .sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border-width:0;white-space:nowrap}.pi .pointer-events-none{pointer-events:none}.pi .pointer-events-auto{pointer-events:auto}.pi .\\!visible{visibility:visible!important}.pi .visible{visibility:visible}.pi .invisible{visibility:hidden}.pi .collapse{visibility:collapse}.pi .static{position:static}.pi .fixed{position:fixed}.pi .absolute{position:absolute}.pi .relative{position:relative}.pi .inset-0{top:0;right:0;bottom:0;left:0}.pi .inset-x-0{left:0;right:0}.pi .-bottom-10{bottom:-10px}.pi .-bottom-20{bottom:-20px}.pi .-bottom-5{bottom:-5px}.pi .-left-5{left:-5px}.pi .-left-8{left:-8px}.pi .-left-80{left:-80px}.pi .-right-5{right:-5px}.pi .-top-144{top:-144px}.pi .-top-40{top:-40px}.pi .-top-5{top:-5px}.pi .bottom-0{bottom:0}.pi .bottom-20{bottom:20px}.pi .left-0{left:0}.pi .left-1\\/2{left:50%}.pi .left-20{left:20px}.pi .right-0{right:0}.pi .right-16{right:16px}.pi .right-2{right:2px}.pi .right-20{right:20px}.pi .right-4{right:4px}.pi .top-0{top:0}.pi .top-1\\/2{top:50%}.pi .top-2{top:2px}.pi .isolate{isolation:isolate}.pi .z-10{z-index:10}.pi .z-20{z-index:20}.pi .z-50{z-index:50}.pi .z-cropzone{z-index:10}.pi .z-loading-indicator{z-index:50}.pi .z-modal{z-index:110}.pi .z-navbar{z-index:40}.pi .z-obj-box{z-index:20}.pi .z-popover{z-index:130}.pi .z-toast{z-index:160}.pi .z-tool-overlay{z-index:30}.pi .z-tooltip{z-index:150}.pi .z-tray{z-index:120}.pi .m-auto{margin:auto}.pi .mx-20{margin-left:20px;margin-right:20px}.pi .mx-8{margin-left:8px;margin-right:8px}.pi .mx-auto{margin-left:auto;margin-right:auto}.pi .my-20{margin-bottom:20px;margin-top:20px}.pi .my-4{margin-bottom:4px;margin-top:4px}.pi .my-6{margin-bottom:6px;margin-top:6px}.pi .my-8{margin-bottom:8px;margin-top:8px}.pi .my-auto{margin-bottom:auto;margin-top:auto}.pi .-ml-1{margin-left:-1px}.pi .-ml-10{margin-left:-10px}.pi .-ml-12{margin-left:-12px}.pi .-ml-3{margin-left:-3px}.pi .-ml-4{margin-left:-4px}.pi .-ml-6{margin-left:-6px}.pi .-mr-4{margin-right:-4px}.pi .-mr-8{margin-right:-8px}.pi .mb-1{margin-bottom:1px}.pi .mb-10{margin-bottom:10px}.pi .mb-16{margin-bottom:16px}.pi .mb-2{margin-bottom:2px}.pi .mb-20{margin-bottom:20px}.pi .mb-24{margin-bottom:24px}.pi .mb-4{margin-bottom:4px}.pi .mb-6{margin-bottom:6px}.pi .mb-8{margin-bottom:8px}.pi .ml-10{margin-left:10px}.pi .ml-12{margin-left:12px}.pi .ml-4{margin-left:4px}.pi .ml-6{margin-left:6px}.pi .ml-8{margin-left:8px}.pi .ml-auto{margin-left:auto}.pi .mr-10{margin-right:10px}.pi .mr-16{margin-right:16px}.pi .mr-20{margin-right:20px}.pi .mr-4{margin-right:4px}.pi .mr-5{margin-right:5px}.pi .mr-6{margin-right:6px}.pi .mr-8{margin-right:8px}.pi .mr-auto{margin-right:auto}.pi .mt-0{margin-top:0}.pi .mt-10{margin-top:10px}.pi .mt-14{margin-top:14px}.pi .mt-20{margin-top:20px}.pi .mt-24{margin-top:24px}.pi .mt-4{margin-top:4px}.pi .mt-6{margin-top:6px}.pi .box-content{box-sizing:content-box}.pi .block{display:block}.pi .inline-block{display:inline-block}.pi .inline{display:inline}.pi .flex{display:flex}.pi .inline-flex{display:inline-flex}.pi .grid{display:grid}.pi .contents{display:contents}.pi .hidden{display:none}.pi .aspect-square{aspect-ratio:1/1}.pi .h-1{height:1px}.pi .h-12{height:12px}.pi .h-128{height:128px}.pi .h-14{height:14px}.pi .h-16{height:16px}.pi .h-18{height:18px}.pi .h-2{height:2px}.pi .h-2\\/4{height:50%}.pi .h-20{height:20px}.pi .h-22{height:22px}.pi .h-24{height:24px}.pi .h-26{height:26px}.pi .h-28{height:28px}.pi .h-3{height:3px}.pi .h-30{height:30px}.pi .h-32{height:32px}.pi .h-36{height:36px}.pi .h-38{height:2.375rem}.pi .h-4{height:4px}.pi .h-40{height:40px}.pi .h-42{height:42px}.pi .h-48{height:48px}.pi .h-50{height:50px}.pi .h-56{height:56px}.pi .h-6{height:6px}.pi .h-60{height:60px}.pi .h-64{height:64px}.pi .h-68{height:68px}.pi .h-8{height:8px}.pi .h-80{height:80px}.pi .h-84{height:84px}.pi .h-92{height:92px}.pi .h-\\[54px\\]{height:54px}.pi .h-font{height:1em}.pi .h-full{height:100%}.pi .h-px{height:1px}.pi .h-screen{height:100dvh}.pi .max-h-100{max-height:6.25rem}.pi .max-h-\\[calc\\(100\\%-40px\\)\\]{max-height:calc(100% - 40px)}.pi .max-h-\\[calc\\(100vh-90px\\)\\]{max-height:calc(100vh - 90px)}.pi .max-h-dialog{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .max-h-full{max-height:100%}.pi .max-h-inherit{max-height:inherit}.pi .max-h-tray{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .min-h-24{min-height:24px}.pi .min-h-30{min-height:30px}.pi .min-h-36{min-height:36px}.pi .min-h-42{min-height:42px}.pi .min-h-50{min-height:50px}.pi .min-h-60{min-height:60px}.pi .min-h-86{min-height:86px}.pi .\\!w-auto{width:auto!important}.pi .w-1\\/2{width:50%}.pi .w-110{width:110px}.pi .w-12{width:12px}.pi .w-1280{width:80rem}.pi .w-14{width:14px}.pi .w-144{width:144px}.pi .w-16{width:16px}.pi .w-18{width:18px}.pi .w-2{width:2px}.pi .w-20{width:20px}.pi .w-22{width:22px}.pi .w-224{width:224px}.pi .w-24{width:24px}.pi .w-256{width:256px}.pi .w-26{width:26px}.pi .w-28{width:28px}.pi .w-280{width:17.5rem}.pi .w-30{width:30px}.pi .w-32{width:32px}.pi .w-320{width:320px}.pi .w-36{width:36px}.pi .w-38{width:2.375rem}.pi .w-384{width:384px}.pi .w-40{width:40px}.pi .w-42{width:42px}.pi .w-440{width:27.5rem}.pi .w-46{width:2.875rem}.pi .w-50{width:50px}.pi .w-56{width:56px}.pi .w-60{width:60px}.pi .w-620{width:38.75rem}.pi .w-64{width:64px}.pi .w-68{width:68px}.pi .w-780{width:48.75rem}.pi .w-8{width:8px}.pi .w-80{width:80px}.pi .w-850{width:53.125rem}.pi .w-96{width:96px}.pi .w-\\[4ch\\]{width:4ch}.pi .w-auto{width:auto}.pi .w-font{width:1em}.pi .w-full{width:100%}.pi .w-max{width:-moz-max-content;width:max-content}.pi .w-min{width:-moz-min-content;width:min-content}.pi .w-px{width:1px}.pi .w-screen{width:100vw}.pi .min-w-0{min-width:0}.pi .min-w-128{min-width:128px}.pi .min-w-180{min-width:11.25rem}.pi .min-w-192{min-width:192px}.pi .min-w-288{min-width:288px}.pi .min-w-30{min-width:30px}.pi .min-w-4{min-width:4px}.pi .min-w-42{min-width:42px}.pi .min-w-92{min-width:92px}.pi .min-w-min{min-width:-moz-min-content;min-width:min-content}.pi .max-w-112{max-width:112px}.pi .max-w-240{max-width:240px}.pi .max-w-288{max-width:288px}.pi .max-w-320{max-width:320px}.pi .max-w-375{max-width:375px}.pi .max-w-500{max-width:31.25rem}.pi .max-w-\\[90\\%\\]{max-width:90%}.pi .max-w-\\[calc\\(100\\%-40px\\)\\]{max-width:calc(100% - 40px)}.pi .max-w-\\[calc\\(100vw-90px\\)\\]{max-width:calc(100vw - 90px)}.pi .max-w-dialog{max-width:calc(var(--be-viewport-width, 100vw)*.9)}.pi .max-w-full{max-width:100%}.pi .max-w-max{max-width:-moz-max-content;max-width:max-content}.pi .flex-\\[1_1_60px\\]{flex:1 1 60px}.pi .flex-auto{flex:1 1 auto}.pi .flex-shrink-0,.pi .shrink-0{flex-shrink:0}.pi .origin-\\[0_55\\%\\]{transform-origin:0 55%}.pi .origin-\\[100\\%\\]{transform-origin:100%}.pi .-translate-x-1\\/2{--tw-translate-x:-50%}.pi .-translate-x-1\\/2,.pi .-translate-y-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .-translate-y-1\\/2{--tw-translate-y:-50%}.pi .rotate-0{--tw-rotate:0deg}.pi .rotate-0,.pi .rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-180{--tw-rotate:180deg}.pi .rotate-45{--tw-rotate:45deg}.pi .rotate-45,.pi .rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-90{--tw-rotate:90deg}.pi .scale-y-\\[0\\.6\\]{--tw-scale-y:.6}.pi .scale-y-\\[0\\.6\\],.pi .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .cursor-default{cursor:default}.pi .cursor-move{cursor:move}.pi .cursor-nesw-resize{cursor:nesw-resize}.pi .cursor-not-allowed{cursor:not-allowed}.pi .cursor-nwse-resize{cursor:nwse-resize}.pi .cursor-pointer{cursor:pointer}.pi .cursor-se-resize{cursor:se-resize}.pi .cursor-sw-resize{cursor:sw-resize}.pi .touch-none{touch-action:none}.pi .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pi .resize{resize:both}.pi .appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.pi .grid-cols-5-min-content{grid-template-columns:repeat(5,min-content)}.pi .flex-row{flex-direction:row}.pi .flex-col{flex-direction:column}.pi .flex-col-reverse{flex-direction:column-reverse}.pi .flex-wrap{flex-wrap:wrap}.pi .flex-nowrap{flex-wrap:nowrap}.pi .items-start{align-items:flex-start}.pi .items-end{align-items:flex-end}.pi .items-center{align-items:center}.pi .items-stretch{align-items:stretch}.pi .justify-start{justify-content:flex-start}.pi .justify-center{justify-content:center}.pi .justify-between{justify-content:space-between}.pi .gap-10{gap:10px}.pi .gap-14{gap:14px}.pi .gap-16{gap:16px}.pi .gap-18{gap:18px}.pi .gap-20{gap:20px}.pi .gap-36{gap:36px}.pi .gap-4{gap:4px}.pi .gap-40{gap:40px}.pi .gap-6{gap:6px}.pi .gap-8{gap:8px}.pi .space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(10px*var(--tw-space-y-reverse));margin-top:calc(10px*(1 - var(--tw-space-y-reverse)))}.pi .overflow-auto{overflow:auto}.pi .overflow-hidden{overflow:hidden}.pi .overflow-x-auto{overflow-x:auto}.pi .overflow-y-auto{overflow-y:auto}.pi .overflow-x-hidden{overflow-x:hidden}.pi .overflow-y-hidden{overflow-y:hidden}.pi .overscroll-contain{overscroll-behavior:contain}.pi .truncate{overflow:hidden;white-space:nowrap}.pi .overflow-ellipsis,.pi .text-ellipsis,.pi .truncate{text-overflow:ellipsis}.pi .whitespace-normal{white-space:normal}.pi .whitespace-nowrap{white-space:nowrap}.pi .break-words{overflow-wrap:break-word}.pi .rounded{border-radius:4px}.pi .rounded-2xl{border-radius:16px}.pi .rounded-3xl{border-radius:24px}.pi .rounded-button{border-radius:var(--be-button-radius,.25rem)}.pi .rounded-full{border-radius:9999px}.pi .rounded-input{border-radius:var(--be-input-radius,.25rem)}.pi .rounded-lg{border-radius:8px}.pi .rounded-md{border-radius:6px}.pi .rounded-none{border-radius:0}.pi .rounded-panel{border-radius:var(--be-panel-radius,.25rem)}.pi .rounded-xl{border-radius:12px}.pi .rounded-l{border-bottom-left-radius:4px;border-top-left-radius:4px}.pi .rounded-l-full{border-bottom-left-radius:9999px;border-top-left-radius:9999px}.pi .rounded-l-input{border-bottom-left-radius:var(--be-input-radius,.25rem);border-top-left-radius:var(--be-input-radius,.25rem)}.pi .rounded-l-none{border-bottom-left-radius:0;border-top-left-radius:0}.pi .rounded-r-full{border-bottom-right-radius:9999px;border-top-right-radius:9999px}.pi .rounded-r-input{border-bottom-right-radius:var(--be-input-radius,.25rem);border-top-right-radius:var(--be-input-radius,.25rem)}.pi .rounded-r-none{border-bottom-right-radius:0;border-top-right-radius:0}.pi .rounded-t{border-top-left-radius:4px;border-top-right-radius:4px}.pi .rounded-bl-none{border-bottom-left-radius:0}.pi .rounded-br-none{border-bottom-right-radius:0}.pi .rounded-tl-none{border-top-left-radius:0}.pi .rounded-tr-none{border-top-right-radius:0}.pi .border{border-width:1px}.pi .border-2{border-width:2px}.pi .border-4{border-width:4px}.pi .border-\\[3px\\]{border-width:3px}.pi .border-y{border-top-width:1px}.pi .border-b,.pi .border-y{border-bottom-width:1px}.pi .border-b-4{border-bottom-width:4px}.pi .border-l{border-left-width:1px}.pi .border-l-4{border-left-width:4px}.pi .border-r{border-right-width:1px}.pi .border-r-4{border-right-width:4px}.pi .border-t{border-top-width:1px}.pi .border-t-4{border-top-width:4px}.pi .border-dotted{border-style:dotted}.pi .border-none{border-style:none}.pi .border-background{--tw-border-opacity:1;border-color:rgb(var(--be-background)/var(--tw-border-opacity))}.pi .border-bg-alt{--tw-border-opacity:1;border-color:rgb(var(--be-background-alt)/var(--tw-border-opacity))}.pi .border-chip{--tw-border-opacity:1;border-color:rgb(var(--be-background-chip)/var(--tw-border-opacity))}.pi .border-danger{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .border-danger\\/50{border-color:#ef444480}.pi .border-divider{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .border-paper{--tw-border-opacity:1;border-color:rgb(var(--be-paper)/var(--tw-border-opacity))}.pi .border-positive\\/50{border-color:#22c55e80}.pi .border-primary{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .border-primary\\/50{border-color:rgb(var(--be-primary)/.5)}.pi .border-text-muted{border-color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .border-transparent{border-color:transparent}.pi .border-white{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.pi .border-white\\/50{border-color:#ffffff80}.pi .border-b-bg{--tw-border-opacity:1;border-bottom-color:rgb(var(--be-background)/var(--tw-border-opacity))}.pi .border-b-transparent{border-bottom-color:transparent}.pi .border-r-transparent{border-right-color:transparent}.pi .bg{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-alt{--tw-bg-opacity:1;background-color:rgb(var(--be-background-alt)/var(--tw-bg-opacity))}.pi .bg-background{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-background\\/70{background-color:rgb(var(--be-background)/.7)}.pi .bg-background\\/80{background-color:rgb(var(--be-background)/.8)}.pi .bg-black\\/50{background-color:#00000080}.pi .bg-black\\/80{background-color:#000c}.pi .bg-chip{--tw-bg-opacity:1;background-color:rgb(var(--be-background-chip)/var(--tw-bg-opacity))}.pi .bg-controls{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-danger{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .bg-danger-lighter{--tw-bg-opacity:1;background-color:rgb(254 202 202/var(--tw-bg-opacity))}.pi .bg-divider{background-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .bg-fg-base\\/4{background-color:rgb(var(--be-foreground-base)/4%)}.pi .bg-focus{background-color:rgb(var(--be-foreground-base)/var(--be-focus-opacity))}.pi .bg-inherit{background-color:inherit}.pi .bg-paper{--tw-bg-opacity:1;background-color:rgb(var(--be-paper)/var(--tw-bg-opacity))}.pi .bg-positive{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.pi .bg-positive-lighter{--tw-bg-opacity:1;background-color:rgb(187 247 208/var(--tw-bg-opacity))}.pi .bg-primary{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .bg-primary-dark{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .bg-primary-light{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-light)/var(--tw-bg-opacity))}.pi .bg-primary\\/focus{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .bg-primary\\/selected{background-color:rgb(var(--be-primary)/var(--be-selected-opacity))}.pi .bg-slider-disabled{--tw-bg-opacity:1;background-color:rgb(189 189 189/var(--tw-bg-opacity))}.pi .bg-slider-disabled\\/60{background-color:#bdbdbd99}.pi .bg-toast{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-transparent{background-color:transparent}.pi .bg-warning{--tw-bg-opacity:1;background-color:rgb(243 164 50/var(--tw-bg-opacity))}.pi .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .bg-white\\/50{background-color:#ffffff80}.pi .bg-opacity-95{--tw-bg-opacity:.95}.pi .bg-no-repeat{background-repeat:no-repeat}.pi .fill-current{fill:currentColor}.pi .fill-transparent{fill:transparent}.pi .stroke-current{stroke:currentColor}.pi .object-contain{-o-object-fit:contain;object-fit:contain}.pi .object-cover{-o-object-fit:cover;object-fit:cover}.pi .p-0{padding:0}.pi .p-10{padding:10px}.pi .p-14{padding:14px}.pi .p-16{padding:16px}.pi .p-18{padding:18px}.pi .p-2{padding:2px}.pi .p-20{padding:20px}.pi .p-4{padding:4px}.pi .p-40{padding:40px}.pi .p-6{padding:6px}.pi .p-8{padding:8px}.pi .px-10{padding-left:10px;padding-right:10px}.pi .px-12{padding-left:12px;padding-right:12px}.pi .px-14{padding-left:14px;padding-right:14px}.pi .px-16{padding-left:16px;padding-right:16px}.pi .px-18{padding-left:18px;padding-right:18px}.pi .px-20{padding-left:20px;padding-right:20px}.pi .px-22{padding-left:22px;padding-right:22px}.pi .px-24{padding-left:24px;padding-right:24px}.pi .px-26{padding-left:26px;padding-right:26px}.pi .px-32{padding-left:32px;padding-right:32px}.pi .px-4{padding-left:4px;padding-right:4px}.pi .px-5vw{padding-left:5vw;padding-right:5vw}.pi .px-6{padding-left:6px;padding-right:6px}.pi .px-8{padding-left:8px;padding-right:8px}.pi .py-10{padding-bottom:10px;padding-top:10px}.pi .py-12{padding-bottom:12px;padding-top:12px}.pi .py-14{padding-bottom:14px;padding-top:14px}.pi .py-2{padding-bottom:2px;padding-top:2px}.pi .py-20{padding-bottom:20px;padding-top:20px}.pi .py-3{padding-bottom:3px;padding-top:3px}.pi .py-4{padding-bottom:4px;padding-top:4px}.pi .py-5{padding-bottom:5px;padding-top:5px}.pi .py-6{padding-bottom:6px;padding-top:6px}.pi .py-8{padding-bottom:8px;padding-top:8px}.pi .py-\\[9px\\]{padding-bottom:9px;padding-top:9px}.pi .pb-10{padding-bottom:10px}.pi .pb-12{padding-bottom:12px}.pi .pb-14{padding-bottom:14px}.pi .pb-16{padding-bottom:16px}.pi .pb-18{padding-bottom:18px}.pi .pb-20{padding-bottom:20px}.pi .pb-4{padding-bottom:4px}.pi .pb-8{padding-bottom:8px}.pi .pb-safe-area{padding-bottom:env(safe-area-inset-bottom)}.pi .pl-10{padding-left:10px}.pi .pl-12{padding-left:12px}.pi .pl-14{padding-left:14px}.pi .pl-16{padding-left:16px}.pi .pl-18{padding-left:18px}.pi .pl-28{padding-left:28px}.pi .pl-46{padding-left:2.875rem}.pi .pl-54{padding-left:3.375rem}.pi .pl-8{padding-left:8px}.pi .pr-10{padding-right:10px}.pi .pr-12{padding-right:12px}.pi .pr-18{padding-right:18px}.pi .pr-24{padding-right:24px}.pi .pr-28{padding-right:28px}.pi .pr-46{padding-right:2.875rem}.pi .pr-54{padding-right:3.375rem}.pi .pr-6{padding-right:6px}.pi .pr-8{padding-right:8px}.pi .pt-10{padding-top:10px}.pi .pt-12{padding-top:12px}.pi .pt-14{padding-top:14px}.pi .pt-16{padding-top:16px}.pi .pt-20{padding-top:20px}.pi .pt-24{padding-top:24px}.pi .pt-4{padding-top:4px}.pi .pt-40{padding-top:40px}.pi .pt-6{padding-top:6px}.pi .text-left{text-align:left}.pi .text-center{text-align:center}.pi .text-right{text-align:right}.pi .align-middle{vertical-align:middle}.pi .text-base{font-size:16px;line-height:24px}.pi .text-lg{font-size:18px;line-height:28px}.pi .text-sm{font-size:14px;line-height:20px}.pi .text-xl{font-size:20px;line-height:28px}.pi .text-xs{font-size:12px;line-height:16px}.pi .font-bold{font-weight:700}.pi .font-medium{font-weight:500}.pi .font-semibold{font-weight:600}.pi .uppercase{text-transform:uppercase}.pi .capitalize{text-transform:capitalize}.pi .italic{font-style:italic}.pi .tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.pi .leading-5{line-height:1.25rem}.pi .leading-none{line-height:1}.pi .tracking-wide{letter-spacing:.025em}.pi .\\!text{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))!important}.pi .text{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.pi .text-black\\/30{color:#0000004d}.pi .text-danger{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.pi .text-danger-darker{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.pi .text-disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .text-link{--tw-text-opacity:1;color:rgb(var(--be-link-color,var(--be-primary))/var(--tw-text-opacity))}.pi .text-main{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .text-muted{color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .text-on-primary{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .text-positive{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity))}.pi .text-positive-darker{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.pi .text-primary{--tw-text-opacity:1;color:rgb(var(--be-primary)/var(--tw-text-opacity))}.pi .text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.pi .underline{text-decoration-line:underline}.pi .no-underline{text-decoration-line:none}.pi .caret-transparent{caret-color:transparent}.pi .opacity-0{opacity:0}.pi .opacity-100{opacity:1}.pi .opacity-70{opacity:.7}.pi .opacity-80{opacity:.8}.pi .opacity-90{opacity:.9}.pi .shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.pi .shadow,.pi .shadow-2xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0,0,0,.25);--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color)}.pi .shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.pi .shadow-lg,.pi .shadow-md{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.pi .shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.pi .shadow-sm,.pi .shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.pi .outline-none{outline:2px solid transparent;outline-offset:2px}.pi .outline{outline-color:rgb(var(--be-primary-lighter)/1);outline-style:solid;outline-width:2px}.pi .ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .ring-inset{--tw-ring-inset:inset}.pi .blur{--tw-blur:blur(8px)}.pi .blur,.pi .grayscale{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .grayscale{--tw-grayscale:grayscale(100%)}.pi .invert{--tw-invert:invert(100%)}.pi .invert,.pi .sepia{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .sepia{--tw-sepia:sepia(100%)}.pi .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .backdrop-blur-sm{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.pi .transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-button{transition-duration:.15s;transition-property:background-color,box-shadow,border-color,color;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-shadow{transition-duration:.15s;transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-width{transition-duration:.15s;transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .duration-100{transition-duration:.1s}.pi .duration-200{transition-duration:.2s}.pi .will-change-transform{will-change:transform}.pi .icon-2xs{font-size:.75rem}.pi .icon-xs{font-size:1rem}.pi .icon-sm{font-size:1.25rem}.pi .icon-md{font-size:1.5rem}.pi .icon-lg{font-size:2.1875rem}.pi .icon-xl{font-size:2.6875rem}.pi .no-tap-highlight{-webkit-tap-highlight-color:transparent}@media only screen and (min-device-width:768px){.pi .tiny-scrollbar{scrollbar-color:rgba(0,0,0,.2) transparent;scrollbar-width:thin}.pi .tiny-scrollbar::-webkit-scrollbar{background-color:transparent;height:6px;width:6px}.pi .tiny-scrollbar::-webkit-scrollbar-thumb{background-color:rgb(var(--be-foreground-base)/.2);border-radius:10px}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:start{background:transparent}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:end{background:transparent}}.pi .hide-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.pi .hide-scrollbar::-webkit-scrollbar{background:transparent;display:none;height:0;width:0}.pi .svg-icon{display:inline-block;flex-shrink:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;fill:currentColor;transition-duration:.15s;transition-property:transform,fill;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .cropzone:not(.moving) .cropzone-transition{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .first-letter\\:capitalize:first-letter{text-transform:capitalize}.pi .file\\:mr-10::file-selector-button{margin-right:10px}.pi .file\\:h-24::file-selector-button{height:24px}.pi .file\\:rounded::file-selector-button{border-radius:4px}.pi .file\\:border-none::file-selector-button{border-style:none}.pi .file\\:bg-primary::file-selector-button{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .file\\:px-10::file-selector-button{padding-left:10px;padding-right:10px}.pi .file\\:text-sm::file-selector-button{font-size:14px;line-height:20px}.pi .file\\:font-semibold::file-selector-button{font-weight:600}.pi .file\\:text-on-primary::file-selector-button{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .before\\:z-10:before{content:var(--tw-content);z-index:10}.pi .before\\:block:before{content:var(--tw-content);display:block}.pi .before\\:h-12:before{content:var(--tw-content);height:12px}.pi .before\\:h-14:before{content:var(--tw-content);height:14px}.pi .before\\:h-18:before{content:var(--tw-content);height:18px}.pi .before\\:h-22:before{content:var(--tw-content);height:22px}.pi .before\\:h-28:before{content:var(--tw-content);height:28px}.pi .before\\:h-full:before{content:var(--tw-content);height:100%}.pi .before\\:w-12:before{content:var(--tw-content);width:12px}.pi .before\\:w-14:before{content:var(--tw-content);width:14px}.pi .before\\:w-18:before{content:var(--tw-content);width:18px}.pi .before\\:w-22:before{content:var(--tw-content);width:22px}.pi .before\\:w-28:before{content:var(--tw-content);width:28px}.pi .before\\:w-full:before{content:var(--tw-content);width:100%}.pi .before\\:translate-x-2:before{--tw-translate-x:2px}.pi .before\\:scale-10:before,.pi .before\\:translate-x-2:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .before\\:scale-10:before{--tw-scale-x:.1;--tw-scale-y:.1}.pi .before\\:rounded-3xl:before{border-radius:24px;content:var(--tw-content)}.pi .before\\:rounded-full:before{border-radius:9999px;content:var(--tw-content)}.pi .before\\:border:before{border-width:1px;content:var(--tw-content)}.pi .before\\:bg-primary:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .before\\:bg-white:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .before\\:opacity-0:before{content:var(--tw-content);opacity:0}.pi .before\\:transition:before{content:var(--tw-content);transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:transition-transform:before{content:var(--tw-content);transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:duration-200:before{content:var(--tw-content);transition-duration:.2s}.pi .after\\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.pi .after\\:absolute:after{content:var(--tw-content);position:absolute}.pi .after\\:inset-0:after{content:var(--tw-content);top:0;right:0;bottom:0;left:0}.pi .checked\\:border-danger:checked{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .checked\\:border-primary:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .checked\\:bg-danger:checked{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .checked\\:bg-primary:checked{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .checked\\:before\\:translate-x-14:checked:before{--tw-translate-x:14px}.pi .checked\\:before\\:translate-x-14:checked:before,.pi .checked\\:before\\:translate-x-20:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-20:checked:before{--tw-translate-x:20px}.pi .checked\\:before\\:translate-x-24:checked:before{--tw-translate-x:24px}.pi .checked\\:before\\:translate-x-24:checked:before,.pi .checked\\:before\\:translate-x-30:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-30:checked:before{--tw-translate-x:30px}.pi .checked\\:before\\:translate-x-36:checked:before{--tw-translate-x:36px}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before,.pi .checked\\:before\\:translate-x-36:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before{--tw-scale-x:.65;--tw-scale-y:.65}.pi .checked\\:before\\:border-white:checked:before{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.pi .checked\\:before\\:opacity-100:checked:before{content:var(--tw-content);opacity:1}.pi .focus-within\\:border-primary\\/60:focus-within{border-color:rgb(var(--be-primary)/.6)}.pi .focus-within\\:ring:focus-within{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-within\\:ring-primary\\/focus:focus-within{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .hover\\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .hover\\:border-chip\\/90:hover{border-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:border-danger:hover{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .hover\\:border-danger\\/90:hover{border-color:#ef4444e6}.pi .hover\\:border-paper\\/90:hover{border-color:rgb(var(--be-paper)/.9)}.pi .hover\\:border-positive:hover{--tw-border-opacity:1;border-color:rgb(34 197 94/var(--tw-border-opacity))}.pi .hover\\:border-primary:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .hover\\:border-primary-dark:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .hover\\:bg-chip\\/90:hover{background-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:bg-danger\\/4:hover{background-color:#ef44440a}.pi .hover\\:bg-danger\\/90:hover{background-color:#ef4444e6}.pi .hover\\:bg-fg-base\\/15:hover{background-color:rgb(var(--be-foreground-base)/15%)}.pi .hover\\:bg-hover:hover{background-color:rgb(var(--be-foreground-base)/var(--be-hover-opacity))}.pi .hover\\:bg-paper\\/90:hover{background-color:rgb(var(--be-paper)/.9)}.pi .hover\\:bg-positive\\/4:hover{background-color:#22c55e0a}.pi .hover\\:bg-primary-dark:hover{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .hover\\:bg-primary\\/4:hover{background-color:rgb(var(--be-primary)/4%)}.pi .hover\\:bg-primary\\/focus:hover{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .hover\\:bg-primary\\/hover:hover{background-color:rgb(var(--be-primary)/var(--be-hover-opacity))}.pi .hover\\:bg-white:hover{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .hover\\:bg-white\\/20:hover{background-color:#fff3}.pi .hover\\:bg-white\\/hover:hover{background-color:rgb(255 255 255/var(--be-hover-opacity))}.pi .hover\\:text-main:hover{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .hover\\:text-primary-dark:hover{--tw-text-opacity:1;color:rgb(var(--be-primary-dark)/var(--tw-text-opacity))}.pi .hover\\:underline:hover{text-decoration-line:underline}.pi .hover\\:shadow-md:hover{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .before\\:hover\\:bg-primary-dark:hover:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .hover\\:after\\:bg-black\\/5:hover:after{background-color:#0000000d;content:var(--tw-content)}.pi .checked\\:hover\\:border-primary-dark:hover:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .focus\\:border-danger\\/60:focus{border-color:#ef444499}.pi .focus\\:border-primary\\/60:focus{border-color:rgb(var(--be-primary)/.6)}.pi .focus\\:bg-primary:focus{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .focus\\:text-on-primary:focus{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.pi .focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus\\:ring-danger\\/focus:focus{--tw-ring-color:rgb(239 68 68/var(--be-focus-opacity))}.pi .focus\\:ring-primary\\/focus:focus{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus\\:after\\:bg-black\\/10:focus:after{background-color:#0000001a;content:var(--tw-content)}.pi .focus-visible\\:bg-primary\\/focus:focus-visible{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus-visible\\:outline:focus-visible{outline-color:rgb(var(--be-primary-lighter)/1);outline-style:solid;outline-width:2px}.pi .focus-visible\\:outline-primary-light:focus-visible{outline-color:rgb(var(--be-primary-light)/1)}.pi .focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-visible\\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.pi .disabled\\:pointer-events-none:disabled{pointer-events:none}.pi .disabled\\:cursor-default:disabled{cursor:default}.pi .disabled\\:border-disabled-bg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:border-disabled-fg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:border-transparent:disabled{border-color:transparent}.pi .disabled\\:border-white\\/70:disabled{border-color:#ffffffb3}.pi .disabled\\:border-r-transparent:disabled{border-right-color:transparent}.pi .disabled\\:bg-disabled:disabled{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:bg-transparent:disabled{background-color:transparent}.pi .disabled\\:text-disabled:disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:text-white\\/70:disabled{color:#ffffffb3}.pi .disabled\\:shadow-none:disabled{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .disabled\\:before\\:bg-disabled-fg:disabled:before{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity));content:var(--tw-content)}.pi :is(.dark .dark\\:bg-chip){--tw-bg-opacity:1;background-color:rgb(var(--be-background-chip)/var(--tw-bg-opacity))}.pi :is(.dark .dark\\:text-white\\/50){color:#ffffff80}.pi :is(.dark .dark\\:checked\\:border-primary-dark:checked){--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi :is(.dark .dark\\:checked\\:bg-primary-dark:checked){--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}@media (min-width:640px){.pi .sm\\:text-sm{font-size:14px;line-height:20px}}@media (min-width:768px){.pi .md\\:text-lg{font-size:18px;line-height:28px}}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-2:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-inset:focus-visible>.tree-label{--tw-ring-inset:inset}\n'),!t.selector)throw new Error('Pixie required "selector" option.');const r=document.querySelector(t.selector);r&&(r.classList.add("pi"),function(e){um=e,dm=e}(r),this.setConfig(t),vm.setState({editor:this}),_(r).render(e(i.StrictMode,{children:e(SR,{})})))}get state(){return ym()}get defaultConfig(){return t.defaultConfig}open(e={}){return new Promise(async t=>{var r;Object.keys(e).length?await this.resetEditor({...eg(e,{ui:{visible:!0},image:e.image||ym().config.image,state:e.state||ym().config.state,blankCanvasSize:e.blankCanvasSize||ym().config.blankCanvasSize})}):null!=(r=ym().config.ui)&&r.visible||ym().setConfig({ui:{visible:!0}}),t()})}close(){var e,t,r;null!=(e=ym().config.ui)&&e.visible&&(this.setConfig({ui:{visible:!1}}),null==(r=(t=ym().config).onClose)||r.call(t))}setConfig(e){ym().setConfig(e)}uploadAndAddImage(){return bm().import.uploadAndAddImage()}uploadAndReplaceMainImage(){return bm().import.uploadAndReplaceMainImage()}uploadAndOpenStateFile(){return bm().import.uploadAndOpenStateFile()}newCanvas(e,t,r){return bm().canvas.openNew(e,t,r)}getState(e){return JSON.stringify(Sm(e))}setState(e){return bm().import.loadState(e)}async setStateFromUrl(e){const t=await Cm(e);return bm().import.loadState(t)}openTool(e){km(e)}applyChanges(){ym().applyChanges()}cancelChanges(){ym().cancelChanges()}async resetEditor(e){await xm(e),await bm().canvas.loadInitialContent()}togglePanel(e,t){"objects"===e&&ym().togglePanel("history",!1),"history"===e&&ym().togglePanel("objects",!1),ym().togglePanel(e,t)}on(e,t){var r;null==(r=this.fabric)||r.on(e,t)}isDirty(){return ym().dirty}get(e){return this.tools[e]}notify(e){return Om(e)}static init(e){return new Promise(t=>{const r=e.onLoad;e.onLoad=e=>{null==r||r(e),t(e)},new this(e)})}};dl(kR,"defaultConfig",If),dl(kR,"version",Af);let AR=kR;function IR(e){if(!this.backgroundColor)return;const t=this._getNonTransformedDimensions(),r=-t.x/2,n=-t.y/2,i=t.x,o=t.y,a=this.backgroundColor;if("string"==typeof a||a instanceof CanvasGradient||a instanceof CanvasPattern)e.fillStyle=a,e.fillRect(r,n,i,o);else if("object"!=typeof a||!("type"in a)||"linear"!==a.type&&"radial"!==a.type){if("source"in a&&(a.source instanceof HTMLImageElement||a.source instanceof HTMLCanvasElement))if(a.repeat){const t=e.createPattern(a.source,a.repeat);t&&(e.fillStyle=t,e.fillRect(r,n,i,o))}else e.drawImage(a.source,r,n,i,o)}else{const t=function(e,t,r,n){var i,o;if("linear"===t.type){const i=e.createLinearGradient(r+t.coords.x1,n+t.coords.y1,r+t.coords.x2,n+t.coords.y2);return t.colorStops.forEach(e=>i.addColorStop(e.offset,e.color)),i}if("radial"===t.type){const a=e.createRadialGradient(r+t.coords.x1,n+t.coords.y1,null!==(i=t.coords.r1)&&void 0!==i?i:0,r+t.coords.x2,n+t.coords.y2,null!==(o=t.coords.r2)&&void 0!==o?o:0);return t.colorStops.forEach(e=>a.addColorStop(e.offset,e.color)),a}throw new Error("Unknown gradient type")}(e,a,r,n);e.fillStyle=t,e.fillRect(r,n,i,o)}this._removeShadow(e)}const ER="fm-pixie-editor";const FR=new class{constructor(){this._container=document.createElement("div"),this._instance=null,this._container.classList.add(ER),this._container.style.width="100%",this._container.style.height="85vh",this._container.style.minHeight="400px"}get className(){return`.${ER}`}get canvas(){var e,t;return null===(t=null===(e=this._instance)||void 0===e?void 0:e.state.canvasRef)||void 0===t?void 0:t.current}get tools(){var e;return null===(e=this._instance)||void 0===e?void 0:e.tools}isLoaded(){return!!this._instance}async _setConfig(e){var t;this._instance?await this._instance.resetEditor(e):this._instance=await AR.init(Object.assign(Object.assign({},e),{selector:this.className})),(t=this._instance).fabric?t.fabric.on("object:added",e=>{const t=e.target;t&&"text"===t.name&&(t._renderBackground=IR)}):console.warn("Pixie fabric instance is not available")}async show(e,t,r=t.firstChild){t.insertBefore(this._container,r),await this._setConfig(e),this._instance.open()}close(){var e;null===(e=this._container.parentNode)||void 0===e||e.removeChild(this._container)}};function TR(e,t){if(!e)return t;if(!t)return e;return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function OR(e,t){if(/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(t))return t;const r=function(e){const t="undefined"!=typeof __webpack_public_path__?__webpack_public_path__:"";if(e&&/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(e))return e;let r=TR(t,e||"");return!r||r.startsWith("/")||/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(r)||(r="/"+r),r}(e),n=TR(r,t);return!n||n.startsWith("/")||/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(n)?n:"/"+n}var PR,MR;!function(e){e.TOP="top",e.BOTTOM="bottom",e.HIDDEN=""}(PR||(PR={})),function(e){e.TOP="top",e.BOTTOM="bottom",e.HIDDEN=""}(MR||(MR={}));const RR=(e,t="image/png")=>fetch(`data:${t};base64,${e}`).then(e=>e.blob());function LR(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=()=>{var e;return r(null!==(e=n.error)&&void 0!==e?e:new Error("Failed to convert blob to data URL"))},n.readAsDataURL(e)})}const NR=({visible:r,onClose:n,file:o,onSave:a,onSaveCopy:s})=>{var l;const{t:c}=Yn(),u=i.useRef(null),d=Oo(),h=Ga(),{options:f,actions:p}=po(),{i18n:g}=Yn(),{config:m}=f,{setCurrentMenuFile:v}=p,{getFileData:y,resolveFileForEditByUrl:b}=h,[w,x]=i.useState(!1),[C,_]=i.useState(null),[S,k]=i.useState(""),[A,I]=i.useState(!1),[E,F]=i.useState(!1),[T,O]=i.useState(null),P=i.useRef(!1),R=i.useRef(),L=i.useRef(),N=i.useRef("saveCopy"),j=i.useRef(void 0);R.current=a,L.current=s,i.useEffect(()=>{o&&!P.current&&(async()=>{if(j.current!==o)if("object"!=typeof o){j.current=o,x(!0);try{if(o.startsWith("data:"))O({thumbnail:o,saveWithoutFolder:!0});else{const e=await b(o);j.current===o&&O(e)}}catch(e){console.error("Failed to load file for editor:",e),j.current===o&&(j.current=null),null==n||n()}finally{x(!1)}}else O(o)})()},[o,n,b]);const D=i.useCallback(async e=>{try{if("string"==typeof e.thumbnail&&e.thumbnail.startsWith("data:"))return e.thumbnail;const t=await y(e.id,!0);if(!t)throw new Error(c("Error loading image"));return new Promise(e=>{const r=new FileReader;r.onload=()=>e(r.result),r.readAsDataURL(t)})}catch(e){throw console.error("Error getting the image data:",e),e}},[y,c]);i.useEffect(()=>{if(!C&&r&&T){let e=!1;const t=async()=>{var t,r,i;x(!0);try{const t=await D(T);if(!t||"string"!=typeof t||""===t.trim())throw new Error("Invalid image data: empty or null");if(!t.startsWith("data:"))throw new Error("Invalid image data: not a valid data URL");const r=t.match(/^data:([^;]+);base64,(.+)$/);if(!r)throw new Error("Invalid image data: malformed data URL format");const[,n,i]=r;if(!n.startsWith("image/"))throw new Error(`Invalid image data: unsupported MIME type ${n}`);if(i.length<10)throw new Error("Invalid image data: base64 content too short");if(!/^[A-Za-z0-9+/]+=*$/.test(i))throw new Error("Invalid image data: corrupted base64 content");if(!e){_(t);const e=Ta(T,"image/png");k(e.mimeType)}}catch(o){e||(d.error({id:"IMAGE_DOWNLOAD_FAILED",innerException:o,message:c("Error loading image"),placement:"bottomRight",data:{itemId:null!==(t=null==T?void 0:T.id)&&void 0!==t?t:void 0,itemName:null!==(r=null==T?void 0:T.name)&&void 0!==r?r:void 0,folderId:null!==(i=null==T?void 0:T.folderId)&&void 0!==i?i:null,thumbnail:null==T?void 0:T.thumbnail}}),null==n||n())}finally{x(!1)}};return t(),()=>{e=!0}}},[T,D,C,n,c,r]);const z=i.useCallback(async(e,t,r)=>{var n;let i=await function(e,t){if("json"===e)return new Blob([t],{type:"application/json"});if("svg"===e)return new Blob([t],{type:"image/svg+xml"});let r=`image/${e}`;if(t.startsWith("data:")){const e=Ir(t);e&&e.startsWith("image/")&&(r=e);const n=t.replace(/data:image\/[^;]+;base64,/,"");return RR(n,Ar(r))}return RR(t,Ar(r))}(r,e),o=Ar(i.type||`image/${r}`);const a=null!==(n=null==m?void 0:m.compessorUrl)&&void 0!==n?n:null==m?void 0:m.compressorUrl;if(o.startsWith("image/"))try{const e=new File([i],t,{type:o}),r=await La(e,{maxSizeMB:null==m?void 0:m.compressMaxSize,maxWidthOrHeight:null==m?void 0:m.compressMaxWidthOrHeight,mimeType:o,fileName:t,libURL:a,enableCompression:Boolean(m)&&"image/gif"!==o});i=r,o=r.type}catch(e){console.warn("Image preparation failed, using original:",e)}return{blob:i,mimeType:o,thumbnailDataUrl:await LR(i)}},[m]),B=i.useCallback(async(e,t,r,n)=>{var i,o,a,s,l,u;const h="save"===n?R.current:L.current;if(!T||!h)return;const f="object"==typeof T&&null!==T?T:null;let p=null;try{x(!0);const{blob:o,mimeType:a,thumbnailDataUrl:s}=await z(e,t,r),l=Object.assign(Object.assign({},T),{thumbnail:s,size:o.size,date:(new Date).toISOString().split("T")[0],type:a,folderId:T.folderId||"",name:T.name||t,extension:T.extension||(null===(i=(T.name||t).split(".").pop())||void 0===i?void 0:i.toLowerCase())||""});p=l;const u={blob:o,mimeType:a,thumbnail:s,mode:n},d=await h(l,u);if(d)return x(!1),d;throw new Error(c("saveCopy"===n?"Failed to save image copy":"Failed to save changes"))}catch(e){console.error("Error saving:",e);const r=null!=p?p:f,i=e;if(!(null==i?void 0:i.notificationShown)){const i=No(e),h=null!==(a=null!==(o=Ro(null==i?void 0:i.code,c))&&void 0!==o?o:null==i?void 0:i.message)&&void 0!==a?a:c("saveCopy"===n?"Failed to save image copy":"Error saving image");d.error({id:"saveCopy"===n?"IMAGE_SAVE_COPY_FAILED":"IMAGE_SAVE_FAILED",message:h,placement:"bottomRight",data:{itemId:null!==(s=null==r?void 0:r.id)&&void 0!==s?s:void 0,itemName:null!==(l=null==r?void 0:r.name)&&void 0!==l?l:t,folderId:null!==(u=null==r?void 0:r.folderId)&&void 0!==u?u:null,thumbnail:null==r?void 0:r.thumbnail},innerException:e})}x(!1)}},[T,d,z,c]),U=i.useCallback(async e=>{var t;if(!FR.isLoaded()||!T)return void console.error("❌ Pixie instance or file is missing");N.current=e;const r=T.name||"edited-image",n=Ta(T,S);try{await(null===(t=FR.tools)||void 0===t?void 0:t.export.save(r.replace(/\.[^/.]+$/,""),n.pixieFormat,Oa.QUALITY))}catch(t){console.error("🎨 Error saving through the button:",t);try{const t=FR.canvas,i=t?t.toDataURL(n.mimeType):null;i&&await B(i,r,n.extension,e)}catch(e){console.error("🎨 Alternative method also did not work:",e)}}},[T,S,B]),V=i.useCallback(async()=>{var t;if(C&&r&&A&&!P.current)try{P.current=!0;const r=u.current;let i=0;for(;i<20&&(0===r.clientWidth||0===r.clientHeight);)await new Promise(e=>setTimeout(e,50)),i++;const o=(null==m?void 0:m.locale)?null==m?void 0:m.locale.replace("_","-"):"en",a=matchMedia(hr).matches?ur:cr,s=(null==m?void 0:m.theme)===dr?a:null==m?void 0:m.theme,l=((null==m?void 0:m.locale)||g.language||"en").split("-")[0].split("_")[0],c=(g.getResourceBundle(l,"translation")||{}).pixie||{},d=e=>e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),h={};Object.entries(c).forEach(([e,t])=>{const r=d(e);h[r]=t,h[e]=t});const f={[o]:h},p=Ta(T,S),v={selector:"#pixie-editor",baseUrl:OR((null==m?void 0:m.baseUrl)||"",(null==m?void 0:m.assetsUrl)||"assets/image-editor"),image:C,activeLanguage:o,languages:f,ui:{activeTheme:s,mode:"inline",forceOverlayModeOnMobile:!1,visible:!0,menubar:{replaceDefaultItems:!0,position:PR.TOP,items:[{type:"undoWidget",align:"left"},{type:"zoomWidget",align:"center",desktopOnly:!0},{type:"button",align:"right",desktopOnly:!0,icon:()=>e(xe,{style:{fontSize:20}}),action:e=>{e.togglePanel("history")}},{type:"button",icon:()=>e(be,{style:{fontSize:20}}),align:"right",desktopOnly:!0,action:n}]},nav:{position:MR.TOP}},tools:{export:{defaultFormat:p.pixieFormat,defaultQuality:Oa.QUALITY,defaultName:(null===(t=null==T?void 0:T.name)||void 0===t?void 0:t.replace(/\.[^/.]+$/,""))||"image"},text:{replaceDefaultItems:!0,defaultText:"Handwriting",items:[{family:"Inter",src:"fonts/inter-v20-cyrillic_latin-regular.woff2"},{family:"Commissioner",src:"fonts/commissioner-v24-cyrillic_latin-regular.woff2"},{family:"Montserrat Light",src:"fonts/Montserrat-Light.woff2"},{family:"Montserrat Regular",src:"fonts/Montserrat-Regular.woff2"},{family:"Montserrat Bold",src:"fonts/Montserrat-Bold.woff2"},{family:"Montserrat Black",src:"fonts/Montserrat-Black.woff2"},{family:"Roboto Light",src:"fonts/Roboto-Light.woff2"},{family:"Roboto Regular",src:"fonts/Roboto-Regular.woff2"},{family:"Roboto Bold",src:"fonts/Roboto-Bold.woff2"},{family:"Roboto Black",src:"fonts/Roboto-Black.woff2"},{family:"Lato Light",src:"fonts/Lato-Light.woff2"},{family:"Lato Regular",src:"fonts/Lato-Regular.woff2"},{family:"Lato Bold",src:"fonts/Lato-Bold.woff2"},{family:"Lato Black",src:"fonts/Lato-Black.woff2"},{family:"Rubik Light",src:"fonts/Rubik-Light.woff2"},{family:"Rubik Regular",src:"fonts/Rubik-Regular.woff2"},{family:"Rubik Bold",src:"fonts/Rubik-Bold.woff2"},{family:"Rubik Black",src:"fonts/Rubik-Black.woff2"},{family:"Bebas Neue Light",src:"fonts/BebasNeueLight.woff2"},{family:"Bebas Neue Regular",src:"fonts/BebasNeueRegular.woff2"},{family:"Bebas Neue Book",src:"fonts/BebasNeueBook.woff2"},{family:"Bebas Neue Bold",src:"fonts/BebasNeueBold.woff2"},{family:"Fira Sans",src:"fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"},{family:"Lobster",src:"fonts/Lobster.woff2"},{family:"Pacifico",src:"fonts/pacifico-v23-cyrillic_latin-regular.woff2"},{family:"Playfair Display",src:"fonts/playfair-display-v40-cyrillic_latin-regular.woff2"},{family:"Oswald",src:"fonts/oswald-v57-cyrillic_latin-regular.woff2"},{family:"Caveat",src:"fonts/caveat-v23-cyrillic_latin-regular.woff2"}]}},onSave:async function(e,t,r){try{x(!0);return await B(e,t,r,N.current)}catch(e){throw console.error("🎨 PIXIE onSave ERROR:",e),x(!1),e}}};try{F(!1),await FR.show(v,u.current);const e=FR.canvas;e&&e.focus(),F(!0),x(!1)}catch(e){console.error("init pixie failed:",e)}}catch(e){console.error("Error initializing Pixie:",e),d.error({id:"EDITOR_INIT_FAILED",message:c("Error initializing editor"),placement:"bottomRight",innerException:e}),P.current=!1,null==n||n()}},[T,S,C,r,A,null==m?void 0:m.locale,null==m?void 0:m.theme,null==m?void 0:m.baseUrl,null==m?void 0:m.assetsUrl,n,B,d,g,c]);i.useEffect(()=>{r&&C&&A&&V()},[r,C,A,V]),i.useEffect(()=>{if(!r){try{FR.close()}catch(e){console.warn("Error closing Pixie:",e)}x(!1),_(null),k(""),P.current=!1,I(!1),F(!1)}return()=>{try{FR.close()}catch(e){console.warn("Error closing Pixie when unmounting:",e)}}},[r]);const H=Boolean(null==T?void 0:T.id)&&!1!==(null===(l=null==m?void 0:m.features)||void 0===l?void 0:l.enableUpdateFile);return e(G,{title:(null==T?void 0:T.name)?c("Editing: {{name}}",{name:T.name}):c("Editing image"),open:r,closeIcon:null,onCancel:n,afterOpenChange:e=>I(e),forceRender:!0,width:"100vw",style:{top:0,height:"100vh",maxWidth:"none",padding:10},styles:{body:{height:"85vh",padding:0}},footer:[e(M,{onClick:n,disabled:!A||w,children:c("Cancel")},"cancel"),e(M,{type:"primary",onClick:()=>U("saveCopy"),loading:w,children:c("Save as copy and choose")},"save-copy"),...H?[e(M,{type:"primary",onClick:()=>U("save"),loading:w,children:c("Save and choose")},"save")]:[]],maskClosable:!1,destroyOnHidden:!1,afterClose:()=>{v&&v("")},children:t("div",{ref:u,style:{position:"relative",width:"100%",height:"100%"},children:[r&&!E?e("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.45)",backdropFilter:"blur(1px)",pointerEvents:"all",zIndex:10},children:e("span",{style:{fontSize:14,color:"#555"},children:c("Loading editor...")})}):null,w&&E&&e(rl,{style:{position:"absolute",top:0,background:"var(--colorBgLayout)",zIndex:100,opacity:.7}})]})})};var jR="uploadProgress",DR="uploadProgress__card",zR="uploadProgress__header",BR="uploadProgress__header-title",UR="uploadProgress__header-buttons",VR="uploadProgress__header-button",HR="uploadProgress__close-icon",$R="uploadProgress__body",WR="uploadProgress__common-error",GR="uploadProgress__common-error-row",qR="uploadProgress__common-error-hint",YR="uploadProgress__list-wrapper",XR="uploadProgress__status-icon",KR="uploadProgress__file-item",ZR="uploadProgress__file-item--error",JR="uploadProgress__body--error",QR="uploadProgress__error-item",eL="uploadProgress__error-message",tL="uploadProgress__error-hint",rL="uploadProgress__file-avatar",nL="uploadProgress__file-info",iL="uploadProgress__file-name",oL="uploadProgress__file-size",aL="uploadProgress__progress-bar",sL="uploadProgress__minimized",lL="uploadProgress__minimized-button",cL="uploadProgress__file-list";const{Text:uL}=T,dL=({visible:r,files:n,totalFiles:i,completedFiles:o,onClose:a,onMinimize:s,onInsert:l,minimized:c=!1})=>{var u;const{token:d}=k.useToken(),{t:h}=Yn();if(!r)return null;const f=t=>{switch(t){case"success":return e("div",{className:XR,children:e(Se,{style:{color:d.colorSuccess}})});case"error":return e(Ce,{style:{color:d.colorError}});default:return e(_e,{style:{color:"#1890ff"}})}},p=t=>"success"===t.status?[e(M,{type:"primary",size:"small",onClick:()=>l(t),children:h("Insert")},"insert")]:[];if(c)return e("div",{className:sL,children:e(M,{type:"primary",size:"small",onClick:s,className:lL,children:h("Upload progress",{completed:o,total:i})})});const g=n.filter(e=>"uploading"===e.status).length,m=n.filter(e=>"success"===e.status).length,v=n.filter(e=>"error"===e.status).length,y=n.filter(e=>"error"===e.status),b=y.length>1&&y.every(e=>{var t;return e.error&&e.error===(null===(t=y[0])||void 0===t?void 0:t.error)}),w=b?null===(u=y[0])||void 0===u?void 0:u.error:null;return e("div",{className:jR+" fm-upload-progress",children:t("div",{className:DR,children:[t("div",{className:zR,children:[e(uL,{strong:!0,className:BR,children:g>0?h("Uploading files",{completed:o,total:i}):m>0?h("Uploaded files",{success:m,total:i}):h("Upload error files",{errorCount:v})}),e("div",{className:UR,children:e(M,{type:"text",size:"small",icon:e(be,{className:HR}),onClick:a,className:VR})})]}),t("div",{className:`${$R} ${n.some(e=>"error"===e.status)?JR:""}`,children:[e("div",{className:YR,children:e(K,{className:cL,size:"small",dataSource:n,renderItem:r=>{const n="error"===r.status,i=n?(e=>{if(!e)return null;const t=e.toLowerCase();return t.includes("type")||t.includes("format")||t.includes("формат")||t.includes("тип")||t.includes("not allowed")||t.includes("дозволен")||t.includes("name")||t.includes("invalid")||t.includes("назва")||t.includes("неприпустим")||t.includes("allowed characters")?null:t.includes("large")||t.includes("size")||t.includes("розмір")||t.includes("размер")?h("upload_error_hint_size"):t.includes("exists")||t.includes("вже існує")||t.includes("уже существует")?h("upload_error_hint_exists"):null})(r.error):null;return e(K.Item,{className:`${KR} ${n?ZR:""}`,actions:p(r),children:e(K.Item.Meta,{avatar:e(Z,{size:"small",icon:f(r.status),className:rL}),title:t("div",{className:nL,children:[e(uL,{ellipsis:!0,className:iL,children:r.name}),e(uL,{type:"secondary",className:oL,children:void 0!==r.size?ui(r.size):""})]}),description:"uploading"===r.status?e(q,{percent:r.progress,size:"small",status:"active",showInfo:!1,className:aL}):n?b?null:t("div",{className:QR,children:[e(uL,{type:"danger",className:eL,children:r.error||h("Error")}),i&&e(uL,{type:"secondary",className:tL,children:i})]}):null})})}})}),w&&t("div",{className:WR,children:[t("div",{className:GR,children:[e(Ce,{style:{color:d.colorError,marginRight:8,flexShrink:0}}),e(uL,{type:"danger",children:w})]}),e(uL,{type:"secondary",className:qR,children:h("Applies to all {{count}} files",{count:y.length})})]})]})]})})},{Header:hL}=J,{Title:fL}=T,pL=({activeLibraryItem:r,selectedFolder:i,isTrashFolder:o,onClearTrash:a,files:s,loading:l,onRefresh:c,refreshDisabled:u,showRefresh:d=!1})=>{const{t:h}=Yn(),f=r===rr&&(null!=o?o:i===lr),[p,g]=n.useState(!1),m={[rr]:h("My files"),[nr]:h("GIF"),[ir]:h("Stock images"),[or]:h("Icons"),[ar]:h("AI image generation")};let v;return n.useEffect(()=>{const e=setTimeout(()=>{g(f&&s.length>0&&!l)},200);return()=>clearTimeout(e)},[f,s.length,l]),v=r===rr?f?h("Trash"):i:m[r],e(hL,{className:"actions-header",children:t("div",{className:"header-title-container",children:[e(fL,{level:5,className:"header-title",children:v}),p&&a&&e(M,{type:"default",onClick:a,className:"clear-trash-button","aria-label":h("Clear Trash"),children:h("Clear")}),r===rr&&d&&c&&e(P,{title:h("Refresh"),children:e(M,{type:"text",className:"folder-refresh-button",icon:e(Ei,{size:16}),onClick:c,disabled:u})})]})})};function gL(e,t){return!e||!t||e<=0||t<=0?1:e/t}const mL=1200;function vL({items:e,getId:t,getPreviewSrc:r,getAltText:n,getWidth:i,getHeight:a,layoutMode:s="masonry",minColumnWidth:l=240,estimatedItemHeight:c=240,gap:u=20,overscanPx:h=800,prefetchThresholdPx:f=1200,resolveColumnCount:p,virtualizationThreshold:g=40}){var m,v;const[y,b]=o({scrollTop:0,viewportHeight:800,viewportWidth:mL,scrollHeight:0}),w=d(()=>function(e){return{getId:e,buildSignature:(t,r)=>{var n,i;const o=r.getPreviewSrc(t)||"",a=r.getAltText(t),s=null===(n=r.getWidth)||void 0===n?void 0:n.call(r,t),l=null===(i=r.getHeight)||void 0===i?void 0:i.call(r,t);return[e(t),o,a,null!=s?s:"",null!=l?l:""].join("::")},buildRowModel:(e,t,r)=>{var n,i;const o=null===(n=t.getWidth)||void 0===n?void 0:n.call(t,e),a=null===(i=t.getHeight)||void 0===i?void 0:i.call(t,e);return{id:r.id,signature:r.signature,item:e,previewSrc:t.getPreviewSrc(e),altText:t.getAltText(e),width:o,height:a,aspectRatio:gL(o,a)}}}}(t),[t]),x=d(()=>({getPreviewSrc:r,getAltText:n,getWidth:i,getHeight:a}),[n,a,r,i]),C=d(()=>{const e=Math.max(1,y.viewportWidth||mL);return p?Math.max(1,p(e)):Math.max(1,Math.floor((e+u)/(l+u)))},[u,l,p,y.viewportWidth]),_=d(()=>{const e=Math.max(1,y.viewportWidth||mL);return Math.max(1,(e-u*Math.max(0,C-1))/C)},[C,u,y.viewportWidth]),S=d(()=>{const t=new Array(C).fill(0),r=[];e:for(let n=0;n<e.length;n+=1){const o=e[n],l=null==i?void 0:i(o),d=null==a?void 0:a(o),h=l&&d&&l>0&&d>0?l/d:void 0,f=h?_/h:c;if("grid"===s){const e=Math.floor(n/C)*(f+u),t=n%C*(_+u);r.push({index:n,top:e,left:t,width:_,height:f,bottom:e+f});continue e}let p=0;for(let e=1;e<t.length;e+=1)t[e]<t[p]&&(p=e);const g=t[p],m=p*(_+u);t[p]=g+f+u,r.push({index:n,top:g,left:m,width:_,height:f,bottom:g+f})}const n=0===r.length?0:"grid"===s?Math.max(...r.map(e=>e.bottom)):Math.max(0,...t.map(e=>e-u));return{positionedItems:r,containerHeight:n}},[C,_,c,u,a,i,e,s]),k=d(()=>e.length<=g?{renderStrategy:"full"}:{renderStrategy:"positioned",positioned:{layout:S.positionedItems,viewportTop:y.scrollTop,viewportBottom:y.scrollTop+y.viewportHeight,overscanPx:h,containerHeight:S.containerHeight}},[e.length,S.containerHeight,S.positionedItems,h,y.scrollTop,y.viewportHeight,g]),{rowModels:A,renderWindow:I}=zs({items:e,context:x,adapter:w,options:k}),E=null!==(m=I.positionedItems)&&void 0!==m?m:A.map((e,t)=>{var r;return{row:e,layout:null!==(r=S.positionedItems[t])&&void 0!==r?r:{index:t,top:0,left:0,width:_,height:c,bottom:c}}}),F=null!==(v=I.containerHeight)&&void 0!==v?v:S.containerHeight,T=F>0&&y.scrollTop+y.viewportHeight>=F-f;return{rowModels:A,renderRows:I.rows,renderWindow:I,positionedItems:E,containerHeight:F,isNearEnd:T,viewportMetrics:y,handleViewportChange:e=>{b(t=>t.scrollTop===e.scrollTop&&t.viewportHeight===e.viewportHeight&&t.viewportWidth===e.viewportWidth&&t.scrollHeight===e.scrollHeight?t:e)}}}const yL=t=>{var r,{imageId:n,sourceUrl:i,shouldLoad:s=!0,loader:l,onLoad:c}=t,d=As(t,["imageId","sourceUrl","shouldLoad","loader","onLoad"]);const[h,f]=o(()=>l.getSnapshot(n,i)),p=u(null);return a(()=>(f(l.getSnapshot(n,i)),l.subscribe(n,i,f)),[n,l,i]),a(()=>(l.setActive(n,i,s),()=>{l.setActive(n,i,!1),l.release(n)}),[n,l,s,i]),h.shouldLoad?e("img",Object.assign({},d,{ref:p,src:i,loading:null!==(r=d.loading)&&void 0!==r?r:"lazy",onLoad:e=>{l.markLoaded(n),null==c||c(e)},onError:e=>{var t;l.markError(n),null===(t=d.onError)||void 0===t||t.call(d,e)}})):null};var bL={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",virtualCanvas:"virtualCanvas",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const wL=e=>{const t="undefined"!=typeof window?window.innerWidth:e;return t<=700?1:t<=1100?2:t<=1600?3:4},xL=e=>e.images.downsized.url,CL=({setImageGifList:n,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:d,customRequest:h})=>{const{t:f}=Yn(),{GifPlayIcon:p}=mo(),{options:g}=po(),{config:m}=g,v=cs({maxConcurrent:6}),[y,b]=o(null),[w,x]=o(new Set),[C,_]=o(!1),[k,A]=o(!1),[I,T]=o(!1),[O]=E.useForm(),P=u(s),M=u(null),R=u(null),L=u(null),N=u(0),j=u(0),D=u(new Set);a(()=>{P.current=s},[s]),a(()=>{O.setFieldsValue({keywords:s.keywords})},[]);const z=null==m?void 0:m.handleProxyUrl,B=async e=>z?Promise.resolve(z(e)):e,U=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await B(e.images.downsized.url)}),fixed_width:e.images.fixed_width?Object.assign(Object.assign({},e.images.fixed_width),{url:await B(e.images.fixed_width.url)}):void 0,fixed_width_downsampled:e.images.fixed_width_downsampled?Object.assign(Object.assign({},e.images.fixed_width_downsampled),{url:await B(e.images.fixed_width_downsampled.url)}):void 0})}))),V=async function({query:e,page:t}){var r;const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(r=null==m?void 0:m.REACT_APP_GIPHY_KEY)&&void 0!==r?r:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(n)}&limit=50&offset=${t}&lang=en`,i=await fetch(await B(e));return{data:await i.json()}}catch(e){console.warn(e)}},{positionedItems:H,containerHeight:$,isNearEnd:W,viewportMetrics:G,handleViewportChange:q}=vL({items:i,getId:e=>e.id,getPreviewSrc:xL,getAltText:e=>e.title,getWidth:e=>e.images.downsized.width?Number(e.images.downsized.width):void 0,getHeight:e=>e.images.downsized.height?Number(e.images.downsized.height):void 0,layoutMode:"masonry",minColumnWidth:240,estimatedItemHeight:220,prefetchThresholdPx:320,resolveColumnCount:wL}),Y=ys(q,[i.length]),X=()=>{M.current&&(clearTimeout(M.current),M.current=null)},K=e=>!D.current.has(e)&&(D.current.add(e),!0),Z=e=>{D.current.delete(e)},J=c(async()=>{var e,t,r;const i=null===(e=P.current.keywords)||void 0===e?void 0:e.trim();if(!i||C||k||!I)return;const o=`gif:${i}:${j.current}`;if(!K(o))return;const a=N.current;A(!0);try{const e=await V({query:P.current,page:j.current});if(a!==N.current)return;const i=null!==(r=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.data)&&void 0!==r?r:[];if(!Array.isArray(i)||0===i.length)return void T(!1);const o=await U(i);if(a!==N.current)return;n(e=>{const t=new Set(e.map(e=>e.id)),r=o.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),j.current+=i.length,T(50===i.length)}finally{Z(o),a===N.current&&A(!1)}},[I,C,k,n]),Q=async()=>{var e,t;X();const r=null===(e=P.current.keywords)||void 0===e?void 0:e.trim();if(!r)return R.current=null,L.current=null,N.current+=1,j.current=0,n([]),x(new Set),T(!1),void A(!1);if(L.current===r)return;if(R.current===r||C&&R.current===r)return;const i=`gif:${r}:0`;if(!K(i))return;const o=N.current+1;N.current=o,R.current=r,j.current=0,n([]),x(new Set),T(!1),A(!1),_(!0);try{const e=await V({query:P.current,page:0});if(o!==N.current)return;const i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.data;if(Array.isArray(i)&&i.length>0){const e=await U(i);if(o!==N.current)return;n(e),j.current=i.length,T(50===i.length)}else n([]),T(!1);L.current=r}catch(e){T(!1)}finally{Z(i),R.current===r&&(R.current=null),_(!1)}};return a(()=>()=>{X()},[]),a(()=>{!C&&!k&&I&&i.length>0&&W&&J()},[I,i.length,W,J,C,k]),e("div",{className:bL.gifTab,children:e("div",{className:bL.searchOutputWrapper,children:t("div",{id:"scrollableDiv",ref:Y,className:bL.scrollableDiv,children:[t(E,{form:O,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},P.current),{keywords:e.keywords});l(t),P.current=t,X(),M.current=setTimeout(Q,800)}},className:i.length>0?bL.searchResults:bL.search,children:[e(E.Item,{name:"keywords",className:bL.gifSearchInput,children:e(F,{onPressEnter:()=>{Q()},allowClear:!0,placeholder:f("Search GIFs"),ref:d,spellCheck:"false",prefix:e(Ti,{size:16,strokeWidth:null==m?void 0:m.iconStrokeWidth,onClick:()=>{Q()}})})}),i.length>0&&!C&&e("div",{className:`ant-divider ${bL.divider}`,role:"separator"})]}),!i.length&&!C&&e(r,{children:s.keywords?e(xo,{}):t("div",{className:bL.resultsContainer,children:[e("div",{className:bL.videoIcon,children:e(p,{className:bL.playButton})}),e("h1",{className:bL.title,children:f("Over 350,000 live images")}),e("p",{className:bL.subtitle,children:f("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&C&&e(rl,{}),i.length>0&&t(r,{children:[e("div",{className:bL.virtualCanvas,style:{height:$},children:H.map(({row:r,layout:n})=>{const i=r.item,o=w.has(i.id),a=xL(i),s=n.bottom>=G.scrollTop-240&&n.top<=G.scrollTop+G.viewportHeight+240;return t("div",{className:`${bL.listItem} ${o?bL.loaded:""}`,onClick:()=>(async(e,t)=>{var r;b(t),setTimeout(()=>{b(null)},2e3);let n=e.split("?")[0].split("#")[0].split("/"),i=n[n.length-1]||"uploaded-file";i.includes(".")&&(null===(r=i.split(".").pop())||void 0===r?void 0:r.length)&&i.split(".").pop().length<=5||(i+=".gif"),h(e,i)})(i.images.downsized.url,i.id,i.title),style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height,minHeight:n.height,maxHeight:"none",marginBottom:0},children:[e(yL,{imageId:i.id,sourceUrl:a,shouldLoad:s,loader:v,className:y===i.id?bL.loadedImage:"",width:"100%",height:"100%",alt:i.title,decoding:"async",onLoad:()=>{x(e=>{if(e.has(i.id))return e;const t=new Set(e);return t.add(i.id),t})}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),y===i.id&&e(S,{className:bL.antSpin})]},i.id)})}),k&&e(rl,{})]})]})})})};var _L={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",virtualCanvas:"virtualCanvas",scrollableDiv:"scrollableDiv",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const SL=e=>{const t="undefined"!=typeof window?window.innerWidth:e;return t<=650?1:t<=1e3?2:t<=1450?3:4},kL=(e,t)=>{const r=new URL(e);return r.searchParams.set("w",t.toString()),r.toString()},AL=({imageStockList:n,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:d,customRequest:h})=>{var f,p;const{t:g}=Yn(),{StockBigIcon:m,MixedViewIcon:v,LandscapeViewIcon:y,PortraitViewIcon:b,SquareViewIcon:w}=mo(),{options:x}=po(),{config:C}=x,_=cs({maxConcurrent:6}),[k,A]=o(!1),[I,T]=o(!1),[O,M]=o(!1),[R,L]=o(null),[N,j]=o(new Set),[D]=E.useForm(),B=null==C?void 0:C.handleProxyUrl,V=null!==(f=null==C?void 0:C.UNSPLASH_KEY)&&void 0!==f?f:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",H=(null===(p=null==C?void 0:C.locale)||void 0===p?void 0:p.slice(0,2))||"ru",$=u(s),W=u(null),G=u(null),q=u(0),Y=u(1),X=u(new Set),K=async e=>B?Promise.resolve(B(e)):e,Z=()=>{W.current&&(clearTimeout(W.current),W.current=null)},J=e=>!X.current.has(e)&&(X.current.add(e),!0),ee=e=>{X.current.delete(e)},te=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:{raw:await K(kL(e.urls.raw,1200)),small:await K(kL(e.urls.raw,540))}})));a(()=>{$.current=s},[s]),a(()=>{0===n.length&&D.setFieldsValue({color:"",orientation:""})},[n,D]),a(()=>{D.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const re=async function({query:e,page:t}){const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let n=`https://api.unsplash.com/search/photos?client_id=${V}&lang=${H}&per_page=30&query=${encodeURIComponent(r)}&page=${t}`;""!==e.color&&(n+=`&color=${e.color}`),""!==e.orientation&&(n+=`&orientation=${e.orientation}`);const i=await fetch(await K(n));return{data:await i.json()}}catch(e){console.warn(e)}},{positionedItems:ne,containerHeight:ie,isNearEnd:oe,viewportMetrics:ae,handleViewportChange:se}=vL({items:n,getId:e=>e.id,getPreviewSrc:e=>e.urls.small,getAltText:e=>e.description||e.user.name,getWidth:e=>e.width,getHeight:e=>e.height,layoutMode:"masonry",minColumnWidth:240,estimatedItemHeight:220,prefetchThresholdPx:320,resolveColumnCount:SL}),le=ys(se,[n.length]),ce=c(async()=>{var e,t;if(k||I||!O||!$.current.keywords.trim())return;const r=q.current,n=Y.current,o=`stock:${`${$.current.keywords.trim()}|${$.current.color}|${$.current.orientation}`}:${n}`;if(J(o)){T(!0);try{const o=await re({query:$.current,page:n});if(r!==q.current)return;const a=null!==(t=null===(e=null==o?void 0:o.data)||void 0===e?void 0:e.results)&&void 0!==t?t:[];if(0===a.length)return void M(!1);const s=await te(a);if(r!==q.current)return;i(e=>{const t=new Set(e.map(e=>e.id)),r=s.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),Y.current=n+1,M(30===a.length)}finally{ee(o),r===q.current&&T(!1)}}},[O,k,I,i]),ue=async()=>{var e,t;Z();const r=`${$.current.keywords.trim()}|${$.current.color}|${$.current.orientation}`;if(!$.current.keywords.trim())return void(G.current=null);if(G.current===r)return;const n=`stock:${r}:1`;if(!J(n))return;const o=q.current+1;q.current=o,A(!0),T(!1),M(!1),Y.current=1,i([]),j(new Set);try{const n=await re({query:$.current,page:1});if(o!==q.current)return;const a=null!==(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.results)&&void 0!==t?t:[];if(a.length>0){const e=await te(a);if(o!==q.current)return;i(e),Y.current=2,M(30===a.length)}else M(!1);G.current=r}finally{ee(n),A(!1)}};a(()=>()=>{Z()},[]),a(()=>{!k&&!I&&O&&n.length>0&&oe&&ce()},[O,n.length,oe,ce,k,I]);const de=async(e,t,r,n)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${V}`,r=await K(t),n=await fetch(r);return{data:await n.json()}}catch(e){console.warn(e)}}(t.download_location),L(r),setTimeout(()=>L(null),2e3);const o=e.raw,a=o.split("?")[0].split("#")[0].split("/");let s=a[a.length-1]||"uploaded-file";s.includes(".")&&(null===(i=s.split(".").pop())||void 0===i?void 0:i.length)&&s.split(".").pop().length<=5||(s+=".jpg"),h(o,s)};return e("div",{className:_L.stockTab,children:e("div",{className:_L.searchOutputWrapper,children:t("div",{className:_L.scrollableDiv,id:"scrollableDiv",ref:le,children:[t(E,{form:D,initialValues:vr,onValuesChange:(e,t)=>{const r=Object.assign(Object.assign({},vr),t);l(r),$.current=r,Z(),""!==r.keywords?W.current=setTimeout(ue,800):(G.current=null,q.current+=1,Y.current=1,i([]),j(new Set),M(!1),T(!1),l(Object.assign({},vr)),$.current=vr,D.resetFields())},className:n.length>0?_L.searchResults:_L.search,children:[t(U,{gutter:24,children:[e(z,{span:n.length>0?void 0:24,children:e(E.Item,{name:"keywords",className:_L.stockSearchInput,children:e(F,{allowClear:!0,placeholder:g("Search image"),ref:d,spellCheck:"false",prefix:e(Ti,{size:16,strokeWidth:null==C?void 0:C.iconStrokeWidth})})})}),!!n.length&&t(r,{children:[e(z,{children:e(E.Item,{name:"orientation",children:t(Q.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(P,{title:g("All"),placement:"top",children:e(Q.Button,{value:"",children:e(v,{})})}),e(P,{title:g("Landscape"),placement:"top",children:e(Q.Button,{value:"landscape",children:e(y,{})})}),e(P,{title:g("Portrait"),placement:"top",children:e(Q.Button,{value:"portrait",children:e(b,{})})}),e(P,{title:g("Squarish"),placement:"top",children:e(Q.Button,{value:"squarish",children:e(w,{})})})]})})}),e(z,{children:e(E.Item,{name:"color",children:t(Q.Group,{className:_L.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(P,{title:g("All"),placement:"top",children:e(Q.Button,{className:_L.allColors,value:"",children:"All"})}),e(P,{title:g("Black"),placement:"top",children:e(Q.Button,{className:_L.blackColor,value:"black",children:"B"})}),e(P,{title:g("Black and White"),placement:"top",children:e(Q.Button,{className:_L.bwColor,value:"black_and_white",children:"B&W"})}),e(P,{title:g("White"),placement:"top",children:e(Q.Button,{className:_L.whiteColor,value:"white",children:"W"})}),e(P,{title:g("Orange"),placement:"top",children:e(Q.Button,{className:_L.orangeColor,value:"orange",children:"O"})}),e(P,{title:g("Red"),placement:"top",children:e(Q.Button,{className:_L.redColor,value:"red",children:"R"})}),e(P,{title:g("Purple"),placement:"top",children:e(Q.Button,{className:_L.purpleColor,value:"purple",children:"P"})}),e(P,{title:g("Magenta"),placement:"top",children:e(Q.Button,{className:_L.magentaColor,value:"magenta",children:"M"})}),e(P,{title:g("Green"),placement:"top",children:e(Q.Button,{className:_L.greenColor,value:"green",children:"G"})}),e(P,{title:g("Teal"),placement:"top",children:e(Q.Button,{className:_L.tealColor,value:"teal",children:"T"})}),e(P,{title:g("Blue"),placement:"top",children:e(Q.Button,{className:_L.blueColor,value:"blue",children:"B"})})]})})})]})]}),n.length>0&&!k&&e("div",{className:`ant-divider ${_L.divider}`,role:"separator"})]}),!n.length&&!k&&e(r,{children:s.keywords?e(xo,{}):t("div",{className:_L.resultsContainer,children:[e("div",{className:_L.videoIcon,children:e(m,{className:_L.playButton})}),e("h1",{className:_L.title,children:g("Millions of free stock images")}),e("p",{className:_L.subtitle,children:g("Enter a search query and we'll find the perfect image for you")})]})}),!n.length&&k&&e(rl,{}),n.length>0&&t(r,{children:[e("div",{className:_L.virtualCanvas,style:{height:ie},children:ne.map(({row:r,layout:n})=>{const i=r.item,o=N.has(i.id),a=n.bottom>=ae.scrollTop-240&&n.top<=ae.scrollTop+ae.viewportHeight+240;return t("div",{className:`${_L.listItem} ${o?_L.loaded:""}`,onClick:()=>de(i.urls,i.links,i.id,i.description),style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height,minHeight:n.height,maxHeight:"none",marginBottom:0},children:[e(yL,{imageId:i.id,sourceUrl:i.urls.small,shouldLoad:a,loader:_,className:R===i.id?_L.loadedImage:"",width:"100%",height:"100%",alt:i.description,decoding:"async",onLoad:()=>{j(e=>{if(e.has(i.id))return e;const t=new Set(e);return t.add(i.id),t})}}),t("p",{className:_L.creatorInfo,onClick:e=>e.stopPropagation(),children:[g("Photo by")," ",e("a",{target:"_blank",href:`${i.user.links.html}?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:i.user.name})," ",g("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),R===i.id&&e(S,{className:_L.antSpin})]},i.id)})}),I&&e(rl,{})]})]})})})},IL=()=>{const{options:e}=po(),t=e.config;return c((e,r)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const r=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(r,t):r()})(e,r)},[null==t?void 0:t.pushToGTM])};var EL="slideshowContainer",FL="slideshowImage";const TL=({images:t,transitionDuration:r=1e3,frameHeight:n})=>{const[i,s]=o([]),[l,c]=o(n);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(n);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof n){const e=Math.min(n,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n]);const u=()=>{s(e=>e.map((t,r)=>r===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(u,1e3)}else s([])},[t]),e("div",{className:EL,style:{height:l,minHeight:130},children:i.map((t,n)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${n+1}`,className:FL,style:{opacity:t.opacity,transition:`opacity ${r}ms linear`,display:"block"}},n))})},OL=t=>{var{className:r,style:n,color:i,text:o,bordered:a}=t,s=As(t,["className","style","color","text","bordered"]);const l=o||"";return e(ee,Object.assign({style:n,color:i,bordered:a,className:r},s,{children:l}))},PL=({text:r,counter:n,limits:i,wrapperStyles:o})=>{const{t:a}=Yn(),{options:s}=po(),l=s.config,{token:c}=k.useToken(),u=+i>0,d=!u||n<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=n+" "+a("of")+" "+(u?i:"∞")+" "+(r||a("tests",{count:i}))+" "+a("was used",{count:n});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(OL,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var ML={imageAi:"imageAi",imageAiExample:"imageAiExample",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const RL=f(({className:t,onClick:r})=>e("div",{className:`${ML.arrow} ${ML.arrowNext} ${t||""}`,onClick:r,children:e(M,{className:`${ML.arrowBtn} ${ML.arrowBtnNext}`,size:"large",icon:e(ke,{})})}));RL.displayName="SampleNextArrow";const LL=f(({className:t,onClick:r})=>e("div",{className:`${ML.arrow} ${ML.arrowPrev} ${t||""}`,onClick:r,children:e(M,{className:`${ML.arrowBtn} ${ML.arrowBtnPrev}`,size:"large",icon:e(Ae,{})})}));LL.displayName="SamplePrevArrow";const NL=({customRequest:r,inputAiRef:n,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Yn(),{AiIcon_2:b}=mo(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:k,requestStatus:A,handleGenerate:I,convertBase64ToFile:T,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:R}=function({setFrameHeight:e,customRequest:t,aiTabRef:r,isImageUploaded:n,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Yn(),{options:m}=po(),v=m.config,y=Oo(),b=IL(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[k,A]=o(null),[I,E]=o(!1),[F,T]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||k||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),D.current=-1)},[l,k]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),j=c(e=>{const t=`${k}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(T(String(e.status)),100===e.progress){p(!1),h(e.images);const t=k,r=Array.isArray(e.images)?e.images:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),A(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=k,r=e.data?[String(e.data)]:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),A(null),P(!1)}}else p(!1),P(!1),k&&!R.current.has(k)&&(R.current.add(k),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(k)||void 0,data:{requestId:k,request:s,response:e},innerException:e}))},[s,h,T,g,p,k,y,P]),D=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>D.current&&(D.current=e,j(x[e]))}},[j,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:H}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:$}=H,W=$>0&&_>=$,G=!(!(null==v?void 0:v.limits)||!v.counters)&&fr,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!W&&!G,[W,G,_,$]),X=c(async()=>{T(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,r,n,i,o,a,l,c,u;const{data:d,error:f}=e||{};if(f)throw f;const m=d;if(401===(null==m?void 0:m.status)||401===(null===(t=null==m?void 0:m.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const v=null!==(r=null==m?void 0:m.data)&&void 0!==r?r:m;if((null==v?void 0:v._eventResult)&&Array.isArray(null===(n=v.task)||void 0===n?void 0:n.images)&&(null!==(o=null===(i=v.task.images)||void 0===i?void 0:i.length)&&void 0!==o?o:0)>0){const e=v.task.images;return h(e),p(!1),P(!1),void A(null)}const b=(null==m?void 0:m.task)||(null===(a=null==m?void 0:m.data)||void 0===a?void 0:a.task),w=null!==(c=null!==(l=null==b?void 0:b.id)&&void 0!==l?l:k)&&void 0!==c?c:void 0;200===(null==m?void 0:m.status)||200===(null===(u=null==m?void 0:m.data)||void 0===u?void 0:u.status)?((null==b?void 0:b.id)&&(T(b.message),A(b.id)),(null==m?void 0:m.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:m.message,placement:"bottomRight",data:{request:s,taskId:w,response:null==m?void 0:m.data}}),z({task_id:null==b?void 0:b.id,entity_id:U})):(p(!1),P(!1),w&&!R.current.has(w)&&(R.current.add(w),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==m?void 0:m.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:w,response:m},innerException:m})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&k&&!R.current.has(k)&&(R.current.add(k),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:k,response:null==t?void 0:t.data,error:No(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,k]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(n)return;const r=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!r)return;const o=r[1],a=r[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[n,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,n;let i=350;if(r.current){const e=null===(t=r.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(n=r.current.getBoundingClientRect())||void 0===n?void 0:n.height)-48-e.clientHeight)}e(i)},0)},[r,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:$,isFieldsDisabled:W,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:F,setRequestStatus:T,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:I,setIsShiftPressed:E,currentReqId:k,setCurrentReqId:A,limitsInPlugin:G}}({setFrameHeight:C,customRequest:r,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[L,N]=o(!1),j=c(()=>N(!0),[]),D=c(()=>N(!1),[]),B=c(e=>f(e.target.value),[f]),V=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),I())},[O,I,P]),H=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:ML.imageAi,ref:w,children:[R&&e(PL,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e(U,{gutter:24,className:ML.row,children:t(z,{span:24,children:[e(E.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${ML.inputAffixWrapper}${L?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:n,onKeyDown:V,onKeyUp:H,onFocus:j,onBlur:D,autoSize:!0,allowClear:!0,className:`${ML.textAreaInputHybrid} ${ML.textarea}`,placeholder:y("Generate image"),value:h,onChange:B,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${ML.inputSuffix}`,children:m||k?e(se,{className:`${ML.inputIcon} input-icon`,spin:!0}):e(b,{className:`${ML.inputIcon} input-icon`,onClick:I})})]})}),t("div",{className:ML.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(te,{dotPosition:"top",arrows:!0,nextArrow:e(RL,{}),prevArrow:e(LL,{}),className:ML.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:ML.loading,children:t("div",{className:"spin",children:[e(se,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:A})]})}),p.length>0&&p.map((r,n)=>t("div",{className:ML.imageItem,children:[e(TL,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(M,{onClick:()=>T(`data:image/jpeg;base64, ${r}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},n))]})]})};var jL={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridLoadingMore:"iconsGridLoadingMore",iconsGridVirtualCanvas:"iconsGridVirtualCanvas",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridItemSelected:"iconsGridItemSelected",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const DL=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],zL=({query:r,onQueryChange:n,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Yn(),{options:u}=po(),{config:d}=u,h=r.length>0&&s;return t("div",{className:jL.iconsSearchFormCenteredContainer,children:[t(E,{layout:"inline",onFinish:i,className:h?jL.iconsSearchResults:jL.iconsSearchFormCentered,children:[e(E.Item,{className:jL.iconsSearchFormInput,children:e(F,{ref:l,className:jL.iconsSearchFormInputInput,allowClear:!0,prefix:e(Ti,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:r,onChange:e=>n(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(E.Item,{className:jL.iconsSearchFormStyleItem,children:e(O,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:jL.iconsSearchFormSelect,options:DL.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${jL.iconsSearchDivider}`,role:"separator"})]})},BL=n=>{const{t:i}=Yn(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=n;return t("div",{className:jL.iconsControls,children:[e("div",{className:jL.iconsControlsControls,children:"family"===o&&t(r,{children:[t("div",{className:jL.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(re,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:jL.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(re,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(R,{size:8,children:e(ne,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(r,{children:[t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ne,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ne,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:jL.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ne,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:jL.iconsControlsHeader,children:e("div",{children:"family"===o?e(M,{className:jL.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},UL=e(se,{style:{fontSize:20},spin:!0}),VL=({items:n,loading:o,isCollectingResults:a=!1,hasMore:s=!1,hasQuery:l,mode:c,selectedHash:u,onItemClick:d,onInsert:h,onLoadMore:f,colorVars:p,svgTextMap:g,previewSize:m,selectedHashes:v,onToggleSelect:y})=>{const{t:b}=Yn(),{ThumbsUpIcon:w}=mo(),x=cs({maxConcurrent:6}),C=Boolean(v&&v.size>0),_=i.useRef(null),k=Math.max(100,(null!=m?m:50)+48),{positionedItems:A,containerHeight:I,isNearEnd:E,viewportMetrics:F,handleViewportChange:T}=vL({items:n,getId:e=>e.hash,getPreviewSrc:e=>e.imagePreviewUrl,getAltText:e=>e.name,getWidth:()=>1,getHeight:()=>1,layoutMode:"grid",minColumnWidth:k,gap:16,prefetchThresholdPx:240}),O=ys(T,[n.length,null!=m?m:50]);i.useEffect(()=>{s||(_.current=null)},[s,n.length]),i.useEffect(()=>{if(!o&&!a&&s&&n.length>0&&E){if(_.current===n.length)return;_.current=n.length,null==f||f()}},[s,a,E,n.length,o,f]);const P=e("div",l?{className:jL.iconsGridEmptyState,children:e(xo,{})}:{className:jL.iconsGridEmptyState,children:t("div",{className:jL.resultsContainer,children:[e("span",{className:jL.videoIcon,children:e(w,{className:jL.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:jL.title,children:b("Millions of icons")}),e("p",{className:jL.subtitle,children:b("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:O,className:jL.iconsGrid,children:[0!==n.length||o?t(r,{children:[e("div",{className:jL.iconsGridVirtualCanvas,style:{height:I},children:A.map(({row:r,layout:n})=>{var i,o,a,s,l,h,f,b,w,_,S;const k=r.item,A=Boolean(v&&v.has(k.hash)||u===k.hash),I=n.bottom>=F.scrollTop-180&&n.top<=F.scrollTop+F.viewportHeight+180;return t("div",{style:{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height},className:`${jL.iconsGridItem} ${A?jL.iconsGridItemSelected:""} ${C?jL.iconsGridShowCheckboxes:""}`,onClick:()=>{d(k),y&&"family"===c&&y(k.hash)},children:[e("div",{style:{height:null!=m?m:50},className:jL.iconsGridItemThumbnail,children:"family"===c&&g[k.hash]?e("div",{style:{color:null==p?void 0:p.colorHex,"--icon-grad-1":null!==(i=null==p?void 0:p.colorHex)&&void 0!==i?i:"#000","--icon-grad-2":null!==(o=null==p?void 0:p.colorHex2)&&void 0!==o?o:"#ff007a","--icon-color-1":null!==(a=null==p?void 0:p.colorHex)&&void 0!==a?a:"#000","--icon-color-2":null!==(s=null==p?void 0:p.colorHex2)&&void 0!==s?s:"#ff007a","--icon-color-3":null!==(l=null==p?void 0:p.colorHex3)&&void 0!==l?l:"#00C2FF","--icon-stroke-1":null!==(h=null==p?void 0:p.colorHex)&&void 0!==h?h:"#000","--icon-stroke-2":null!==(f=null==p?void 0:p.colorHex2)&&void 0!==f?f:"#ff007a","--icon-stroke-3":null!==(b=null==p?void 0:p.colorHex3)&&void 0!==b?b:"#00C2FF","--icon-fill-1":null!==(w=null==p?void 0:p.colorHex)&&void 0!==w?w:"#000","--icon-fill-2":null!==(_=null==p?void 0:p.colorHex2)&&void 0!==_?_:"#ff007a","--icon-fill-3":null!==(S=null==p?void 0:p.colorHex3)&&void 0!==S?S:"#00C2FF"},dangerouslySetInnerHTML:{__html:g[k.hash]},className:jL.iconsGridItemSvg}):e(yL,{imageId:k.hash,sourceUrl:k.imagePreviewUrl,shouldLoad:I,loader:x,alt:k.name,style:{maxHeight:null!=m?m:96},className:jL.iconsGridItemImg,decoding:"async"})}),e("div",{className:jL.iconsGridItemName,title:k.name,children:k.name}),y?e("div",{onClick:e=>{e.stopPropagation()},className:jL.iconsGridCheckbox,children:e(N,{checked:Boolean(v&&v.has(k.hash)),onChange:()=>y(k.hash)})}):null]},k.hash)})}),a&&e("div",{className:jL.iconsGridLoadingMore,children:e(S,{indicator:UL})})]}):P,o&&0===n.length&&e("div",{className:jL.iconsGridLoading,children:e(S,{indicator:UL})})]})},HL="path|rect|circle|ellipse|polygon|line|polyline|g";function $L(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const r={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},n=t.toLowerCase();return r[n]?r[n]:("currentcolor"===n||"inherit"===n||/^[a-zA-Z]+$/.test(t),null)}function WL(e,t){const r=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),n=e.match(r);return n?n[1].trim():null}function GL(e){let t=0;const r=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&WL(i[1],"fill")&&!/^none$/i.test(WL(i[1],"fill"));(o||a)&&(t+=1)}return t}function qL(e){let t=0;const r=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&WL(i[1],"stroke")&&!/^none$/i.test(WL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function YL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function XL(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),r=parseFloat(t);return Number.isNaN(r)||r<=0||r>10?null:Math.round(10*r)/10}function KL(e){const t=[],r=e.indexOf("</defs>"),n=r>=0?e.slice(r):e,i=new RegExp(`<(?:${HL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(n));){const e=XL(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${HL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(n));){const e=XL(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function ZL(e){const t=function(e){const t=[],r=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))});const n=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let i;for(;null!==(i=n.exec(e));){const e=i[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(n&&n[1]){const e=$L(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=$L(o[1]);e&&!r.has(e)&&(r.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=WL(a[1],"fill");if(e){const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))}const n=WL(a[1],"stroke");if(n){const e=$L(n);e&&!r.has(e)&&(r.add(e),t.push(n))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[n,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const n=e.match(i);if(n&&n[1]){const e=$L(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}}const n=e.match(/style\s*=\s*["']([^"']*)["']/i);if(n&&n[1])for(const e of["fill","stroke"]){const i=WL(n[1],e);if(i){const e=$L(i);e&&!r.has(e)&&(r.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:GL(e),strokesCount:qL(e),hasGradient:YL(e),strokeWidth:KL(e)}}const JL=new Map,QL="https://public-api.streamlinehq.com/v1";function eN(e,t,r,n){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>r?Promise.resolve(r(e)):e,s=null==n?void 0:n.trim(),l=i.useCallback(async e=>r?a(function(e){const{mode:t,q:r,offset:n,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",r),s.set("offset",String(n)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${QL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:r,q:n,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===r?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===r&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",n),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,r]),c=i.useCallback(async e=>{var t;const r=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),n={Accept:"application/json"};s&&(n["x-api-key"]=s);const i=await fetch(r,{method:"GET",headers:n,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let r=e;const n=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(r)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(r);if(!(/fill="url\(#/i.test(r)||/stroke="url\(#/i.test(r))){const e=function(e){var t,r,n,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=$L(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const f=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(r),t=t=>{const r=$L(t),n=r?e.get(r):void 0;return 1===n?"var(--icon-color-1)":2===n?"var(--icon-color-2)":3===n?"var(--icon-color-3)":"currentColor"};r=r.replace(/<svg([^>]*)>/i,(e,r)=>{let n=r;const i=r.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(n=n.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=r.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(n=n.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${n}>`}),r=r.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,r,n,i)=>{var o,a,s,l,c,u,d,h;let f=n;const p=n.match(/fill\s*=\s*["']([^"']*)["']/i),g=n.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=n.match(/stroke\s*=\s*["']([^"']*)["']/i),b=n.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${r}${f}${i}`})}return n&&(r=r.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,r)=>{let n=0;return`<linearGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</linearGradient>`}),r=r.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,r)=>{let n=0;return`<radialGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(r)&&(r=r.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(r)&&(r=r.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(r)||(r=r.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),r=r.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),r},[]),d=i.useCallback(async(t,n)=>{const i=[t,e?"css=1":"css=0",(null==n?void 0:n.colors)?`c=${n.colors}`:"",(null==n?void 0:n.backgroundColor)?`bg=${n.backgroundColor}`:"",null!=(null==n?void 0:n.strokeWidth)?`sw=${n.strokeWidth}`:"",null!=(null==n?void 0:n.size)?`s=${n.size}`:"",null!=(null==n?void 0:n.responsive)?`r=${n.responsive}`:"",null!=(null==n?void 0:n.strokeToFill)?`sf=${n.strokeToFill}`:""].filter(Boolean).join("|"),l=JL.get(i);if(l)return l;const c=await(async(e,t)=>{var n,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${QL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(r)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,n),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==n?void 0:n.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==n?void 0:n.colors)&&(f=u(f,{strokeWidth:null==n?void 0:n.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return JL.set(i,g),g},[o,u,e,r,a,s]),h=i.useCallback(async(e,t)=>{const n=await(async(e,t)=>{var n;const i=new URLSearchParams;i.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${QL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(r)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(n,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(new Error("Failed to read PNG blob")),r.readAsDataURL(c)})},[o,r,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const tN=({items:e,selectedHashes:t,getPngDataUrlForItem:r,dataUrlToBlob:n,clearSelection:o})=>{const{t:a}=Yn(),{options:s,state:l}=po(),c=Oo(),[u,d]=i.useState(!1),[h]=E.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=Wo(),{EmptyFolderIcon:w}=mo(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=ol({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),k=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),A=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,r,n;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(r=null==o?void 0:o.error)||void 0===r?void 0:r.message)||(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:r,items:n,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s,config:l}=e;let c=0,u=0;for(const e of r){const r=n.find(t=>t.hash===e);if(!r){u+=1;continue}const d=await a(r);if(!d){u+=1;continue}const h=Dr(`${(null===(t=r.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,l),f=await hi(o,h,i,!1,Br(l)),p=s(d,"image/png"),g=new File([p],f,{type:"image/png",lastModified:Date.now()});try{await o.uploadFile({name:f,size:g.size,type:g.type,folderId:i,data:g,extension:"png"}),c+=1}catch(e){u+=1}}return{successCount:c,failCount:u}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p,getFiles:d.getFiles,getFolders:d.getFolders},getPngDataUrlForItem:r,dataUrlToBlob:n,config:null==s?void 0:s.config});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,n,r,e,c,s,t,null==l?void 0:l.selectedFolder,a]),I=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),F=i.useCallback(()=>{C(""),p(!1)},[C]),T=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await A(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[A,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:I,resetAfterClose:F,handleCopyTreeSelect:k,handleIconsCopyOk:T,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}};async function rN(e,t,r){if(0===e.length)return[];const n=new Array(e.length);let i=0;const o=Math.max(1,Math.min(t,e.length));return await Promise.all(Array.from({length:o},()=>(async()=>{for(;;){const t=i++;if(t>=e.length)return;n[t]=await r(e[t])}})())),n}const nN=({apiKey:n,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Yn(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,k]=i.useState(""),[A,I]=i.useState("global"),[O,P]=i.useState(null),[L,N]=i.useState(null),[j,D]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[H,$]=i.useState(0),[W,q]=i.useState(!1),[Y,K]=i.useState(!1),[Z,J]=i.useState(!1),[Q,ee]=i.useState(null),[te,re]=i.useState({}),[ne,oe]=i.useState({}),[ae,se]=i.useState({}),[le,ce]=i.useState("#000000"),[ue,de]=i.useState("#ff007a"),[he,fe]=i.useState("#00C2FF"),[pe,ge]=i.useState(1),[me,ve]=i.useState(50),[ye,be]=i.useState(!0),[we,xe]=i.useState(!0),[Ce,_e]=i.useState(!1),Se=i.useRef(A);i.useEffect(()=>{Se.current=A},[A]);const ke=po(),{options:Ae}=ke,Ie=i.useRef(!1),Ee=i.useRef(null),Fe=i.useRef(0),Te=i.useRef(null),Oe=i.useRef(!1),Pe=i.useRef(null),Me=i.useRef(null===(c=null==Ae?void 0:Ae.config)||void 0===c?void 0:c.handleTranslate),Re=i.useRef(null===(u=null==Ae?void 0:Ae.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Me.current=null===(e=null==Ae?void 0:Ae.config)||void 0===e?void 0:e.handleTranslate,Re.current=null===(t=null==Ae?void 0:Ae.config)||void 0===t?void 0:t.locale},[null===(d=null==Ae?void 0:Ae.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==Ae?void 0:Ae.config)||void 0===h?void 0:h.locale]);const Le=i.useRef(null),Ne=i.useRef(null),je=i.useRef(new Set),De=i.useRef(null),ze=i.useRef(new Set),[Be,Ue]=i.useState(new Set),Ve=null!==(p=null===(f=null==Ae?void 0:Ae.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",He=null===(g=null==Ae?void 0:Ae.config)||void 0===g?void 0:g.handleProxyUrl,$e=async e=>He?Promise.resolve(He(e)):e,{performSearch:We,fetchSvgDataUrl:Ge,fetchPngDataUrl:qe,normalizeSvgForCss:Ye}=eN(we,null===(m=null==Ae?void 0:Ae.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,He,Ve),Xe=i.useMemo(()=>{if("family"!==A||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(ae).some(t=>e.has(t))?ae:ne,r=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===r.length)return null;return function(e){const t=[],r=new Set;let n,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const n=$L(e);n&&!r.has(n)&&(r.add(n),t.push(e))}null==n&&null!=s.strokeWidth&&(n=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:n}}(r.map(e=>ZL(e)))},[U,A,ae,ne]);i.useMemo(()=>"family"===A&&(!!(null==Xe?void 0:Xe.hasGradient)||!!(O||"").toLowerCase().includes("gradient")),[Xe,O,A]);const Ke=i.useMemo(()=>"family"===A&&U.some(e=>{const t=ne[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,A,ne]),Ze=i.useMemo(()=>"family"===A&&U.some(e=>{const t=ne[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,A,ne]),Je=i.useMemo(()=>!!we&&(!!Xe&&(Xe.hasGradient||Xe.colors.length>=2&&Ke)),[Xe,we,Ke]),Qe=i.useMemo(()=>!!we&&(!!Xe&&(Xe.colors.length>=3&&Ze)),[Xe,we,Ze]);i.useEffect(()=>(Ie.current=!0,()=>{var e,t,r;Ie.current=!1;try{null===(e=Le.current)||void 0===e||e.abort(),null===(t=Ne.current)||void 0===t||t.abort(),null===(r=De.current)||void 0===r||r.abort()}catch(e){}}),[]);const et=i.useRef(x),tt=i.useCallback(async e=>{var t,r,n,i,o,a,s,l;const c=null!==(r=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==r?r:_;if(!c||0===c.trim().length)return;if(e.initial?Y:Z||Y)return;if(!Ie.current)return;e.initial&&(null===(n=Le.current)||void 0===n||n.abort());const u=new AbortController;Le.current=u,e.initial?(K(!0),V([]),$(0),q(!1)):J(!0);const d=e.initial?0:H,h=(e.initial,30),f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:A,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:O,g=c.trim(),m=`${f}|${p||""}|${g}|${j||""}|${d}|${h}`;if(!ze.current.has(m)){ze.current.add(m);try{const t=await We({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:j,signal:u.signal});if(!Ie.current)return;const r=await(async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await $e(e.imagePreviewUrl)}))))(t.results);if(e.initial){const e=r.filter((e,t,r)=>r.findIndex(t=>t.hash===e.hash)===t);V(e)}else V(e=>{const t=new Set(e.map(e=>e.hash)),n=r.filter(e=>!t.has(e.hash));return n.length>0?[...e,...n]:e});q(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),$(d+r.length)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),ie.error(y("Request error"))}finally{Ie.current&&(e.initial?K(!1):J(!1)),ze.current.delete(m)}}},[_,O,Z,Y,A,H,We,j,y]);i.useEffect(()=>{Pe.current=tt},[tt]),i.useEffect(()=>{if("family"===A){const e=window.setTimeout(()=>{Oe.current=!1},100);return()=>window.clearTimeout(e)}Oe.current=!1},[A]);const rt=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const r=`${e.trim()}|${j||""}`;if(Te.current===r&&"global"===Se.current)return;const n=++Fe.current;let i=e.trim();if(Me.current)try{i=await Me.current(e,{locale:Re.current})}catch(t){console.error("IconsTab: translation error",t),i=e}n===Fe.current&&(je.current.clear(),I("global"),P(null),B(null),V([]),q(!1),$(0),ee(null),Ue(new Set),k(i),await(null===(t=Pe.current)||void 0===t?void 0:t.call(Pe,{initial:!0,override:{query:i}})),Te.current=r)},[j]),nt=i.useCallback(async()=>{x&&0!==x.trim().length&&(Ee.current&&(window.clearTimeout(Ee.current),Ee.current=null),await rt(x))},[x,rt]),it=i.useCallback(()=>{Fe.current+=1,je.current.clear(),I("global"),P(null),N(null),B(null),D(null),k(""),V([]),J(!1),q(!1),$(0),Te.current=null,ee(null),Ue(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF")},[]);i.useEffect(()=>{const e=et.current;e&&e.trim().length>=3&&rt(e)},[]),i.useEffect(()=>{const e=x.trim();Ee.current&&(window.clearTimeout(Ee.current),Ee.current=null),e.length<3?it():Ee.current=window.setTimeout(()=>{rt(e)},700)},[x,j,it,rt]);const ot=i.useCallback(e=>{if("global"===A){if(!e.familySlug||!_)return;return Ee.current&&(window.clearTimeout(Ee.current),Ee.current=null),je.current.clear(),Oe.current=!0,I("family"),P(e.familySlug),N(e.hash),B(e.categoryName||null),V([]),J(!1),q(!1),$(0),ee(null),Ue(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF"),void tt({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}ee(e.hash)},[_,tt,A]),at=i.useCallback(()=>{const e=_.trim();je.current.clear(),I("global"),P(null),N(null),B(null),V([]),J(!1),q(!1),$(0),ee(null),Ue(new Set),ce("#000000"),de("#ff007a"),fe("#00C2FF"),e&&tt({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,tt]);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=new Set(U.map(e=>e.hash));let r=U.map(e=>e.hash).filter(e=>!te[e]||!ne[e]);if(!L||t.has(L)||ae[L]||(r=[L,...r]),r=r.filter(e=>!je.current.has(e)),0===r.length)return;let n=!1;null===(e=Ne.current)||void 0===e||e.abort();const i=new AbortController;return Ne.current=i,rN(r,4,e=>Ge(e,{colors:we?void 0:le,strokeWidth:pe,size:me,responsive:ye,signal:i.signal}).then(t=>({h:e,r:t})).catch(t=>("AbortError"===(null==t?void 0:t.name)||je.current.add(e),{h:e,r:null}))).then(e=>{if(n||!Ie.current)return;const t={},r={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,r[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&re(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&oe(e=>Object.assign(Object.assign({},e),r)),Object.keys(i).length>0&&se(e=>Object.assign(Object.assign({},e),i))}),()=>{n=!0,i.abort()}},[le,L,Ge,U,A,ae,ye,me,pe,ne,te,we]),i.useEffect(()=>{if("family"!==A)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},r={};let n=!1;e.forEach(e=>{const i=ae[e]||ne[e];if(!i)return;const o=Ye(i,{strokeWidth:"number"==typeof pe?pe:void 0});o&&o!==ne[e]&&(t[e]=o,r[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,n=!0)}),n&&(Object.keys(t).length>0&&oe(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&re(e=>Object.assign(Object.assign({},e),r)))},[U,A,Ye,ae,pe,ne]);const st=i.useRef(null);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=L&&ae[L]?L:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!ae[t])return;if(st.current===O)return;const r=ae[t];if(!r)return;st.current=O;const n=function(e){var t,r,n,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=$L(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const p=new RegExp(`<(?:${HL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(r),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const r=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r)){const e=r.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const n=r.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(n)return"#"+[1,2,3].map(e=>parseInt(n[e],10).toString(16).padStart(2,"0")).join("");const i=r.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[r.toLowerCase()])&&void 0!==t?t:$L(r)||"#000000"}(e)};n[0]&&ce(i(n[0])),n[1]&&de(i(n[1])),n[2]&&fe(i(n[2]))},[U,A,ae,O,L]),i.useEffect(()=>{"family"!==A&&(st.current=null)},[A]);const lt=i.useRef(null);i.useEffect(()=>{if("family"!==A||!O||0===U.length)return;const e=U[0];if(!e||!ae[e.hash])return;if(lt.current===O)return;const t=ae[e.hash];if(!t)return;const r=ZL(t);"number"==typeof r.strokeWidth&&r.strokeWidth>0&&(lt.current=O,ge(r.strokeWidth))},[U,A,ae,O]),i.useEffect(()=>{"family"!==A&&(lt.current=null)},[A]);const ct=i.useCallback(e=>function(e,t){const{colorHex:r,colorHex2:n,colorHex3:i}=t,o=[`--icon-grad-1: ${r}`,`--icon-grad-2: ${n}`,`--icon-stroke-1: ${r}`,`--icon-stroke-2: ${n}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${r}`,`--icon-fill-2: ${n}`,`--icon-fill-3: ${i}`,`color: ${r}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):r+=` style="${o}"`,`<svg${r}>`});return a=a.replace(/var\(--icon-color-1\)/g,r).replace(/var\(--icon-color-2\)/g,n).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,r).replace(/var\(--icon-fill-2\)/g,n).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,r).replace(/var\(--icon-stroke-2\)/g,n).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,r).replace(/var\(--icon-grad-2\)/g,n).replace(/currentColor/g,r),a}(e,{colorHex:le,colorHex2:ue,colorHex3:he}),[le,ue,he]),ut=i.useCallback(e=>{Ue(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),dt=i.useCallback(()=>{Ue(new Set)},[]),ht=i.useMemo(()=>{if(1===Be.size){const[e]=Array.from(Be);return U.find(t=>t.hash===e)||null}return 0===Be.size&&Q&&U.find(e=>e.hash===Q)||null},[U,Q,Be]),ft=i.useCallback((e,t="image/png")=>{try{const r=e.split(",");if(r.length<2)return new Blob([],{type:t});const n=r[1]||"",i=atob(n),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),pt=i.useCallback(async(e,t)=>{try{const r=async e=>{const t="family"===A?ct(e):e,r=function(e,t){const r=e.match(/\swidth="([0-9.]+)(px)?"/i),n=e.match(/\sheight="([0-9.]+)(px)?"/i);if(r&&n){const e=parseFloat(r[1]),i=parseFloat(n[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const r=e/i;return r>=1?{width:t,height:Math.max(1,Math.round(t/r))}:{width:Math.max(1,Math.round(t*r)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const r=parseFloat(e[2]),n=parseFloat(e[3]);if(Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0){const e=r/n;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,me);return async function(e,t,r){const n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);try{const e=new Image;return await new Promise((n,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*r));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),n(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,r.width,r.height)},n=async e=>{const n=await Ge(e,{colors:we?void 0:le,strokeWidth:"number"==typeof pe?pe:void 0,size:me,responsive:ye,signal:t}),i=n.original||n.text;return r(i)};if("family"!==A)try{return await qe(e.hash,{size:me,colors:we?void 0:le,strokeWidth:"number"==typeof pe?pe:void 0,signal:t})}catch(t){return e.hash?await n(e.hash):null}const i=ne[e.hash]||ae[e.hash];return i?r(i):e.hash?await n(e.hash):null}catch(e){return null}},[ct,le,Ge,qe,A,ae,ye,me,pe,ne,we]),gt=i.useCallback(async e=>{var t;try{if(!Ie.current)return;_e(!0),null===(t=De.current)||void 0===t||t.abort();const r=new AbortController;De.current=r;const n=await pt(e,r.signal);if(!Ie.current||!n)return;await Promise.resolve(o(n))}catch(e){console.error("IconsTab: insert error",e),ie.error(y("Request error"))}finally{Ie.current&&_e(!1)}},[o,pt,y]);i.useCallback(()=>{var e;ee(null),dt();const t=null===(e=null==Ae?void 0:Ae.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[dt,Ae]);const{isCopyIconsModalVisible:mt,isCopyLoading:vt,copyForm:yt,openCopyModal:bt,closeCopyModal:wt,resetAfterClose:xt,handleCopyTreeSelect:Ct,handleIconsCopyOk:_t,fetchChildFolders:St,generateMenuItemsFromFolders:kt,handleCreateFolderAndCopy:At}=tN({items:U,selectedHashes:Be,getPngDataUrlForItem:pt,dataUrlToBlob:ft,clearSelection:dt}),It=Boolean(_.trim())&&(U.length>0||Y),Et=It&&Be.size>0;return t(r,{children:[t("div",{className:`${jL.iconsTab} ${_.trim()?jL.hasSearch:""}`,children:[It&&Et?t("div",{className:jL.iconsHeaderContainer,children:[t("div",{className:jL.iconsHeaderContainerLeft,children:[t(T.Text,{type:"secondary",children:[Be.size," ",y("selected")]}),e(M,{icon:e(Fi,{size:16}),onClick:dt,children:y("Deselected")})]}),e(R,{children:e(M,{icon:e(gi,{size:16}),onClick:bt,children:y("Copy to folder")})})]}):e(zL,{query:x,onQueryChange:C,onSubmit:nt,styleFilter:j,onStyleChange:D,hasResults:U.length>0||Y,inputRef:l}),"family"===A?e(BL,{mode:A,familySlug:O,categoryName:z,colorHex:le,setColorHex:ce,colorHex2:ue,setColorHex2:de,colorHex3:he,setColorHex3:fe,sizePx:me,setSizePx:ve,strokeWidth:pe,setStrokeWidth:ge,responsiveSvg:ye,setResponsiveSvg:be,useCssColor:we,setUseCssColor:xe,showSecondColor:Je,showThirdColor:Qe,styleFilter:j,onBack:at}):null,e(VL,{items:U,loading:Y,isCollectingResults:Z,hasMore:W,hasQuery:Boolean(_.trim()),mode:A,selectedHash:Q,onItemClick:ot,onInsert:gt,onLoadMore:()=>{tt({initial:!1})},colorVars:{colorHex:le,colorHex2:ue,colorHex3:he},svgTextMap:ne,previewSize:me,selectedHashes:Be,onToggleSelect:ut}),ht?t("div",{className:jL.iconsBottomBar,children:[e(X,{className:"zero-divider"}),e("div",{className:jL.iconsBottomBarContent,children:e(R,{children:e(M,{size:"large",type:"primary",style:{height:40},loading:Ce,onClick:()=>gt(ht),children:y("Choose")})})})]}):null]}),e(G,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:mt,onCancel:()=>{vt||wt()},maskClosable:!vt,closable:!vt,keyboard:!vt,footer:t("div",{className:nl.formFooter,children:[t(M,{className:nl.folderButton,onClick:At,loading:vt,children:[e(wi,{size:18,strokeWidth:null===(v=Ae.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(M,{type:"primary",className:nl.folderButton,onClick:()=>{wt()},loading:vt,children:y("Done")})]}),afterClose:()=>xt(),children:t("div",{className:jL.copyToFolderModalBody,children:[vt?e("div",{className:jL.copyToFolderModalLoadingOverlay,children:e(S,{size:"large"})}):null,e(E,{form:yt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:nl.foldersWrapper,children:[e(E.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:nl.formItem,children:e(tl,{onSelect:Ct,generateMenuItems:()=>kt({targetForm:yt,onTreeSelect:Ct,onComplete:_t,actionButtonText:y("Copy here")}),fetchChildFolders:St,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(E.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(E.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},iN=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const r=document.createElement("style");if(r.type="text/css",r.dataset.themeVariablesFm="true",r.setAttribute("data-file-manager","true"),Object.entries(e).length){let n="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(n+=`\t--${e}: ${t};\n`)}),n=`.em-filemanager {\n${n}}`,r.appendChild(document.createTextNode(n));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(r,i):t.insertBefore(r,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:oN,Content:aN}=J,sN={keywords:""},lN=()=>{var s,l,d;const h=Wo(),f=ss(),p=(()=>{var e,t;const{state:r,actions:n,options:i}=po(),{selectedFolder:o,pathHistory:a,folders:s}=r,{t:l}=Yn(),{setSelectedFolder:u,setPathHistory:d}=n,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const r=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!r)return[];const n=new Set(t);return n.add(e),r.parentId?r.parentId===r.id?(console.warn(`Cycle detected: folder ${r.id} is a parent of itself`),[{id:r.id,name:r.name+" (ошибка)"}]):[...f(r.parentId,n),{id:r.id,name:r.name}]:[{id:r.id,name:r.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const r=!0===(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),n=h();try{if(!r)return void localStorage.removeItem(n);e?localStorage.setItem(n,e):localStorage.removeItem(n)}catch(e){}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}const t=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!t)return void console.warn("⚠️ Folder not found:",e);const r=f(e),n=[{id:"folders",name:l("Folders")},...r];null==d||d(n),i.onPathChange&&i.onPathChange(n.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),r=t[t.length-1],n="folders"===r.id?void 0:r.id;null==u||u(n||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),g=(()=>{const{state:e,actions:t}=po(),{pagination:r}=e,{setPagination:n}=t,i=c((e,t)=>{const i=t||r.pageSize;null==n||n({current:e,pageSize:i,total:r.total})},[r.pageSize,r.total,n]);return{state:{pagination:r},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=n.useState(()=>{const e=localStorage.getItem(ls);return e?Math.max(290,parseInt(e,10)):298}),[r,i]=n.useState(!1),[o,a]=n.useState(!1),[s,l]=n.useState(0),c=n.useCallback(()=>{t(298),localStorage.setItem(ls,298..toString())},[]),u=n.useCallback(r=>{r.preventDefault(),r.stopPropagation(),i(!0),document.body.classList.add("resizing");const n=r.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const r=Math.max(Math.min(o+e.clientX-n,600),290);s=r,t(r),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(ls,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return n.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:r,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[r,n]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>ui(e.size),[]),f=c((e,r)=>{const i=r.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),n(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,r)=>{const i={id:d(),folderId:e,name:r,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),n(!0),a(!1),i.id},[d]),g=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,r))}):t))},[]),m=c((e,r)=>{r&&l.current.set(e,r),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==r?void 0:r.name)&&(e.name=r.name),(null==r?void 0:r.size)&&void 0===t.size&&(e.size=ui(r.size)),e}return t}))},[]),v=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:r}):t))},[]),y=c(()=>{n(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:r,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=Ga(),{deleteItems:b}=Go(),w=Oo(),{t:C}=Yn(),{options:_,state:k,actions:A}=po(),I=_,E=null==I?void 0:I.onChangeSelection,F=k,T=null==I?void 0:I.config,{dataProviders:O}=I,{form:P,urlForm:R,renameForm:L,moveForm:N,renameFolderForm:j,copyForm:D,isModalVisible:z,isUrlModalVisible:B,isMoveModalVisible:U,isRenameFolderModalVisible:V,isCopyModalVisible:H,isDeleteConfirmVisible:$,folderToRename:W,activeLibraryItem:G}=k,{setIsUrlModalVisible:q,setActiveLibraryItem:Y}=A,{config:K}=_,{DropZoneFileIcon:Z}=mo(),[Q,ee]=o(!1),[te,re]=o(!1),[ne,ie]=o(!1),oe=u(0),ae=u(!1);ae.current=te;const se=i.useRef(null),le=i.useRef([]),[ce,ue]=o(!1),[de,he]=o(!1),fe=Za(e=>e.selectedFiles),pe=Za(e=>e.clearSelection),ge=Za(e=>e.syncVisibleFiles),{folders:me,loading:ve}=h.state,{fetchFolders:ye,fetchChildFolders:be,handleCreateFolder:we,handleModalOk:xe,handleModalCancel:Ce,generateMenuItems:_e}=h.actions,Se=(e=>{var t;const{state:r,actions:n,options:i}=po(),{t:o}=Yn(),a=Oo(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=r,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=n,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,r;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error(o("renameFolder is not implemented in dataProviders"));const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(r=s.parentId)&&void 0!==r?r:null}}),y(),await e(),l!==s.id&&n.setSelectedFolder&&n.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),error:{message:e instanceof Error?e.message:String(e)}}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(ye),{files:ke,loading:Ae,isRenamingFile:Ie,fileToRename:Ee}=f.state,{fetchFiles:Te,handleDeleteFile:Oe,handleDeleteFolder:Pe,handleAddFile:Me,handleAddFileByUrl:Re,showRenameModal:Le,handleRenameCancel:Ne,handleRenameOk:je,handleDroppedFiles:De,showMoveModal:ze,handleMoveCancel:Be,handleMoveOk:Ue,handleCopyOk:Ve,handleCopyCancel:He,showDeleteConfirm:$e,handleDeleteConfirmCancel:We,handleDeleteConfirmOk:Ge}=f.actions,{selectedFolder:qe,pathHistory:Ye}=p.state,{handleFolderSelect:Xe,handleItemClick:Ke}=p.actions,{pagination:Ze}=g.state,Je=Eo(Te),{searchTerm:Qe,sortBy:et,sortOrder:tt}=Je.state,{handleSearch:rt,handleSort:nt,handlePaginationChange:it}=Je.actions,ot=c(async()=>{const e=(e=>Uo(e))(Ye||[]);try{await $o({options:I,pathFolder:e,dataProviders:null==I?void 0:I.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await ye(),await Te({folderId:qe||"",page:Ze.current,limit:Ze.pageSize,search:Qe,sortBy:et,sortOrder:tt,itemType:"all"})},[Te,ye,I,Ze,Ye,Qe,qe,et,tt]),at=(({files:e,fetchFiles:t,selectedFolder:r})=>{var i;const{t:o}=Yn(),a=Oo(),{options:s,actions:l,state:c}=n.useContext(fo),{setActiveLibraryItem:u}=l,{activeLibraryItem:d}=c,h=Ga(),[f,p]=n.useState(!1),[g,m]=n.useState(null),v=n.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return gr.includes(t)}const r=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!r&&gr.includes(r)},[]),y=n.useCallback(async(e,t)=>{var r,n;const{dataProviders:i}=s;if(!1===(null===(n=null===(r=s.config)||void 0===r?void 0:r.features)||void 0===n?void 0:n.enableUpdateFile))throw new qo(o("Updating files is disabled by configuration"),"UnsupportedOperation");if(!e.id||!e.thumbnail||!(null==i?void 0:i.updateFile))throw new qo(o("Failed to save changes"),"UnsupportedOperation");const a=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),l=Fr(a),c=e.name.lastIndexOf("."),u=`${c>0?e.name.substring(0,c):e.name}.${l}`,d=(null==t?void 0:t.blob)||Mr(e.thumbnail,a);return i.updateFile(e.id,{name:u,type:a,data:d})},[s,o]),b=n.useCallback(async(e,t)=>{var r,n,i;if(!e.thumbnail)throw new qo(o("Failed to save changes"),"ValidationError");const a=!(!0===(null===(r=s.config)||void 0===r?void 0:r.saveCopyToCurrentFolder))||(null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id),l=a?void 0:null!==(i=e.folderId)&&void 0!==i?i:void 0,c=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),u=(null==t?void 0:t.blob)||Mr(e.thumbnail,c),d=new File([u],e.name,{type:c,lastModified:Date.now()}),f=await h.uploadFileWithProvider(d,l,void 0,a);if(!f)throw new qo(o("Failed to save image copy"),"FileWriteError");return f},[h,null===(i=s.config)||void 0===i?void 0:i.saveCopyToCurrentFolder,o]),w=n.useCallback(t=>{let r;if(t)r=t;else{const t=Za.getState().selectedFiles;if(1!==t.size)return;const n=Array.from(t)[0];if(r=e.find(e=>e.id===n),!r||r.isFolder||!v(r))return}u&&u(sr),m(r),p(!0)},[e,v,p,u]),x=n.useCallback(()=>{u&&d===sr&&u(rr),p(!1),m(null)},[d,u]),C=n.useCallback(async(e,n)=>{var i,l,c,u,d,h;try{const c=await y(e,n);return a.success({id:"IMAGE_UPDATE_SUCCESS",message:o("Success"),description:o("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(i=null==c?void 0:c.id)&&void 0!==i?i:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&s.onEditorOk&&s.onEditorOk(c,{mode:n.mode}),await t({folderId:r||""}),x(),null!=c?c:void 0}catch(t){const r=No(t),n=null!==(u=null!==(c=Ro(null==r?void 0:r.code,o))&&void 0!==c?c:null==r?void 0:r.message)&&void 0!==u?u:o("Failed to save changes");throw a.error({id:"IMAGE_SAVE_FAILED",message:n,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[y,s,t,r,a,x,o]),_=n.useCallback(async(e,n)=>{var i,l,c,u,d,h;try{const c=await b(e,n);return a.success({id:"IMAGE_SAVE_COPY_SUCCESS",message:o("Success"),description:o("Image copy saved successfully"),placement:"bottomRight",data:{itemId:null!==(i=null==c?void 0:c.id)&&void 0!==i?i:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&s.onEditorOk&&s.onEditorOk(c,{mode:n.mode}),await t({folderId:r||""}),x(),null!=c?c:void 0}catch(t){const r=No(t),n=null!==(u=null!==(c=Ro(null==r?void 0:r.code,o))&&void 0!==c?c:null==r?void 0:r.message)&&void 0!==u?u:o("Failed to save image copy");throw a.error({id:"IMAGE_SAVE_COPY_FAILED",message:n,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[b,s,t,r,a,x,o]);return{isPixieEditorVisible:f,editingFile:g,handleEdit:w,handlePixieEditorSave:C,handlePixieEditorSaveCopy:_,handlePixieEditorClose:x}})({files:ke||[],fetchFiles:Te,selectedFolder:qe||null}),[st,lt]=o(!1),ct=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,r=e.currentTarget;t&&r.contains(t)||(oe.current+=1,oe.current>0&&ee(!0))},[]),ut=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,r=e.currentTarget;if(t&&!r.contains(t))oe.current=Math.max(0,oe.current-1),oe.current<=0&&ee(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&r.contains(e))return}},[]),dt=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),ht=c(e=>{e.preventDefault(),e.stopPropagation(),ee(!1),oe.current=0;const t=(()=>{var t;const r=e.dataTransfer;if(!r)return[];if(null===(t=r.files)||void 0===t?void 0:t.length)return Array.from(r.files);const n=[];if(r.items)for(let e=0;e<r.items.length;e++){const t=r.items[e].getAsFile();t&&n.push(t)}return n})();t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{lt(!1)}))},[De]),ft=c(()=>{ee(!1),oe.current=0,document.body.removeAttribute("data-fm-dragging"),ie(!1),re(!1)},[]);i.useEffect(()=>{le.current=ke||[]},[ke]);const pt=null==F?void 0:F.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=!1;const r=r=>{var n,i;!t&&(null===(i=null===(n=r.dataTransfer)||void 0===n?void 0:n.types)||void 0===i?void 0:i.includes("Files"))&&(t=!0,ie(!0),e(!0),pt===rr&&re(!0))},n=r=>{const n=r.relatedTarget;(!n||!document.documentElement.contains(n))&&t&&(t=!1,ie(!1),re(!1),e(!1))};return window.addEventListener("dragenter",r,!0),window.addEventListener("dragleave",n,!0),()=>{window.removeEventListener("dragenter",r,!0),window.removeEventListener("dragleave",n,!0),document.body.removeAttribute("data-fm-dragging")}},[pt]),a(()=>{const e=e=>{var t,r;if(document.body.removeAttribute("data-fm-dragging"),ie(!1),!(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files")))return;e.preventDefault();const n=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const r=[];if(e.items)for(let t=0;t<e.items.length;t++){const n=e.items[t].getAsFile();n&&r.push(n)}return r})(e.dataTransfer);if(!n.length)return;const i=e.target,o=i.closest(`.${xs.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(ae.current||Q||o||a)&&(e.preventDefault(),e.stopPropagation(),re(!1),ee(!1),oe.current=0,lt(!0),De(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>lt(!1)))},t=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||(document.body.setAttribute("data-fm-dragging","true"),ie(!0)),pt!==rr||ae.current||re(!0))},r=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"),ie(!0))},n={capture:!0,passive:!1};return window.addEventListener("drop",e,n),window.addEventListener("dragover",t,n),window.addEventListener("dragenter",r,n),()=>{window.removeEventListener("drop",e,n),window.removeEventListener("dragover",t,n),window.removeEventListener("dragenter",r,n)}},[Q,De,pt]),a(()=>{const e=e=>{Q&&ft(),re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[Q,ft]),a(()=>{let e=null;const t=t=>{Q&&(e=setTimeout(()=>{Q&&ft()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[Q,ft]),a(()=>{const e=e=>{"Escape"===e.key&&Q&&ft()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Q,ft]),a(()=>{const e=e=>{Q&&setTimeout(()=>{Q&&ft()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[Q,ft]);const gt=i.useCallback(async()=>{await Ge(),await ye(),qe===lr&&be&&await be(lr),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[ye,be,Ge,qe]),mt=i.useCallback(()=>{he(!0)},[]),vt=i.useCallback(async()=>{var e,t;if(qe!==lr)return console.error("Clear trash called outside of trash folder"),void he(!1);try{if(null==O?void 0:O.cleanTrash){const t=await O.cleanTrash();await Te({folderId:lr}),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}else{const e=le.current||[];if(0===e.length)return void he(!1);const r=e.map(e=>({id:e.id,isFolder:e.isFolder})),n=await b({items:r,selectedFolder:lr,getItemNameById:t=>{var r;return(null===(r=e.find(e=>e.id===t))||void 0===r?void 0:r.name)||t||""},showNotifications:!1});await Te({folderId:lr}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=n;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:C("Trash partially cleared"),description:C("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}he(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:C("Error clearing trash"),placement:"bottomRight"}),he(!1)}},[qe,O,Te,w,C,b]),yt=i.useCallback(()=>{he(!1)},[]),bt=i.useCallback(async e=>{var t;await Ue(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ue]),wt=i.useCallback(async e=>{var t;await Ve(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ve]),xt=i.useCallback(async()=>{let e=[],t=new Map;const r=null==I?void 0:I.config;await Me({onStartBatch:n=>{e=v.startUpload(qe||void 0,n),t=new Map,n.forEach((n,i)=>{const o=e[i];o&&(t.set(n.name,o),t.set(Dr(n.name,r),o))})},onStart:n=>{if(0===e.length){e=v.startUpload(qe||void 0,[n]);const i=e[0];i&&(t.set(n.name,i),t.set(Dr(n.name,r),i))}},onProgress:(e,r)=>{const n=t.get(e);n&&v.updateProgress(n,r)},onComplete:async e=>{var r;const n=t.get(e);if(n){await new Promise(e=>setTimeout(e,100));const t=null==ke?void 0:ke.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(n,t)}await(null===(r=se.current)||void 0===r?void 0:r.refreshFileCounts())},onError:(r,n,i)=>{var o;const a=null!==(o=t.get(r))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,n)},onBatchComplete:async r=>{var n,i,o,a,s,l,c,u;for(let u=0;u<r.successes.length;u++){const d=r.successes[u],h=null===(n=r.uploadedFiles)||void 0===n?void 0:n.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:qe)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ke?void 0:ke.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}r.errors.forEach(({fileName:e,error:r})=>{const n=t.get(e);n&&v.markAsError(n,r)}),await(null===(u=se.current)||void 0===u?void 0:u.refreshFileCounts())}})},[Me,v,ke,qe,null==I?void 0:I.config]),Ct=i.useCallback(async(e,t,r,n)=>{var i,o;try{ue(!0);let a=r||"uploaded-file";if(!r&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(qe||void 0,a);try{const r=await Re(e,t,!0,null!=n?n:"uploadByUrl");if(v.updateProgress(s,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=se.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=No(e),r=Bo(t,C);v.markAsError(s,r)}}finally{ue(!1)}},[Re,v,qe,ke,C]),_t=i.useCallback(async({file:e})=>{var t;const r=v.startUpload(qe||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);const o=n&&n.folderId||qe||null;return Xe&&Xe(o&&"folders"!==o?o:"folders"),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts()),n}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[y,v,qe,ke,Xe]),St=i.useCallback(async e=>{var t;if(De){const r=v.startUpload(qe||void 0,e);e.forEach(async(e,t)=>{const n=r[t];if(!n)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(n,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await De(e),r.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}},[De,v,qe]),kt=i.useCallback(async e=>{var t;await Pe(e),await ye(),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Pe,ye]),At=(({files:e,clearSelection:t,showRenameModal:r,showMoveModal:i,showCopyModal:o,handleDeleteFile:a,handleDeleteFolder:s,showDeleteConfirm:l,onEdit:c})=>{const u=n.useCallback(()=>{t()},[t]),d=n.useCallback(e=>{const t=Za.getState().selectedFiles;if(t&&1===t.size||e){const n=e||Array.from(t)[0];r(n)}},[r]),h=n.useCallback(t=>{const r=Za.getState().selectedFiles;if(r&&r.size>0||(null==t?void 0:t.id)){if(l)return void l();(t?[t.id]:r).forEach(t=>{const r=e.find(e=>e.id===t);r?r.isFolder?s(t):a(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[e,a,s,l]);return{handleClearSelection:u,handleRename:d,handleDeleteSelected:h,handleCopy:n.useCallback(()=>{o()},[o]),handleMove:n.useCallback(()=>{i()},[i]),handleEdit:n.useCallback(()=>{c()},[c])}})({files:ke||[],clearSelection:pe,showRenameModal:Le,showMoveModal:ze,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:Oe,handleDeleteFolder:kt,showDeleteConfirm:$e,onEdit:at.handleEdit}),It=ve||Ae||st;a(()=>{Sr()},[]),x(()=>{G!==rr?pe():ge(ke||[])},[G,ke,ge,pe]),a(()=>{if(!E||G!==rr)return;if(!ur.current)return void(ur.current=!0);const e=(Array.isArray(ke)?ke:[]).filter(e=>fe.has(e.id));E(e)},[G,ke,fe,E]),i.useEffect(()=>{if(!Xe||0===me.length)return;const e=!1!==(null==T?void 0:T.rememberLastFolder),t=`em_fm:lastFolder:${(null==T?void 0:T.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),r=e&&me.some(t=>t.id===e);if(r)return void Xe(e)}catch(e){}qe||Xe("folders")},[qe,Xe,me,null==T?void 0:T.rememberLastFolder,null==T?void 0:T.projectId]);const{handleRenameFolderCancel:Et,handleRenameFolderOk:Ft}=Se.actions;a(()=>{const e=async e=>{if(G!==rr)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const r=e.clipboardData;if(!r)return;const n=Array.from(r.items),i=n.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await St(t)))}const o=n.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const r=t.trim();if(r.startsWith("http://")||r.startsWith("https://"))e.preventDefault(),await Ct(r);else if(r.includes("<meta")||r.includes("http")){const t=r.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await Ct(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[G,Ct,St]);const Tt=u(Ze);a(()=>{Tt.current=Ze},[Ze]);const Ot=c(e=>{it(e.current||Tt.current.current,e.pageSize||Tt.current.pageSize)},[it]),Pt=c(e=>{null==Ke||Ke(e)},[Ke]),Mt=i.useCallback(e=>{const{sortBy:t,sortOrder:r}=(e=>{const[t,r]=e.split("-");return{sortBy:t,sortOrder:r}})(e);nt(t,r)},[nt]),[Rt,Lt]=o(sN),[Nt,jt]=o([]),Dt=u(null),[zt,Bt]=o(vr),[Ut,Vt]=o([]),Ht=u(null),[$t,Wt]=o(""),Gt=u(null),[qt,Yt]=o(""),[Xt,Kt]=o([]),Zt=i.useRef(void 0),[Jt,Qt]=o(!1),[er,tr]=o(!1),cr=i.useRef(null),ur=i.useRef(!1),dr=i.useRef(G),hr=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const r=e.substring(0,t),n=r.match(/^data:([^;]+)/),i=n&&n[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(r)){const r=e.substring(t+1),n=atob(r),a=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)a[e]=n.charCodeAt(e);o=new Blob([a],{type:i})}else{const r=decodeURIComponent(e.substring(t+1));o=new Blob([r],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),fr=i.useCallback(async e=>{var t;const r=v.startUpload(qe||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[v,ke,y,qe]),pr=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=hr(e);if(!t)return;return void await fr(t)}e&&await Ct(e,void 0,void 0,"iconStock")},[hr,Ct,fr]),yr=c(async()=>{const e=null==K?void 0:K.fileForEdit;if(Zt.current===e)return;if(G===sr&&e&&!at.editingFile){Zt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==at||at.handleEdit({thumbnail:e,saveWithoutFolder:!0}));const t=await y.resolveFileForEditByUrl(e);Zt.current===e&&(null==at||at.handleEdit(t))}}catch(t){Zt.current===e&&(Zt.current=null),console.error("Failed to open file in editor:",t),null==at||at.handlePixieEditorClose()}}},[null==K?void 0:K.fileForEdit,G,at,y]);a(()=>{yr()},[yr]),a(()=>{var e,t,r,n;const i=dr.current;dr.current=G,G===rr?(jt([]),Lt(sN),Vt([]),Bt(vr),Kt([]),Yt(""),tr(!1),Qt(!1),i===rr||i!==ir&&i!==nr&&i!==ar||rt("")):G===ar?null===(e=cr.current)||void 0===e||e.focus():G===nr?null===(t=Dt.current)||void 0===t||t.focus():G===ir?null===(r=Ht.current)||void 0===r||r.focus():G===or&&(null===(n=Gt.current)||void 0===n||n.focus())},[G,rt]);const br=i.useCallback(async()=>{var e;await Ft(),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts())},[Ft]),wr=fe.size,xr=i.useMemo(()=>{var e,t,r;if(1!==wr)return!1;const[n]=Array.from(fe),i=ke.find(e=>e.id===n);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(r=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==r?r:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&mr.includes(s)},[wr,fe,ke]),Cr=c(e=>{var t;return e?(null===(t=e.files)||void 0===t?void 0:t.length)?Array.from(e.files):e.items?Array.from(e.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[]:[]},[]);return t(r,{children:[ne&&pt===rr&&Fe(e("div",{className:xs.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&!ae.current&&re(!0)},onDragEnter:e=>{var t,r;e.preventDefault(),e.stopPropagation(),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&re(!0)},onDragLeave:e=>{const t=e.relatedTarget;t&&document.documentElement.contains(t)||(re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging"))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),ie(!1),re(!1),document.body.removeAttribute("data-fm-dragging");const t=Cr(e.dataTransfer);t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true"}),document.body),te&&Fe(e("div",{className:xs.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),re(!1),ie(!1),document.body.removeAttribute("data-fm-dragging");const t=Cr(e.dataTransfer);t.length&&(lt(!0),De(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true",children:t("div",{className:xs.dragOverlayInner,children:[e("div",{className:xs.uploadIcon,children:e(Z,{})}),e("div",{className:xs.textTitle,children:C("Drop files here to upload")}),e("div",{className:xs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),document.body),e(J,{className:"file-manager__layout",children:t("div",{className:xs.filesContainer,"data-files-container":"true",onDragOver:dt,onDragLeave:ut,onDragEnter:ct,onDrop:ht,children:[Q&&e("div",{className:xs.dragOverlay,children:t("div",{className:xs.dragOverlayInner,children:[e("div",{className:xs.uploadIcon,children:e(Z,{})}),e("div",{className:xs.textTitle,children:C("Drop files here to upload")}),e("div",{className:xs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(J,{className:"file-manager__content",children:[t(oN,{width:320,theme:"light",className:"file-manager-sider",children:[e(cl,{ref:se,selectedFolder:qe||"folders",generateMenuItems:_e,onFolderSelect:e=>null==Xe?void 0:Xe(e),folders:me||[],fetchFolders:ye,fetchChildFolders:be,handleAddFile:xt,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleDeleteFolder:kt,handleCreateFolder:we,activeLibraryItem:G,setActiveLibraryItem:e=>null==Y?void 0:Y(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(J,{className:"file-manager__main-content",children:[st&&e(rl,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(aN,{className:"main-content",children:[e(pL,{activeLibraryItem:G,selectedFolder:(null===(s=null==me?void 0:me.find(e=>(null==e?void 0:e.id)===qe))||void 0===s?void 0:s.name)||C("Folders"),isTrashFolder:"Trash"===qe,onClearTrash:mt,files:ke||[],loading:It,onRefresh:ot,refreshDisabled:Ae||ve,showRefresh:!(!(null===(l=null==I?void 0:I.apiEndpoints)||void 0===l?void 0:l.clearCache)&&!(null===(d=null==I?void 0:I.dataProviders)||void 0===d?void 0:d.clearCache))}),e(X,{className:"zero-divider"}),G===rr&&e(Ws,{searchTerm:Qe,handleAddFile:xt,files:ke||[],handleSearch:rt,sortBy:et,sortOrder:tt,handleSortOptionChange:Mt,pagination:Ze,setPagination:Ot,loading:It,handleItemClick:Pt,onClearSelection:At.handleClearSelection,onRename:At.handleRename,onCopy:At.handleCopy,onMove:At.handleMove,onDelete:At.handleDeleteSelected,showRenameModal:Le,showDeleteConfirm:$e,showCopyModal:f.actions.showCopyModal||(()=>{}),showMoveModal:ze,onEdit:at.handleEdit,getFileData:y.getFileData}),G===nr&&e(CL,{imageGifList:Nt,setImageGifList:jt,currentReqGif:Rt,setCurrentReqGif:Lt,inputRef:Dt,customRequest:(e,t)=>Ct(e,void 0,t,"gif")}),G===ir&&e(AL,{imageStockList:Ut,setImageStockList:Vt,currentReq:zt,setCurrentReq:Bt,inputRef:Ht,customRequest:(e,t)=>Ct(e,void 0,t,"imageStock")}),G===or&&e(nN,{apiKey:null==K?void 0:K.STREAMLINE_API_KEY,customRequest:pr,query:$t,setQuery:Wt,inputRef:Gt}),G===ar&&!!(null==K?void 0:K.sseQuery)&&e(NL,{imageAiList:Xt,setImageAiList:Kt,aiImageRequest:qt,setAiImageRequest:Yt,inputAiRef:cr,customRequest:_t,isLoadingAi:Jt,setIsLoadingAi:Qt,isImageUploaded:er,setIsImageUploaded:tr}),G===sr&&e(r,{}),e(r,{children:xr&&t(r,{children:[e(X,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(M,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(_.onEditorOk){const e=Array.from(fe)[0],t=ke.find(t=>t.id===e);t&&_.onEditorOk(t)}},children:C("Choose")})})]})})]})]})]}),ce&&!v.isUploadVisible&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(S,{size:"large"})}),e(sl,{isModalVisible:z,handleModalOk:xe,handleModalCancel:Ce,form:P,selectedFolder:qe||null,folders:me||[],isUrlModalVisible:B,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleAddFileByUrl:Ct,urlForm:R,isRenameModalVisible:Ie,handleRenameOk:()=>null==je?void 0:je(),handleRenameCancel:()=>null==Ne?void 0:Ne(),renameForm:L,fileToRename:Ee,files:ke||[],isMoveModalVisible:U,handleMoveOk:bt,handleMoveCancel:Be,moveForm:N,selectedFiles:fe||new Set,isRenameFolderModalVisible:V,handleRenameFolderOk:br,handleRenameFolderCancel:Et,renameFolderForm:j,folderToRename:W,isCopyModalVisible:H,handleCopyOk:wt,handleCopyCancel:He,copyForm:D,isDeleteConfirmVisible:$,handleDeleteConfirmOk:gt,handleDeleteConfirmCancel:()=>null==We?void 0:We(),isClearTrashConfirmVisible:de,handleClearTrashConfirm:vt,handleClearTrashCancel:yt,fetchChildFolders:be}),e(NR,{visible:at.isPixieEditorVisible,onClose:at.handlePixieEditorClose,file:at.editingFile,onSave:at.handlePixieEditorSave,onSaveCopy:at.handlePixieEditorSaveCopy}),e(dL,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const r=v.getUploadedFile(e.id)||e;null===(t=_.onEditorOk)||void 0===t||t.call(_,r)}})]})})]})},cN=f(({config:n={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.folderNameProcessing)},n),[n]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(hr).matches?ur:cr;e=e===dr?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),iN(b)},[b]),a(()=>{b.locale&&b.locale!==On.language&&On.changeLanguage(b.locale),b.customLocale&&b.locale&&On.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null),x=i.useMemo(()=>({apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y}),[h,c,d,o,s,l,b,f,p,g,m,v,y]);return e(I,{className:"em-filemanager",children:t(r,{children:[e(A,{getPopupContainer:()=>w.current||document.body,children:e(go,{options:x,children:e(lN,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});cN.displayName="FileManagerApp";const uN=t=>{var r,n,i;return e(Xn,{i18n:On,children:e(wr,{externalTheme:null!==(n=null===(r=t.config)||void 0===r?void 0:r.theme)&&void 0!==n?n:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(oe,{children:e(cN,Object.assign({},t))})})})},dN=new Map,hN=(t,r)=>{var n;let i;Sr();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?Cr("imageCenter",e):Cr(t)};if(t instanceof HTMLElement){i=t;o={config:a(r),apiEndpoints:null==r?void 0:r.apiEndpoints}}else{i=t.element;const e=a(t.config),r=Object.assign(Object.assign({},null===(n=t.config)||void 0===n?void 0:n.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:r,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=_(i);s.render(e(uN,Object.assign({},o))),dN.set(i.id||`container_${Date.now()}`,s)},fN=e=>{const t=e.id||Object.keys(dN).find(e=>e.startsWith("container_"));if(t&&dN.has(t)){const e=dN.get(t);null==e||e.unmount(),dN.delete(t)}else{console.warn("Couldn t find the root to unmount");try{_(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},pN=new Map,gN=n=>{const{onClose:o,onSave:s,dataProviders:l,theme:c,locale:d,hasPagination:h,disablePagination:f,paginationAvailable:p,dedupeUploadNamesOnClient:g,saveCopyToCurrentFolder:m}=n,v=i.useMemo(()=>{var e,t;return{theme:null!=c?c:"light",locale:d,baseUrl:n.baseUrl,assetsUrl:n.assetsUrl,compressMaxSize:n.compressMaxSize,compressMaxWidthOrHeight:n.compressMaxWidthOrHeight,compessorUrl:null!==(e=n.compessorUrl)&&void 0!==e?e:n.compressorUrl,compressorUrl:null!==(t=n.compressorUrl)&&void 0!==t?t:n.compessorUrl,showNotifications:n.showNotifications,handleFileProxy:n.handleFileProxy,hasPagination:h,disablePagination:f,paginationAvailable:p,dedupeUploadNamesOnClient:g,saveCopyToCurrentFolder:m}},[c,d,n.baseUrl,n.assetsUrl,n.compressMaxSize,n.compressMaxWidthOrHeight,n.compessorUrl,n.compressorUrl,n.showNotifications,n.handleFileProxy,h,f,p,g,m]),y=i.useCallback(async(e,t,r,n)=>{if(!e&&!t||!(null==l?void 0:l.getFiles))return null;try{const i=await l.getFiles({folderId:n?void 0:null!=r?r:void 0,noFolder:n,search:t||void 0,itemType:"file",page:1,limit:1}),[o]=i.files;return o?e&&o.id!==e?null:o:null}catch(e){return console.warn("Standalone Pixie: failed to resolve uploaded file from provider",e),null}},[l]),b=i.useMemo(()=>{if(n.file)return n.file;const e=n.name||"edited-image",t=n.extension||(n.type?n.type.split("/")[1]:"png"),r=n.type||`image/${t}`;return{thumbnail:n.imageDataUrl||"",name:e,id:void 0,type:r,extension:t,saveWithoutFolder:!0}},[n.file,n.imageDataUrl,n.name,n.extension,n.type]),w=i.useCallback(async(e,t)=>{if((null==l?void 0:l.updateFile)&&e.thumbnail)try{const r=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),n=Fr(r),i=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,o=(null==t?void 0:t.blob)||Mr(e.thumbnail,r);return await l.updateFile(e.id,{name:i,type:r,data:o})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[l]),x=i.useCallback(async(e,t)=>{var r,n,i,o,a,s;if(!e.thumbnail)return null;try{const c=!0!==v.saveCopyToCurrentFolder||(null!==(r=e.saveWithoutFolder)&&void 0!==r?r:!e.id),u=c?"":e.folderId||"",d=(null==t?void 0:t.mimeType)||Er(e.thumbnail,e.type),h=(null==t?void 0:t.blob)||Mr(e.thumbnail,d),f=Dr(e.name,v),p=await hi(l,f,u,c,Br(v)),g=new File([h],p,{type:d,lastModified:Date.now()});if(null==l?void 0:l.uploadFiles){const t=await l.uploadFiles({items:[{name:g.name,size:g.size,type:g.type,folderId:u,noFolder:c,data:g,extension:Fr(d)}],folderId:u}),r=null===(n=t.detailed)||void 0===n?void 0:n[0];if(t.success&&(null==r?void 0:r.success)&&r.data){const t=r.data;if(t.url||t.thumbnailUrl||t.thumbnail)return{id:t.id||e.id||"",name:t.name||e.name,folderId:null!==(i=t.folderId)&&void 0!==i?i:u,type:t.type||g.type,size:null!==(o=t.size)&&void 0!==o?o:g.size,extension:t.extension||Fr(d),url:t.url,thumbnailUrl:t.thumbnailUrl,thumbnail:t.thumbnail,date:t.date,dimensions:t.dimensions,aspectRatio:t.aspectRatio,sourceUrl:t.sourceUrl,isFolder:!1,selected:!1};const n=await y(r.data.id,r.data.name||g.name,null!==(a=r.data.folderId)&&void 0!==a?a:u,c);return n||{id:r.data.id||e.id||"",name:r.data.name||e.name,folderId:null!==(s=r.data.folderId)&&void 0!==s?s:u,type:g.type,size:g.size,extension:Fr(d),url:r.data.url,thumbnailUrl:r.data.thumbnailUrl,thumbnail:r.data.thumbnail,isFolder:!1,selected:!1}}}return(null==l?void 0:l.uploadFile)?await l.uploadFile({name:g.name,size:g.size,type:g.type,folderId:u,noFolder:c,data:g,extension:Fr(d)}):null}catch(e){return console.error("Error saving file copy:",e),null}},[l,y,v]),C=i.useCallback(async(e,t)=>{if((null==l?void 0:l.updateFile)&&e.id&&e.thumbnail)try{const r=await w(e,t);r&&(e=r)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return s&&await s(e,t),o&&o(),e},[l,s,o,w]),_=i.useCallback(async(e,t)=>{let r=e;if(e.thumbnail)try{const n=await x(e,t);n&&(r=n)}catch(e){console.error("Standalone Pixie: saveFileCopyToServer error",e)}return s&&await s(r,t),o&&o(),r},[o,s,x]),S=u(null);return a(()=>{d&&d!==On.language&&On.changeLanguage(d)},[d]),e(I,{className:"em-filemanager",children:t(r,{children:[e(A,{getPopupContainer:()=>S.current||document.body,children:e(Xn,{i18n:On,children:e(wr,{externalTheme:null!=c?c:"light",children:e(oe,{children:e(go,{options:{dataProviders:l,handleNotify:n.handleNotify,handleError:n.handleError,handleSuccess:n.handleSuccess,config:v},children:e(NR,{visible:!0,onClose:o,file:b,onSave:C,onSaveCopy:_})})})})})}),e("div",{ref:S,className:"file-manager-modal-root"})]})})},mN=t=>{Sr();const r=t.element,n=_(r);n.render(e(gN,Object.assign({},t))),pN.set(r.id||`pixie_container_${Date.now()}`,n)},vN=e=>{const t=Array.from(pN.keys()).find(e=>e.startsWith("pixie_container_")),r=e.id||t;if(r&&pN.has(r)){const e=pN.get(r);null==e||e.unmount(),pN.delete(r)}else{console.warn("Couldn t find the root to unmount Pixie");try{_(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},yN=e=>{var t,r;const{mode:n,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&fN(c),u&&vN(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(n){case"fileManager":c=i,hN(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>fN(c);break;case"pixieEditor":u=i,mN(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>vN(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,hN(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),mN(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>fN(c),d.unmountPixieEditor=()=>vN(u);break}}return d};function bN(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var wN={init:hN,unmount:fN,initPixieEditor:mN,unmountPixieEditor:vN,initFileManager:yN};export{Ws as FileContent,qo as FileManagerApiError,cN as FileManagerApp,uN as FileManagerAppWithContext,sl as FileModals,cl as FolderSidebar,gN as PixieOnlyApp,wN as default,hN as init,yN as initFileManager,mN as initPixieEditor,Sr as installResizeObserverErrorHandler,bN as mapHttpStatusToErrorCode,kr as uninstallResizeObserverErrorHandler,fN as unmount,vN as unmountPixieEditor};
|
|
62
62
|
//# sourceMappingURL=file-manager.esm.js.map
|