class KropiftActOne{constructor(t="KropiftActOne",e="1.0.0"){this.name=t,this.version=e,this.status="initialized",this.logs=[],this.config={retries:3,delay:1e3,enableLogging:!0},this.metrics={actionsCompleted:0,errorsEncountered:0},this.dataBuffer=[]}start(){this.status="running",this.log(`Started ${this.name} v`+this.version),this.runDiagnostics()}stop(){this.status="stopped",this.log("Stopped "+this.name)}pause(){this.status="paused",this.log("Paused "+this.name)}resume(){this.status="running",this.log("Resumed "+this.name)}log(t){this.config.enableLogging&&(t=`[${(new Date).toISOString()}] `+t,this.logs.push(t),console.log(t))}getStatus(){return{name:this.name,version:this.version,status:this.status,logCount:this.logs.length,config:this.config,metrics:this.metrics}}updateConfig(t={}){this.config={...this.config,...t},this.log("Configuration updated: "+JSON.stringify(this.config))}runDiagnostics(){this.log("Running system diagnostics...");["CPU","Memory","Disk","Network"].forEach((t,e)=>{setTimeout(()=>{this.log(`Diagnostic check: ${t} OK`)},500*(e+1))})}simulateAction(e="DefaultAction"){this.log(`Starting simulation of ${e}...`);for(let t=0;t{this.log(`Simulation step ${t+1} of ${e} complete.`),t===this.config.retries-1&&(this.metrics.actionsCompleted++,this.log(`Simulation of ${e} completed successfully.`))},t*this.config.delay)}generateReport(){var t={name:this.name,version:this.version,status:this.status,metrics:this.metrics,lastLog:this.logs[this.logs.length-1]||"No logs yet"};return this.log("Generated report."),t}resetMetrics(){this.metrics={actionsCompleted:0,errorsEncountered:0},this.log("Metrics reset.")}simulateError(t="An unknown error occurred"){this.metrics.errorsEncountered++,this.log("Error: "+t)}cleanup(){this.status="cleaned",this.logs=[],this.dataBuffer=[],this.log("Cleanup completed. Logs and data buffer cleared.")}importData(t){this.dataBuffer.push(...t),this.log(`Imported ${t.length} items into KropiftActOne.`)}exportData(){return this.log("Exporting data buffer contents."),[...this.dataBuffer]}analyzeData(){this.log("Analyzing data buffer..."),0===this.dataBuffer.length?this.log("No data to analyze."):this.log(`Data buffer contains ${this.dataBuffer.length} items.`)}performLongOperation(){this.log("Performing long operation...");let t=0;const e=setInterval(()=>{t++,this.log(`Step ${t} of long operation complete.`),5<=t&&(clearInterval(e),this.log("Long operation completed."))},1e3)}}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e()}(this,function(){"use strict";function M(e,t){var i,a=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,i)),a}function H(a){for(var t=1;tt.length)&&(e=t.length);for(var i=0,a=new Array(e);it.width?3===i?s=t.height*e:n=t.width/e:3===i?n=t.width/e:s=t.height*e,{aspectRatio:e,naturalWidth:o,naturalHeight:a,width:s,height:n});this.canvasData=e,this.limited=1===i||2===i,this.limitCanvas(!0,!0),e.width=Math.min(Math.max(e.width,e.minWidth),e.maxWidth),e.height=Math.min(Math.max(e.height,e.minHeight),e.maxHeight),e.left=(t.width-e.width)/2,e.top=(t.height-e.height)/2,e.oldLeft=e.left,e.oldTop=e.top,this.initialCanvasData=u({},e)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,o=this.canvasData,s=this.cropBoxData,n=i.viewMode,r=o.aspectRatio,h=this.cropped&&s;t&&(t=Number(i.minCanvasWidth)||0,i=Number(i.minCanvasHeight)||0,1=a.width&&(o.minLeft=Math.min(0,r),o.maxLeft=Math.max(0,r)),o.height>=a.height)&&(o.minTop=Math.min(0,t),o.maxTop=Math.max(0,t))):(o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=a.width,o.maxTop=a.height))},renderCanvas:function(t,e){var i,a,o,s,n=this.canvasData,r=this.imageData;e&&(r=(e={width:r.naturalWidth*Math.abs(r.scaleX||1),height:r.naturalHeight*Math.abs(r.scaleY||1),degree:r.rotate||0}).width,s=e.height,e=e.degree,i=90==(e=Math.abs(e)%180)?{width:s,height:r}:(a=e%90*Math.PI/180,i=Math.sin(a),o=r*(a=Math.cos(a))+s*i,r=r*i+s*a,90n.maxWidth||n.widthn.maxHeight||n.heighte.width?a.height=a.width/i:a.width=a.height*i),this.cropBoxData=a,this.limitCropBox(!0,!0),a.width=Math.min(Math.max(a.width,a.minWidth),a.maxWidth),a.height=Math.min(Math.max(a.height,a.minHeight),a.maxHeight),a.width=Math.max(a.minWidth,a.width*t),a.height=Math.max(a.minHeight,a.height*t),a.left=e.left+(e.width-a.width)/2,a.top=e.top+(e.height-a.height)/2,a.oldLeft=a.left,a.oldTop=a.top,this.initialCropBoxData=u({},a)},limitCropBox:function(t,e){var i,a,o=this.options,s=this.containerData,n=this.canvasData,r=this.cropBoxData,h=this.limited,c=o.aspectRatio;t&&(t=Number(o.minCropBoxWidth)||0,o=Number(o.minCropBoxHeight)||0,i=h?Math.min(s.width,n.width,n.width+n.left,s.width-n.left):s.width,a=h?Math.min(s.height,n.height,n.height+n.top,s.height-n.top):s.height,t=Math.min(t,s.width),o=Math.min(o,s.height),c&&(t&&o?ti.maxWidth||i.widthi.maxHeight||i.height=e.width&&i.height>=e.height?$:P),f(this.cropBox,u({width:i.width,height:i.height},x({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),b(this.element,tt,this.getData())}},e={initPreview:function(){var t=this.element,i=this.crossOrigin,e=this.options.preview,a=i?this.crossOriginUrl:this.url,o=t.alt||"The image to preview",s=document.createElement("img");i&&(s.crossOrigin=i),s.src=a,s.alt=o,this.viewBox.appendChild(s),this.viewBoxImage=s,e&&("string"==typeof(s=e)?s=t.ownerDocument.querySelectorAll(e):e.querySelector&&(s=[e]),N(this.previews=s,function(t){var e=document.createElement("img");w(t,m,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),i&&(e.crossOrigin=i),e.src=a,e.alt=o,e.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(e)}))},resetPreview:function(){N(this.previews,function(e){var i=Ct(e,m);if(f(e,{width:i.width,height:i.height}),e.innerHTML=i.html,s((i=e)[e=m]))try{delete i[e]}catch(t){i[e]=void 0}else if(i.dataset)try{delete i.dataset[e]}catch(t){i.dataset[e]=void 0}else i.removeAttribute("data-".concat(kt(e)))})},preview:function(){var n=this.imageData,t=this.canvasData,e=this.cropBoxData,r=e.width,h=e.height,c=n.width,l=n.height,d=e.left-t.left-n.left,p=e.top-t.top-n.top;this.cropped&&!this.disabled&&(f(this.viewBoxImage,u({width:c,height:l},x(u({translateX:-d,translateY:-p},n)))),N(this.previews,function(t){var e=Ct(t,m),i=e.width,a=i,o=e=e.height,s=1;r&&(o=h*(s=i/r)),h&&eMath.abs(a-1)?i:a)&&(t.restore&&(s=this.getCanvasData(),n=this.getCropBoxData()),this.render(),t.restore)&&(this.setCanvasData(N(s,function(t,e){s[e]=t*o})),this.setCropBoxData(N(n,function(t,e){n[e]=t*o}))))},dblclick:function(){var t,e;this.disabled||this.options.dragMode===Z||this.setDragMode((t=this.dragBox,e=K,(t.classList?t.classList.contains(e):-1b&&(k.x=b-f);break;case S:p+k.xx&&(k.y=x-v)}}var i,a,s,o=this.options,n=this.canvasData,r=this.containerData,h=this.cropBoxData,c=this.pointers,l=this.action,d=o.aspectRatio,p=h.left,m=h.top,g=h.width,u=h.height,f=p+g,v=m+u,w=0,y=0,b=r.width,x=r.height,D=!0,M=(!d&&t.shiftKey&&(d=g&&u?g/u:1),this.limited&&(w=h.minLeft,y=h.minTop,b=w+Math.min(r.width,n.width,n.left+n.width),x=y+Math.min(r.height,n.height,n.top+n.height)),c[Object.keys(c)[0]]),k={x:M.endX-M.startX,y:M.endY-M.startY};switch(l){case P:p+=k.x,m+=k.y;break;case C:0<=k.x&&(b<=f||d&&(m<=y||x<=v))?D=!1:(e(C),(g+=k.x)<0&&(l=S,p-=g=-g),d&&(m+=(h.height-(u=g/d))/2));break;case E:k.y<=0&&(m<=y||d&&(p<=w||b<=f))?D=!1:(e(E),u-=k.y,m+=k.y,u<0&&(l=T,m-=u=-u),d&&(p+=(h.width-(g=u*d))/2));break;case S:k.x<=0&&(p<=w||d&&(m<=y||x<=v))?D=!1:(e(S),g-=k.x,p+=k.x,g<0&&(l=C,p-=g=-g),d&&(m+=(h.height-(u=g/d))/2));break;case T:0<=k.y&&(x<=v||d&&(p<=w||b<=f))?D=!1:(e(T),(u+=k.y)<0&&(l=E,m-=u=-u),d&&(p+=(h.width-(g=u*d))/2));break;case O:if(d){if(k.y<=0&&(m<=y||b<=f)){D=!1;break}e(E),u-=k.y,m+=k.y,g=u*d}else e(E),e(C),!(0<=k.x)||fMath.abs(s)&&(s=i)})}),s),t),D=!1;break;case U:k.x&&k.y?(i=Bt(this.cropper),p=M.startX-i.left,m=M.startY-i.top,g=h.minWidth,u=h.minHeight,0
',s=(o=o.querySelector(".".concat(c,"-container"))).querySelector(".".concat(c,"-canvas")),n=o.querySelector(".".concat(c,"-drag-box")),h=(r=o.querySelector(".".concat(c,"-crop-box"))).querySelector(".".concat(c,"-face")),this.container=a,this.cropper=o,this.canvas=s,this.dragBox=n,this.cropBox=r,this.viewBox=o.querySelector(".".concat(c,"-view-box")),this.face=h,s.appendChild(i),v(t,z),a.insertBefore(o,t.nextSibling),I(i,F),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,v(r,z),e.guides||v(r.getElementsByClassName("".concat(c,"-dashed")),z),e.center||v(r.getElementsByClassName("".concat(c,"-center")),z),e.background&&v(o,"".concat(c,"-bg")),e.highlight||v(h,J),e.cropBoxMovable&&(v(h,G),w(h,l,P)),e.cropBoxResizable||(v(r.getElementsByClassName("".concat(c,"-line")),z),v(r.getElementsByClassName("".concat(c,"-point")),z)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),d(e.ready)&&y(t,"ready",e.ready,{once:!0}),b(t,"ready"))}},{key:"unbuild",value:function(){var t;this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),(t=this.cropper.parentNode)&&t.removeChild(this.cropper),I(this.element,z))}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}]),W(Rt,D),Object.defineProperty(Rt,"prototype",{writable:!1}),Pt);function Pt(t){var e=1 or element.");this.element=t,this.options=u({},gt,g(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return u(D.prototype,i,e,t,Ht,Wt,Yt),D});class KropifyActTwo{constructor(t={}){this.options={debug:t.debug||!1,maxItems:t.maxItems||10,autoSave:t.autoSave||!1,theme:t.theme||"light"},this.isActive=!1,this.dataStore=[],this.eventListeners={},this.activityLog=[]}activate(){this.isActive=!0,this.log("KropifyActTwo activated."),this.initializeData(),this.triggerEvent("activated")}deactivate(){this.isActive=!1,this.log("KropifyActTwo deactivated."),this.clearData(),this.triggerEvent("deactivated")}log(t){this.options.debug&&(t="[DEBUG]: "+t,console.log(t),this.activityLog.push(t))}initializeData(){for(let t=0;t=this.options.maxItems?(this.log("Cannot add item: data store is full."),this.triggerEvent("error",{message:"Data store full"}),!1):(e={id:this.dataStore.length+1,name:t,createdAt:(new Date).toISOString()},this.dataStore.push(e),this.log("Item added: "+t),this.options.autoSave&&this.saveData(),this.triggerEvent("itemAdded",e),!0)}removeItem(e){var t=this.dataStore.findIndex(t=>t.name===e);return-1!==t?(t=this.dataStore.splice(t,1),this.log("Item removed: "+e),this.triggerEvent("itemRemoved",t[0]),!0):(this.log("Item not found: "+e),this.triggerEvent("error",{message:"Item not found: "+e}),!1)}updateItem(e,t={}){var i=this.dataStore.find(t=>t.name===e);return i?(Object.assign(i,t),this.log(`Item updated: ${e} => `+JSON.stringify(t)),this.triggerEvent("itemUpdated",i),!0):(this.log("Item not found for update: "+e),this.triggerEvent("error",{message:"Item not found for update: "+e}),!1)}getData(){return this.dataStore.slice()}registerEvent(t,e){this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(e),this.log("Registered event: "+t)}triggerEvent(t,e){var i=this.eventListeners[t];i&&i.length&&(i.forEach(t=>t(e)),this.log("Triggered event: "+t))}saveData(){this.log("Data saved to local storage (simulated).")}loadData(){this.log("Data loaded from local storage (simulated).")}toggleTheme(){this.options.theme="light"===this.options.theme?"dark":"light",this.log("Theme toggled to: "+this.options.theme),this.triggerEvent("themeChanged",{theme:this.options.theme})}printSummary(){var t={isActive:this.isActive,totalItems:this.dataStore.length,theme:this.options.theme,debug:this.options.debug};return this.log("Summary: "+JSON.stringify(t)),t}resetActivityLog(){this.activityLog=[],this.log("Activity log reset.")}exportDataForKropift(){return this.log("Exporting data for KropiftActOne."),this.dataStore.map(t=>({id:t.id,label:t.name,timestamp:t.createdAt}))}importResultsFromKropift(t){this.log("Importing analysis results from KropiftActOne: "+JSON.stringify(t))}performMaintenance(){this.log("Performing maintenance tasks..."),setTimeout(()=>{this.log("Maintenance completed.")},2e3)}}class Kropify{constructor(t,e={}){this.inputs=document.querySelectorAll(t),this.fileNameAttr="",this.defaults={allowedExtensions:["jpg","jpeg","png"],aspectRatio:1,preview:null,viewMode:1,cancelButtonText:"Cancel",resetButtonText:"Reset",cropButtonText:"Crop & Upload",processURL:"",maxSize:2097152,showLoader:!0,animationClass:"",fileName:"image",maxWoH:1080,onError:function(t){alert(t)},onDone:function(t){}},this.options=Object.assign({},this.defaults,e),this.csrfToken=document.querySelector('meta[name="csrf-token"]')?.getAttribute("content"),this.init()}init(){this.inputs.forEach(e=>{this.setDefaultImagePreview(),e.addEventListener("change",t=>this.handleFileSelect(t,e))})}setDefaultImagePreview(){var t,e;this.options.preview&&(t=document.querySelector(this.options.preview))&&(e=t.dataset.kropifyDefaultSrc)&&(t.src=e)}fadeImage(t,e){t.style.opacity=0,setTimeout(()=>{t.src=e,t.style.opacity=1},200)}handleFileSelect(t,e){var t=t.target.files[0],i=e.name,i=(this.fileNameAttr=i,this.options.preview?document.querySelector(this.options.preview):null);if(t){var a=t.name.split(".").pop().toLowerCase();if(this.options.allowedExtensions.includes(a))if(t.size>this.options.maxSize)this.options.onError(`File too large.Max size is ${this.options.maxSize/1024/1024}MB`),e.value="",i&&i.dataset.kropifyDefaultSrc&&this.fadeImage(i,i.dataset.kropifyDefaultSrc);else{const o=new FileReader;o.onload=()=>{this.showCropperModal(o.result,e)},o.readAsDataURL(t)}else this.options.onError("Invalid file type.Allowed:"+this.options.allowedExtensions.join(", ")),e.value="",i&&i.dataset.kropifyDefaultSrc&&this.fadeImage(i,i.dataset.kropifyDefaultSrc)}}showCropperModal(t,r){const h=document.createElement("div");h.className="kropify-modal",h.innerHTML=`
KROPIFY v3
+
`,document.body.appendChild(h);t=h.querySelector("#cropper-image");const c=new Cropper(t,{aspectRatio:this.options.aspectRatio,viewMode:this.options.viewMode}),e=h.querySelector(".kropify-modal-content");e.classList.remove("animate__animated","animate__"+this.options.animationClass),e.offsetWidth,e.classList.add("animate__animated","animate__"+this.options.animationClass),e.addEventListener("animationend",()=>{e.classList.remove("animate__animated","animate__"+this.options.animationClass)});let o,i=1,a=1;function s(t){switch(t){case"rotate-left":c.rotate(-1);break;case"rotate-right":c.rotate(1);break;case"zoom-in":c.zoom(.01);break;case"zoom-out":c.zoom(-.01);break;case"move-up":c.move(0,-1);break;case"move-down":c.move(0,1);break;case"move-left":c.move(-1,0);break;case"move-right":c.move(1,0);break;case"flip-horizontal":i=1===i?-1:1,c.scaleX(i);break;case"flip-vertical":a=1===a?-1:1,c.scaleY(a)}}h.querySelectorAll(".kropify-options span").forEach(t=>{const e=t.dataset.action;var i=()=>{s(e),["flip-horizontal","flip-vertical"].includes(e)||(o=setInterval(()=>s(e),30))},a=()=>clearInterval(o);t.addEventListener("mousedown",i),t.addEventListener("mouseup",a),t.addEventListener("mouseleave",a),t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",a)}),h.querySelector("span.jc-close-btn").onclick=()=>{c.destroy(),h.remove(),r.value=""},h.querySelector("div.btn-close").onclick=()=>{c.destroy(),h.remove(),r.value=""},h.querySelector("span.jc-reset-btn").onclick=()=>{c.reset()},h.querySelector("span.jc-crop-btn").onclick=()=>{if(this.csrfToken){const n=c.getCroppedCanvas();var i=c.getCroppedCanvas(),a=i.width,i=i.height,o=this.options.maxWoH;let t=a,e=i;(o{if(t.ok)return t.text().then(e=>{if(!e)return{};try{return JSON.parse(e)}catch(t){return e}});this.options.onError(""+t.status+t.statusText)}).then(t=>{this.options.showLoader&&this.hideLoader(),"function"==typeof this.options.onDone&&this.options.onDone(t),c.destroy(),h.remove(),r.value="",this.options.preview&&(t=document.querySelector(this.options.preview))&&"IMG"===t.tagName&&(t.src=n.toDataURL("image/png"))}).catch(function(t){this.options.showLoader&&this.hideLoader(),this.options.onError(t.message||"An unexpected error occurred.")})):this.options.onError("Cropping failed.")}else this.options.onError('CSRF token not found. Make sure your page includes: ')}}b64toBlob(t,e,i){e=e||"",i=i||512;for(var a=atob(t),o=[],s=0;s
',document.body.appendChild(t))}hideLoader(){var t=document.querySelector(".kropify-loader");t&&t.remove()}}class KropixaActThree{constructor(t={}){this.settings={verbose:t.verbose||!1,threshold:t.threshold||5,mode:t.mode||"standard",allowedOperations:t.allowedOperations||["analyze","sync","archive"]},this.operationHistory=[],this.resources=[],this.activeTasks=[],this.status="idle"}initialize(){this.status="initialized",this.log("KropixaActThree initialized."),this.setupResources()}setupResources(){for(let t=0;t{e.status="completed",this.operationHistory.push(e),this.log("Task completed: "+t)},1e3),!0}stopAllTasks(){this.activeTasks.forEach(t=>{t.status="stopped",this.log("Task stopped: "+t.name)}),this.activeTasks=[],this.status="idle",this.log("All tasks stopped.")}log(t){var e;this.settings.verbose&&(e=(new Date).toISOString(),console.log(`[${e}] KropixaActThree: `+t))}getStatus(){return{status:this.status,activeTasks:this.activeTasks.length,totalResources:this.resources.length,operationsDone:this.operationHistory.length,settings:this.settings}}refreshResources(){this.resources.forEach(t=>{t.status="available"}),this.log("All resources refreshed and marked as available.")}analyzeResources(){var t=this.resources.filter(t=>"available"!==t.status).length;return this.log(`Resource analysis complete. In-use: ${t}, Available: `+(this.resources.length-t)),{total:this.resources.length,available:this.resources.length-t,inUse:t}}archiveData(){this.log("Archiving operation history...");var t={archivedItems:this.operationHistory.length,lastArchivedAt:(new Date).toISOString()};return this.operationHistory=[],this.log("Archive complete: "+JSON.stringify(t)),t}syncWithKropiftActOne(t){t?(t=t.exportData(),this.resources.push(...t.map((t,e)=>({id:this.resources.length+e+1,name:t.label,status:"imported"}))),this.log(`Imported ${t.length} items from KropiftActOne.`)):this.log("No KropiftActOne instance provided.")}exportDataForKropifyActTwo(){var t=this.resources.map(t=>({id:t.id,resourceName:t.name,status:t.status}));return this.log("Exporting data for KropifyActTwo."),t}toggleVerbose(){this.settings.verbose=!this.settings.verbose,this.log("Verbose mode toggled to: "+this.settings.verbose)}performDeepAnalysis(){this.log("Starting deep analysis...");let t=0;const e=setInterval(()=>{t+=20,this.log(`Deep analysis progress: ${t}%`),100<=t&&(clearInterval(e),this.log("Deep analysis complete."))},500)}resetSystem(){this.resources=[],this.activeTasks=[],this.operationHistory=[],this.status="idle",this.log("System reset complete.")}}