var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aM as _,av as l,aP as q,e as u,aw as G,aI as w,de as J,aL as A,aJ as N,df as z,dg as Q,dh as W,di as H,bm as K,dj as U,dk as X,dl as Y,bA as Z,q as ee,dm as te,dn as se,dp as oe,bk as re,t as ne,dq as ae,dr as ce,ds as le,cm as ie,dt as fe,du as pe,bI as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-03b6134d.js";import{u as he}from"./index-0a53aaef.js";import{c as ye}from"./Component-3cb422ab.js";import"./postmen-9e6354af.js";import{I as ge}from"./IconPlus-99d7bb90.js";import{D as Pe,M as je}from"./Menu-62cee67e.js";import{c as B}from"./createReactComponent-fcd6848b.js";import{A as xe,a as Ee}from"./Accordion-b106eaf3.js";/**
 * @license @tabler/icons-react v3.24.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var Ce=B("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);/**
 * @license @tabler/icons-react v3.24.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var ke=B("outline","trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);function Ie(e){const{renameable:s,onDelete:o,removable:a,checkable:c,defaultChecked:r,onCheckedChange:t}=e;return l.jsxs(w,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[l.jsxs(w,{children:[c&&l.jsx(J,{style:{marginRight:"5px"},checked:r,onCheckedChange:t,onClick:n=>n.stopPropagation()}),l.jsx("span",{children:e.title})]}),l.jsxs(w,{gap:"xxs",children:[s&&l.jsx(A,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(Ce,{size:"14px"})}),a&&l.jsx(A,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(ke,{size:"14px"})})]})]})}const O={TonemappingEffect:"post-process.effects.tone-mapping.title",BloomEffect:"post-process.effects.bloom.title"};function ve(e){const{label:s,info:o,items:a=[],menuItems:c=[],onClickMenu:r,onDelete:t,addItemText:n="Add Item",defaultValue:f,onCheckedChange:p}=e,b=i=>()=>{t&&t(i)},P=_.useMemo(()=>a.length?a.map(i=>`${i.id}`):[],[a]),j=l.jsxs(q,{size:"sm",variant:"soft",css:{width:"100%",marginTop:"$1","& > svg":{marginRight:"$1"}},children:[l.jsx(ge,{size:"12px"}),String(u(n))]});return l.jsxs(G,{label:u(s),info:o,direction:"column",children:[a.length&&l.jsx(xe,{type:"multiple",defaultValue:f??P,"data-state":"closed",children:a.map(i=>l.jsx(Ee,{value:`${i.id}`,title:l.jsx(Ie,{title:u(O[i.name]),onDelete:b(i),removable:i.removable,renameable:i.renameable,checkable:i.checkable,defaultChecked:i.defaultChecked,onCheckedChange:I=>{p&&p(I,i)}}),arrow:!!i.children,children:i.children&&l.jsx(w,{direction:"column",children:i.children})},i.name))}),l.jsx(Pe,{trigger:j,children:c.map(i=>l.jsx(je,{name:u(O[i.name]),onClick:()=>{r&&r(i)}},i.id))})]})}const y={TonemappingEffect:{constructor:fe},BloomEffect:{constructor:pe,defaultValue:{intensity:1,dirtIntensity:1}}},d={highQualityFiltering:{label:"post-process.effects.bloom.high-quality-filtering.label",info:"post-process.effects.bloom.high-quality-filtering.info"},scatter:{label:"post-process.effects.bloom.scatter.label",info:"post-process.effects.bloom.scatter.info"},downScale:{label:"post-process.effects.bloom.down-scale.label",info:"post-process.effects.bloom.down-scale.info"},threshold:{label:"post-process.effects.bloom.threshold.label",info:"post-process.effects.bloom.threshold.info"},intensity:{label:"post-process.effects.bloom.intensity.label",info:"post-process.effects.bloom.intensity.info"},tint:{label:"post-process.effects.bloom.tint.label",info:"post-process.effects.bloom.tint.info"},dirtTexture:{label:"post-process.effects.bloom.dirt-texture.label",info:"post-process.effects.bloom.dirt-texture.info"},dirtIntensity:{label:"post-process.effects.bloom.dirt-intensity.label",info:"post-process.effects.bloom.dirt-intensity.info"},mode:{label:"post-process.effects.tone-mapping.mode.label",info:"post-process.effects.tone-mapping.mode.info"}},we=N(({item:e,effectIndex:s,effect:o,onParameterChange:a})=>{const{assetStore:c}=he();return o?l.jsx(l.Fragment,{children:e.parameters.map((r,t)=>{var b,P,j,i,I,F,M,S,V;const{name:n,value:f}=r,p=o[n];if(!(p instanceof z))return null;switch(p.constructor){case le:return l.jsx(ie,{label:u(((b=d[n])==null?void 0:b.label)??n),min:p.min,max:p.max,value:Number(f),dragStep:.01,onChange:m=>{a(s,t,m)}},t);case ae:return l.jsx(ce,{label:u(((P=d[n])==null?void 0:P.label)??n),value:!!f,onChange:m=>{a(s,t,m)}},t);case oe:return l.jsx(re,{label:u(((j=d[n])==null?void 0:j.label)??n),options:ne(p.enumType,void 0,m=>u(`post-process.effects.options.${m.toLocaleLowerCase()}`)),value:f,onChange:m=>{a(s,t,m)}},t);case te:return l.jsx(se,{label:u(((i=d[n])==null?void 0:i.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case Y:{const m=c.assets,v=m[(I=r.value)==null?void 0:I.refId],L=Object.values(m).filter(h=>h.getMetaConfig().type==="Texture"&&!h.isSubAsset);return l.jsx(Z,{label:u(((F=d[n])==null?void 0:F.label)??n),dropLayer:ee.Texture,assets:L,asset:v,value:v==null?void 0:v.name,placeholder:u("texture.select-texture"),onSelect:h=>{a(s,t,h.getCurrentRef())},onLocate:()=>{var h;c.selectAsset((h=r.value)==null?void 0:h.refId)},onDelete:()=>{a(s,t,null)}},t)}case U:return l.jsx(X,{label:u(((M=d[n])==null?void 0:M.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case H:return l.jsx(K,{label:u(((S=d[n])==null?void 0:S.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case Q:return l.jsx(W,{label:u(((V=d[n])==null?void 0:V.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);default:return null}})}):null}),De=N(({model:e,onModelChange:s})=>{const o=e.effects,a=r=>{const t=me(o);r(t),s==null||s("effects",t)},c=(r,t,n)=>{a(f=>{var b;const p=f[r];(b=p==null?void 0:p.parameters)!=null&&b[t]&&(p.parameters[t]={...p.parameters[t],value:n})})};return l.jsx(ve,{label:u("post-process.effects.title"),addItemText:u("post-process.effects.add"),menuItems:Object.keys(y).map(r=>({id:r,name:r})),onClickMenu:r=>{const t=r.name;a(n=>{n.some(f=>f.name===t)||n.push({name:t,enabled:!0,parameters:[]})})},onCheckedChange:(r,t)=>{a(n=>{const f=n[Number(t.id)];f&&(f.enabled=r)})},onDelete:r=>{a(t=>{t.splice(Number(r.id),1)})},items:o.map((r,t)=>{var p;const n=(p=y[r.name])==null?void 0:p.constructor,f=n?e.engineObject.getEffect(n):null;return{children:l.jsx(we,{item:r,effectIndex:t,effect:f,onParameterChange:c}),id:String(t),name:r.name,removable:!0,checkable:!0,defaultChecked:r.enabled}})})});function Te(e){return e==null||typeof e!="object"?e:"r"in e&&"g"in e&&"b"in e&&"a"in e?{r:e.r,g:e.g,b:e.b,a:e.a}:"x"in e&&"y"in e&&"z"in e&&"w"in e?{x:e.x,y:e.y,z:e.z,w:e.w}:"x"in e&&"y"in e&&"z"in e?{x:e.x,y:e.y,z:e.z}:"x"in e&&"y"in e?{x:e.x,y:e.y}:e}function ze(e,s,o){if(o.parameters.length>0)return;const a=y[e].defaultValue??{},c=[];for(const r in s){const t=s[r];if(!(t instanceof z))continue;const n=a[r];n!==void 0&&(t.value=n),c.push({name:r,value:Te(n??t.value)??null})}o.parameters=c}async function Fe(e,s,o){var a;if(o!=null&&o.refId){const c=await e.root.assetStore.getAssetByRef(o);s.value=(c==null?void 0:c.engineObject)??null;return}if((a=s.value)!=null&&a.copyFrom&&o&&typeof o=="object"){s.value.copyFrom(o);return}s.value=o}async function Me(e,s){const o=e.engineObject,a=new Set;for(let c=0;c<s.length;c++){const r=s[c],{name:t,enabled:n}=r;if(!y[t])continue;const f=y[t].constructor;a.add(f);let p=o.getEffect(f);if(p||(p=o.addEffect(f)),!!p){ze(t,p,r),p.enabled=n;for(let b=0;b<r.parameters.length;b++){const{name:P,value:j}=r.parameters[b],i=p[P];i instanceof z&&await Fe(e,i,j)}}}for(const c of Object.keys(y)){const r=y[c].constructor;a.has(r)||o.getEffect(r)&&o.removeEffect(r)}}function Se(e){return e.map(s=>{const o={$type:s.name,enabled:s.enabled};for(const a of s.parameters)o[a.name]={value:a.value};return o})}function Ve(e){return e.map(s=>{const o=s,{$type:a,enabled:c,...r}=o,t=Object.entries(r).map(([n,f])=>({name:n,value:f.value}));return{name:a,enabled:c??!0,parameters:t}})}var Ae=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,E=(e,s,o,a)=>{for(var c=a>1?void 0:a?Oe(s,o):s,r=e.length-1,t;r>=0;r--)(t=e[r])&&(c=(a?t(s,o,c):t(c))||c);return a&&c&&Ae(s,o,c),c};let g=class extends ue{constructor(s,o){super(s,o);x(this,"isGlobal",!0);x(this,"blendDistance",0);x(this,"priority",0);x(this,"layer",[T.Layer0]);x(this,"effects",[])}};E([C(),k({label:"post-process.global.title",info:"post-process.global.info",type:D.Toggle,bindPath:"isGlobal"})],g.prototype,"isGlobal",2);E([C(),k({label:"post-process.blend-distance.title",info:"post-process.blend-distance.info",type:D.Number,bindPath:"blendDistance",min:0,dragStep:.01,when:e=>!e.isGlobal})],g.prototype,"blendDistance",2);E([C(),k({label:"post-process.priority.title",info:"post-process.priority.info",type:D.Number,bindPath:"priority",dragStep:1})],g.prototype,"priority",2);E([C(be()),k({label:"post-process.layer.title",info:"post-process.layer.info",type:D.Select,...de([T.Nothing,T.Everything]),bindPath:"layer"})],g.prototype,"layer",2);E([C({onSerialize:Se,onDeserialize:Ve}),k({customComponent:De,onChange:async(e,s,o)=>{await Me(e,o)}})],g.prototype,"effects",2);g=E([ye({type:"PostProcess",componentsMenu:{label:"component.post-process.title"}})],g);export{g as P};
