import{bg as b}from"./index-6jOCfdig.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";function O(l){return l.split(" ").filter(a=>a!=="").map(a=>parseFloat(a))}function x(l,a,s){for(;s.length!==a;){const n=O(l.lines[l.index++]);s.push(...n)}}function V(l,a,s){let n=0,e=0,r=0,u=0,f=0,m=0;for(let o=0;o<l.numberOfHorizontalAngles-1;o++)if(s<l.horizontalAngles[o+1]||o===l.numberOfHorizontalAngles-2){e=o,r=l.horizontalAngles[o],u=l.horizontalAngles[o+1];break}for(let o=0;o<l.numberOfVerticalAngles-1;o++)if(a<l.verticalAngles[o+1]||o===l.numberOfVerticalAngles-2){n=o,f=l.verticalAngles[o],m=l.verticalAngles[o+1];break}const c=u-r,h=m-f;if(h===0)return 0;const p=c===0?0:(s-r)/c,g=(a-f)/h,d=c===0?e:e+1,t=b(l.candelaValues[e][n],l.candelaValues[d][n],p),i=b(l.candelaValues[e][n+1],l.candelaValues[d][n+1],p);return b(t,i,g)}function z(l){const n={lines:new TextDecoder("utf-8").decode(l).split(`
`),index:0},e={version:n.lines[0],candelaValues:[],horizontalAngles:[],verticalAngles:[],numberOfHorizontalAngles:0,numberOfVerticalAngles:0};for(n.index=1;n.lines.length>0&&!n.lines[n.index].includes("TILT=");)n.index++;n.lines[n.index].includes("INCLUDE"),n.index++;const r=O(n.lines[n.index++]);e.numberOfLights=r[0],e.lumensPerLamp=r[1],e.candelaMultiplier=r[2],e.numberOfVerticalAngles=r[3],e.numberOfHorizontalAngles=r[4],e.photometricType=r[5],e.unitsType=r[6],e.width=r[7],e.length=r[8],e.height=r[9];const u=O(n.lines[n.index++]);e.ballastFactor=u[0],e.fileGenerationType=u[1],e.inputWatts=u[2];for(let t=0;t<e.numberOfHorizontalAngles;t++)e.candelaValues[t]=[];x(n,e.numberOfVerticalAngles,e.verticalAngles),x(n,e.numberOfHorizontalAngles,e.horizontalAngles);for(let t=0;t<e.numberOfHorizontalAngles;t++)x(n,e.numberOfVerticalAngles,e.candelaValues[t]);let f=-1;for(let t=0;t<e.numberOfHorizontalAngles;t++)for(let i=0;i<e.numberOfVerticalAngles;i++)e.candelaValues[t][i]*=e.candelaValues[t][i]*e.candelaMultiplier*e.ballastFactor*e.fileGenerationType,f=Math.max(f,e.candelaValues[t][i]);if(f>0)for(let t=0;t<e.numberOfHorizontalAngles;t++)for(let i=0;i<e.numberOfVerticalAngles;i++)e.candelaValues[t][i]/=f;const m=180,c=m*2,h=c*m,p=new Float32Array(c*m),g=e.horizontalAngles[0],d=e.horizontalAngles[e.numberOfHorizontalAngles-1];for(let t=0;t<h;t++){let i=t%c;const A=Math.floor(t/c);d-g!==0&&(i<g||i>=d)&&(i%=d*2,i>d&&(i=d*2-i)),p[A+i*m]=V(e,A,i)}return{width:c/2,height:1,data:p}}class N{constructor(){this.supportCascades=!1}loadCubeData(){throw".ies not supported in Cube."}loadData(a,s,n){const e=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),r=z(e);n(r.width,r.height,s.useMipMaps,!1,()=>{const u=s.getEngine();s.type=1,s.format=6,s._gammaSpace=!1,u._uploadDataToTextureDirectly(s,r.data)})}}export{N as _IESTextureLoader};
