PageSourceSearch

https://inlite.com.au/assets/smart-crop-Bs75JoC4.js

js inlite.com.au collected 2026-10-09 00:47:41 UTC 15,608 bytes, 1 lines download raw bytes

1import{a as e,i as t,t as n}from"./rolldown-runtime-CNC7AqOf.js";import{d as r,p as i}from"./vendor-editor-Kht1VA-0.js";import{S as a,x as o}from"./vendor-pdf-XYZMXB_7.js";import{t as s}from"./utils-B6KiDbIe.js";import{a as c,i as l,n as u,r as d,s as f}from"./lazy-image-Doe0mWZx.js";var p={enabled:!0,fallback:`center`,minScale:.8},m={center:`50% 50%`,contain:`50% 50%`,"rule-of-thirds":`33% 33%`},h=e(i()),g=Object.prototype.hasOwnProperty;function _(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&_(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(g.call(e,n)&&++r&&!g.call(t,n)||!(n in t)||!_(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var v=n((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=i();function n(){var e=t.useRef(!1),n=t.useCallback(function(){return e.current},[]);return t.useEffect(function(){return e.current=!0,function(){e.current=!1}},[]),n}e.default=n})),y=n((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(o(),t(a)),r=i(),s=n.__importDefault(v());function c(e,t,i){t===void 0&&(t=[]),i===void 0&&(i={loading:!1});var a=r.useRef(0),o=s.default(),c=r.useState(i),l=c[0],u=c[1];return[l,r.useCallback(function(){var t=[...arguments],r=++a.current;return l.loading||u(function(e){return n.__assign(n.__assign({},e),{loading:!0})}),e.apply(void 0,t).then(function(e){return o()&&r===a.current&&u({value:e,loading:!1}),e},function(e){return o()&&r===a.current&&u({error:e,loading:!1}),e})},t)]}e.default=c})),b=n(((e,t)=>{(function(){var n={};function r(){throw Error(`No native promises and smartcrop.Promise not set.`)}n.Promise=typeof Promise<`u`?Promise:r,n.DEFAULTS={width:0,height:0,aspect:0,cropWidth:0,cropHeight:0,detailWeight:.2,skinColor:[.78,.57,.44],skinBias:.01,skinBrightnessMin:.2,skinBrightnessMax:1,skinThreshold:.8,skinWeight:1.8,saturationBrightnessMin:.05,saturationBrightnessMax:.9,saturationThreshold:.4,saturationBias:.2,saturationWeight:.1,scoreDownSample:8,step:8,scaleStep:.1,minScale:1,maxScale:1,edgeRadius:.4,edgeWeight:-20,outsideImportance:-.5,boostWeight:100,ruleOfThirds:!0,prescale:!0,imageOperations:null,canvasFactory:g,debug:!1},n.crop=function(e,t,r){var i=S({},n.DEFAULTS,t);i.aspect&&(i.width=i.aspect,i.height=1),i.imageOperations===null&&(i.imageOperations=_(i.canvasFactory));var a=i.imageOperations,o=1,s=1;return a.open(e,i.input).then(function(e){return i.width&&i.height&&(o=v(e.width/i.width,e.height/i.height),i.cropWidth=~~(i.width*o),i.cropHeight=~~(i.height*o),i.minScale=v(i.maxScale,y(1/o,i.minScale)),i.prescale!==!1&&(s=v(y(256/e.width,256/e.height),1),s<1?(e=a.resample(e,e.width*s,e.height*s),i.cropWidth=~~(i.cropWidth*s),i.cropHeight=~~(i.cropHeight*s),i.boost&&=i.boost.map(function(e){return{x:~~(e.x*s),y:~~(e.y*s),width:~~(e.width*s),height:~~(e.height*s),weight:e.weight}})):s=1)),e}).then(function(e){return a.getData(e).then(function(e){for(var t=p(i,e),n=t.crops||[t.topCrop],a=0,o=n.length;a<o;a++){var c=n[a];c.x=~~(c.x/s),c.y=~~(c.y/s),c.width=~~(c.width/s),c.height=~~(c.height/s)}return r&&r(t),t})})},n.isAvailable=function(e){return!(!n.Promise||(e?e.canvasFactory:g)===g&&!document.createElement(`canvas`).getContext(`2d`))};function i(e,t){for(var n=e.data,r=t.data,i=e.width,a=e.height,o=0;o<a;o++)for(var s=0;s<i;s++){var c=(o*i+s)*4,l=s===0||s>=i-1||o===0||o>=a-1?T(n,c):T(n,c)*4-T(n,c-i*4)-T(n,c-4)-T(n,c+4)-T(n,c+i*4);r[c+1]=l}}function a(e,t,n){for(var r=t.data,i=n.data,a=t.width,o=t.height,s=0;s<o;s++)for(var c=0;c<a;c++){var l=(s*a+c)*4,u=w(r[l],r[l+1],r[l+2])/255,d=f(e,r[l],r[l+1],r[l+2]),p=d>e.skinThreshold,m=u>=e.skinBrightnessMin&&u<=e.skinBrightnessMax;p&&m?i[l]=(d-e.skinThreshold)*(255/(1-e.skinThreshold)):i[l]=0}}function o(e,t,n){for(var r=t.data,i=n.data,a=t.width,o=t.height,s=0;s<o;s++)for(var c=0;c<a;c++){var l=(s*a+c)*4,u=w(r[l],r[l+1],r[l+2])/255,d=E(r[l],r[l+1],r[l+2]),f=d>e.saturationThreshold;u>=e.saturationBrightnessMin&&u<=e.saturationBrightnessMax&&f?i[l+2]=(d-e.saturationThreshold)*(255/(1-e.saturationThreshold)):i[l+2]=0}}function s(e,t){if(e.boost){for(var n=t.data,r=0;r<t.width;r+=4)n[r+3]=0;for(r=0;r<e.boost.length;r++)c(e.boost[r],e,t)}}
1function c(e,t,n){for(var r=n.data,i=n.width,a=~~e.x,o=~~(e.x+e.width),s=~~e.y,c=~~(e.y+e.height),l=e.weight*255,u=s;u<c;u++)for(var d=a;d<o;d++){var f=(u*i+d)*4;r[f+3]+=l}}function l(e,t,n){for(var r=[],i=v(t,n),a=e.cropWidth||i,o=e.cropHeight||i,s=e.maxScale;s>=e.minScale;s-=e.scaleStep)for(var c=0;c+o*s<=n;c+=e.step)for(var l=0;l+a*s<=t;l+=e.step)r.push({x:l,y:c,width:a*s,height:o*s});return r}function u(e,t,n){for(var r={detail:0,saturation:0,skin:0,boost:0,total:0},i=t.data,a=e.scoreDownSample,o=1/a,s=t.height*a,c=t.width*a,l=t.width,u=0;u<s;u+=a)for(var f=0;f<c;f+=a){var p=(~~(u*o)*l+~~(f*o))*4,m=d(e,n,f,u),h=i[p+1]/255;r.skin+=i[p]/255*(h+e.skinBias)*m,r.detail+=h*m,r.saturation+=i[p+2]/255*(h+e.saturationBias)*m,r.boost+=i[p+3]/255*m}return r.total=(r.detail*e.detailWeight+r.skin*e.skinWeight+r.saturation*e.saturationWeight+r.boost*e.boostWeight)/(n.width*n.height),r}function d(e,t,n,r){if(t.x>n||n>=t.x+t.width||t.y>r||r>=t.y+t.height)return e.outsideImportance;n=(n-t.x)/t.width,r=(r-t.y)/t.height;var i=b(.5-n)*2,a=b(.5-r)*2,o=Math.max(i-1+e.edgeRadius,0),s=Math.max(a-1+e.edgeRadius,0),c=(o*o+s*s)*e.edgeWeight,l=1.41-x(i*i+a*a);return e.ruleOfThirds&&(l+=Math.max(0,l+c+.5)*1.2*(C(i)+C(a))),l+c}n.importance=d;function f(e,t,n,r){var i=x(t*t+n*n+r*r),a=t/i-e.skinColor[0],o=n/i-e.skinColor[1],s=r/i-e.skinColor[2];return 1-x(a*a+o*o+s*s)}function p(e,t){var n={},r=new m(t.width,t.height);i(t,r),a(e,t,r),o(e,t,r),s(e,r);for(var c=h(r,e.scoreDownSample),d=-1/0,f=null,p=l(e,t.width,t.height),g=0,_=p.length;g<_;g++){var v=p[g];v.score=u(e,c,v),v.score.total>d&&(f=v,d=v.score.total)}return n.topCrop=f,e.debug&&f&&(n.crops=p,n.debugOutput=r,n.debugOptions=e,n.debugTopCrop=S({},n.topCrop)),n}function m(e,t,n){this.width=e,this.height=t,n?this.data=new Uint8ClampedArray(n):this.data=new Uint8ClampedArray(e*t*4)}n.ImgData=m;function h(e,t){for(var n=e.data,r=e.width,i=Math.floor(e.width/t),a=Math.floor(e.height/t),o=new m(i,a),s=o.data,c=1/(t*t),l=0;l<a;l++)for(var u=0;u<i;u++){for(var d=(l*i+u)*4,f=0,p=0,h=0,g=0,_=0,v=0,y=0;y<t;y++)for(var b=0;b<t;b++){var x=((l*t+y)*r+(u*t+b))*4;f+=n[x],p+=n[x+1],h+=n[x+2],g+=n[x+3],_=Math.max(_,n[x]),v=Math.max(v,n[x+1])}s[d]=f*c*.5+_*.5,s[d+1]=p*c*.7+v*.3,s[d+2]=h*c,s[d+3]=g*c}return o}n._downSample=h;function g(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function _(e){return{open:function(t){var r=e(t.naturalWidth||t.width,t.naturalHeight||t.height),i=r.getContext(`2d`);return t.naturalWidth&&(t.naturalWidth!=t.width||t.naturalHeight!=t.height)?(r.width=t.naturalWidth,r.height=t.naturalHeight):(r.width=t.width,r.height=t.height),i.drawImage(t,0,0),n.Promise.resolve(r)},resample:function(t,r,i){return Promise.resolve(t).then(function(t){var a=e(~~r,~~i);return a.getContext(`2d`).drawImage(t,0,0,t.width,t.height,0,0,a.width,a.height),n.Promise.resolve(a)})},getData:function(e){return Promise.resolve(e).then(function(e){var t=e.getContext(`2d`).getImageData(0,0,e.width,e.height);return new m(e.width,e.height,t.data)})}}}n._canvasImageOperations=_;var v=Math.min,y=Math.max,b=Math.abs,x=Math.sqrt;function S(e){for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];if(r)for(var i in r)e[i]=r[i]}return e}function C(e){return e=((e-1/3+1)%2*.5-.5)*16,Math.max(1-e*e,0)}function w(e,t,n){return .5126*n+.7152*t+.0722*e}function T(e,t){return w(e[t],e[t+1],e[t+2])}function E(e,t,n){var r=y(e/255,t/255,n/255),i=v(e/255,t/255,n/255);if(r===i)return 0;var a=(r+i)/2,o=r-i;return a>.5?o/(2-r-i):o/(r+i)}typeof define<`u`&&define.amd&&define(function(){return n}),e===void 0?typeof navigator<`u`&&(window.SmartCrop=window.smartcrop=n):e.smartcrop=n,t!==void 0&&(t.exports=n)})()})),x=e(y()),S=e(b()),C=function(e){var t=E(e.naturalWidth||e.width,e.naturalHeight||e.height);e.naturalWidth&&(e.naturalWidth!=e.width||e.naturalHeight!=e.height)?(t.width=e.naturalWidth,t.height=e.naturalHeight):(t.width=e.width,t.height=e.height);var n=t.getContext(`2d`);if(n)return n.drawImage(e,0,0),t;throw Error(`Couldn't get canvas context`)},w=function(e){var t=e.target;return C(t)};function T(e){return e.complete&&e.naturalHeight!==0}function E(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function D(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var O=[`src`,`crossOrigin`,`decoding`,`loading`,`referrerPolicy`];function k(e){e===void 0&&(e={});var t=(0,h.useState)(null),n=t[0],r=t[1],i=(0,h.useState)(null),a=i[0],o=i[1],s=e||{}
1,c=s.src,l=s.crossOrigin,u=l===void 0?``:l,d=s.decoding,f=s.loading,p=s.referrerPolicy;return D(s,O),(0,h.useEffect)(function(){if(!c)return;var e=function(e){try{o(w(e)),r(null)}catch(e){o(null),r(e)}};function t(e){r(e)}var n=new Image;if(n.crossOrigin=u,n.src=c,d&&(n.decoding=d),f&&(n.loading=f),p&&(n.referrerPolicy=p),T(n))try{o(C(n)),r(null)}catch(e){o(null),r(e)}else n.addEventListener(`load`,e),n.addEventListener(`error`,t);return function(){r(null);try{n.removeEventListener(`load`,e)}catch{}try{n.removeEventListener(`error`,t)}catch{}}},[c,u,d,f,p]),[a,n]}function A(e){var t=(0,h.useRef)();return(!t.current||!_(t.current,e))&&(t.current=e),t.current}function j(e,t){return S.default.crop(e,t)}function M(e,t){var n=A(t),r=(0,x.default)(function(){return e&&n?j(e,n):Promise.resolve(null)},[e,n],{loading:!!e}),i=r[0],a=r[1];return(0,h.useEffect)(function(){e&&n&&a()},[a,e,n]),i}var N=new Map,P=new Map,F=150;function I(e,t){let n;n=e<640?`sm`:e<1024?`md`:e<1440?`lg`:`xl`;let r=e/t,i;return i=r<.75?`portrait`:r<1.1?`square`:r<1.5?`landscape`:`wide`,`${n}-${i}`}function L(e,t,n){let r=(0,h.useMemo)(()=>({...p,...n}),[n]),[i,a]=(0,h.useState)({width:0,height:0});(0,h.useEffect)(()=>{let e=t.current;if(!e)return;let n=null,r=()=>{let t=e.getBoundingClientRect();t.width>0&&t.height>0&&(n&&clearTimeout(n),n=setTimeout(()=>{a(e=>{let n=Math.round(t.width),r=Math.round(t.height);return Math.abs(e.width-n)>5||Math.abs(e.height-r)>5?{width:n,height:r}:e})},F))},i=e.getBoundingClientRect();i.width>0&&i.height>0&&a({width:Math.round(i.width),height:Math.round(i.height)});let o=new ResizeObserver(r);return o.observe(e),()=>{o.disconnect(),n&&clearTimeout(n)}},[t]);let o=i.width>0&&i.height>0?I(i.width,i.height):``,s=e&&o?`${e}-${o}`:``,c=s?N.get(s):void 0,l=e?P.get(e):void 0,u=r.enabled&&i.width>0&&i.height>0&&!c&&!!e,[d,f]=k((0,h.useMemo)(()=>!u||!e?null:{src:e,crossOrigin:`anonymous`},[u,e])),g=(0,h.useMemo)(()=>d?{width:d.width,height:d.height}:null,[d]),_=M(u?d:void 0,{width:i.width,height:i.height,minScale:r.minScale}),v=(0,h.useCallback)((e,t)=>{if(!e||!t)return m[r.fallback];let n=e.x+e.width/2,i=e.y+e.height/2,a=Math.round(n/t.width*100),o=Math.round(i/t.height*100);return`${Math.max(0,Math.min(100,a))}% ${Math.max(0,Math.min(100,o))}%`},[r.fallback]);return(0,h.useMemo)(()=>{if(!r.enabled)return{position:m.center,usedFallback:!0,isAnalyzing:!1,error:null,crop:null,objectFit:`cover`};if(f)return{position:l||m[r.fallback],usedFallback:!l,isAnalyzing:!1,error:f,crop:null,objectFit:r.fallback===`contain`?`contain`:`cover`};if(_.error)return{position:l||m[r.fallback],usedFallback:!l,isAnalyzing:!1,error:_.error instanceof Error?_.error:Error(`Smart crop analysis failed`),crop:null,objectFit:r.fallback===`contain`?`contain`:`cover`};if(_.value?.topCrop){let t=_.value.topCrop,n={x:t.x,y:t.y,width:t.width,height:t.height},r=g||(d?{width:d.width,height:d.height}:null),i=v(n,r);return s&&N.set(s,{position:i,crop:n}),e&&P.set(e,i),{position:i,usedFallback:!1,isAnalyzing:!1,error:null,crop:n,objectFit:`cover`}}return c?(e&&P.set(e,c.position),{position:c.position,usedFallback:!1,isAnalyzing:!1,error:null,crop:c.crop,objectFit:`cover`}):_.loading||u?{position:l||m[r.fallback],usedFallback:!l,isAnalyzing:!0,error:null,crop:null,objectFit:r.fallback===`contain`?`contain`:`cover`}:{position:l||m[r.fallback],usedFallback:!l,isAnalyzing:!!e&&i.width>0&&i.height>0,error:null,crop:null,objectFit:r.fallback===`contain`?`contain`:`cover`}},[r.enabled,r.fallback,c,u,i.width,i.height,e,f,_.loading,_.error,_.value,g,d,v,s,l])}var R=r(),z=(0,h.forwardRef)(({src:e,alt:t,placeholder:n,loading:r,transition:i,fallbackSrc:a,className:o,imageClassName:p,fallbackClassName:m=`object-cover`,style:g,smartCrop:_,onLoad:v,onError:y,...b},x)=>{let S=(0,h.useRef)(null),C=(0,h.useMemo)(()=>({...l,...r}),[r]),w=(0,h.useMemo)(()=>({...c,...i}),[i]),{ref:T,inView:E}=f({threshold:C.threshold,rootMargin:C.rootMargin,triggerOnce:C.triggerOnce}),D=C.strategy===`eager`||E,{placeholderSrc:O}=d(n),{currentSrc:k,isLoaded:A,isShowingFallback:j,hasError:M,handleLoad:N,handleError:P}=u({src:e,fallbackSrc:a,shouldLoad:D,onLoad:v,onError:y,timeout:5e3}),F=L(D?e:void 0,S,_),I=(0,h.useMemo)(()=>{let e={transition:`opacity ${w.duration}ms ${w.easing}`};return!A&&!j&&(e.opacity=0),w.effect===`blur`&&!A&&!j&&(e.filter=`blur(10px)`),w.effect===`scale`&&!A&&!j&&(e.transform=`scale(0.95)`,e.transition=`opacity ${w.duration}ms ${w.easing}, transform ${w.duration}ms ${w.easing}`),e},[A,j,w]),z=(0,h.useMemo)(()=>j||!_?.enabled?{}:{objectPosition:F.position,objectFit:F.objectFit},[j,_?.enabled,F.position,F.objectFit]),B={...g,...I,...z},V=!A&&!j&&O,H=!A&&!j&&!M&&D;return(0,R.jsxs)(`div`,{className:s(`smart-image-container relative overflow-hidden`,o),ref:e=>{e&&(S.current=e),T(e)},children:[V&&(0,R.jsx)(`img`,{src:O,alt:``,"aria-hidden":`true`,className:`smart-image-placeholder absolute inset-0 w-full h-full object-cover`,"data-
1placeholder":`true`}),H&&(0,R.jsx)(`div`,{className:`lazy-image-shimmer absolute inset-0 z-0`,style:{transition:`opacity ${w.duration}ms ${w.easing}`}}),(0,R.jsx)(`img`,{ref:x,src:k,alt:t,style:B,onLoad:j?void 0:N,onError:j?void 0:P,className:s(`relative z-10 w-full h-full`,j?m:p),...b})]})});z.displayName=`SmartImage`;var B=(0,h.forwardRef)(({src:e,placeholder:t,loading:n,transition:r,fallbackSrc:i,className:a,style:o,children:p,smartCrop:m,onLoad:g,onError:_,...v},y)=>{let b=(0,h.useRef)(null),x=(0,h.useMemo)(()=>({...l,...n}),[n]),S=(0,h.useMemo)(()=>({...c,...r}),[r]),{ref:C,inView:w}=f({threshold:x.threshold,rootMargin:x.rootMargin,triggerOnce:x.triggerOnce}),T=x.strategy===`eager`||w,{placeholderSrc:E}=d(t),{currentSrc:D,isLoaded:O,isShowingFallback:k}=u({src:e,fallbackSrc:i,shouldLoad:T,onLoad:g,onError:_}),A=L(T?e:void 0,b,m),j=(0,h.useMemo)(()=>{let e={...o,transition:`opacity ${S.duration}ms ${S.easing}`};return O||k?e.backgroundImage=`url(${D})`:E&&(e.backgroundImage=`url(${E})`),(O||k)&&m?.enabled!==!1&&(e.backgroundPosition=A.position,e.backgroundSize=A.objectFit===`contain`?`contain`:`cover`),S.effect===`blur`&&!O&&!k&&E&&(e.filter=`blur(20px)`),S.effect===`scale`&&!O&&!k&&(e.transform=`scale(0.95)`,e.transition=`opacity ${S.duration}ms ${S.easing}, transform ${S.duration}ms ${S.easing}`),e},[O,k,D,E,o,S,m?.enabled,A.position,A.objectFit]),M=!O&&!k&&T;return(0,R.jsxs)(`div`,{ref:e=>{e&&(b.current=e),typeof y==`function`?y(e):y&&(y.current=e),C(e)},className:s(`smart-bg-image-container relative overflow-hidden bg-no-repeat`,a),style:j,...v,children:[M&&(0,R.jsx)(`div`,{className:`lazy-image-shimmer absolute inset-0 z-0`,style:{transition:`opacity ${S.duration}ms ${S.easing}`}}),p]})});B.displayName=`SmartBackgroundImage`;export{B as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.