@galacean/cli 2.0.0-alpha.26 → 2.0.0-alpha.27
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/dist/cli.bundle.cjs +671 -777
- package/dist/preview-client/_static/{Accordion-2cd014f1.js → Accordion-4afac60c.js} +1 -1
- package/dist/preview-client/_static/{AmbientLightAsset-be9e872c.js → AmbientLightAsset-3825f3bf.js} +2 -2
- package/dist/preview-client/_static/{AnimationClipAsset-d7b37af0.js → AnimationClipAsset-660ecb36.js} +1 -1
- package/dist/preview-client/_static/{AnimatorControllerAsset-2716497a.js → AnimatorControllerAsset-dcf11a9d.js} +1 -1
- package/dist/preview-client/_static/{AnimatorStore-883a28ad.js → AnimatorStore-aa58d85c.js} +1 -1
- package/dist/preview-client/_static/{AssetViewer-3847c058.js → AssetViewer-8338dfe1.js} +1 -1
- package/dist/preview-client/_static/{AudioAsset-c28f33ab.js → AudioAsset-6e607154.js} +1 -1
- package/dist/preview-client/_static/{AudioComponent-3d6c73ce.js → AudioComponent-b70cc31e.js} +1 -1
- package/dist/preview-client/_static/{Callout-e2a89f6f.js → Callout-155c30df.js} +1 -1
- package/dist/preview-client/_static/{CameraComponent-3dc63451.js → CameraComponent-76bc9102.js} +1 -1
- package/dist/preview-client/_static/{Component-0f881fc1.js → Component-398551a0.js} +1 -1
- package/dist/preview-client/_static/{DirectLight-96dbba47.js → DirectLight-50653e81.js} +1 -1
- package/dist/preview-client/_static/{FontAsset-d34b5378.js → FontAsset-dc385d41.js} +1 -1
- package/dist/preview-client/_static/{FormItemArray-b8cda1d2.js → FormItemArray-9ca61884.js} +1 -1
- package/dist/preview-client/_static/{GlTFAsset-5970e707.js → GlTFAsset-d2ee4f95.js} +1 -1
- package/dist/preview-client/_static/{IconPlus-def01e2b.js → IconPlus-b3ed4c04.js} +1 -1
- package/dist/preview-client/_static/{IconPointFilled-62d3c3b2.js → IconPointFilled-3ba6d082.js} +1 -1
- package/dist/preview-client/_static/{LightBaseComponent-d651a276.js → LightBaseComponent-4cfc9f48.js} +1 -1
- package/dist/preview-client/_static/{LottieAnimationComponent-f10dc558.js → LottieAnimationComponent-aeb555ea.js} +1 -1
- package/dist/preview-client/_static/{MarkdownAsset-b2a3fad5.js → MarkdownAsset-02477e7c.js} +1 -1
- package/dist/preview-client/_static/{MaterialAsset-5353c4cb.js → MaterialAsset-8f3b3302.js} +1 -1
- package/dist/preview-client/_static/{MaterialInspector-8d466d59.js → MaterialInspector-3fb471d9.js} +1 -1
- package/dist/preview-client/_static/{Menu-c8e6194b.js → Menu-36c201c0.js} +1 -1
- package/dist/preview-client/_static/{MeshAsset-c2bf60c5.js → MeshAsset-3ddf1ac6.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererBaseComponent-fde6b6a5.js → MeshRendererBaseComponent-cd8b743b.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererComponent-430774ef.js → MeshRendererComponent-17a7fc72.js} +1 -1
- package/dist/preview-client/_static/{MeshThumbnail-07ffa076.js → MeshThumbnail-8c20ee92.js} +1 -1
- package/dist/preview-client/_static/{ParticleRendererComponent-e106bd8c.js → ParticleRendererComponent-1834a159.js} +3 -3
- package/dist/preview-client/_static/{PhysicsMaterialAsset-a2f73b5c.js → PhysicsMaterialAsset-e0491877.js} +1 -1
- package/dist/preview-client/_static/{PhysicsStore-818c2f61.js → PhysicsStore-ab32886e.js} +1 -1
- package/dist/preview-client/_static/{PointLight-add790ea.js → PointLight-97975350.js} +1 -1
- package/dist/preview-client/_static/{PostProcessComponent-af270a77.js → PostProcessComponent-9590ec29.js} +1 -1
- package/dist/preview-client/_static/PrefabAsset-2f94de73.js +1 -0
- package/dist/preview-client/_static/{PrimitiveMesh-075dda8a.js → PrimitiveMesh-0492d482.js} +1 -1
- package/dist/preview-client/_static/{ReferencedMaterial-d11151b5.js → ReferencedMaterial-49a7cbcc.js} +1 -1
- package/dist/preview-client/_static/{RenderTargetAsset-b3cd1c49.js → RenderTargetAsset-dc1f9494.js} +1 -1
- package/dist/preview-client/_static/{SceneAsset-08752701.js → SceneAsset-c3bb667f.js} +1 -1
- package/dist/preview-client/_static/{ShaderAsset-a9d667f5.js → ShaderAsset-f4eead79.js} +12 -12
- package/dist/preview-client/_static/{ShaderChunkAsset-e43dde8a.js → ShaderChunkAsset-4bea2733.js} +2 -2
- package/dist/preview-client/_static/{ShaderUIScriptAsset-e1cd0b8b.js → ShaderUIScriptAsset-3c731f3b.js} +2 -2
- package/dist/preview-client/_static/{SkinnedMeshRendererComponent-9756bd5f.js → SkinnedMeshRendererComponent-e0f9b133.js} +1 -1
- package/dist/preview-client/_static/{SpineAnimationComponent-f3e0ff44.js → SpineAnimationComponent-1e1655fd.js} +1 -1
- package/dist/preview-client/_static/{SpineSkeletonDataAsset-43b731f1.js → SpineSkeletonDataAsset-afb4afae.js} +1 -1
- package/dist/preview-client/_static/{SpotLight-649b0e21.js → SpotLight-69f361c9.js} +1 -1
- package/dist/preview-client/_static/{SpriteBaseComponent-d2a7ab4c.js → SpriteBaseComponent-2c2454ea.js} +1 -1
- package/dist/preview-client/_static/{SpriteMaskComponent-2c1cef5e.js → SpriteMaskComponent-a7ebcc50.js} +1 -1
- package/dist/preview-client/_static/{SpriteRendererComponent-33b71997.js → SpriteRendererComponent-f7604c68.js} +1 -1
- package/dist/preview-client/_static/{TextBaseComponent-9310e0c6.js → TextBaseComponent-cd7ad9f7.js} +1 -1
- package/dist/preview-client/_static/{TextRendererComponent-8dc0d7fb.js → TextRendererComponent-a5357d52.js} +1 -1
- package/dist/preview-client/_static/{TextureAsset-a7ff39b1.js → TextureAsset-ff089b5a.js} +1 -1
- package/dist/preview-client/_static/{Tooltip-b5be390f.js → Tooltip-1bcb87b5.js} +1 -1
- package/dist/preview-client/_static/{TrailRendererComponent-c4635fab.js → TrailRendererComponent-cdefa368.js} +1 -1
- package/dist/preview-client/_static/{TransformBaseComponent-1473deaa.js → TransformBaseComponent-d26ff236.js} +1 -1
- package/dist/preview-client/_static/{TransformComponent-e544f7ac.js → TransformComponent-4ec4b7b5.js} +1 -1
- package/dist/preview-client/_static/{XRReferenceImageAsset-96f516ba.js → XRReferenceImageAsset-ff82ab30.js} +1 -1
- package/dist/preview-client/_static/{audio-b5fbde34.js → audio-0a013eb6.js} +1 -1
- package/dist/preview-client/_static/{createOnModelChange-370b83da.js → createOnModelChange-89f572a6.js} +1 -1
- package/dist/preview-client/_static/{createReactComponent-58d9f0dd.js → createReactComponent-baa41397.js} +1 -1
- package/dist/preview-client/_static/index-0086cabc.js +1 -0
- package/dist/preview-client/_static/index-253f9e13.js +1 -0
- package/dist/preview-client/_static/{index-da16047f.js → index-29916a80.js} +1 -1
- package/dist/preview-client/_static/{index-ab8556cb.js → index-4845b67c.js} +3 -3
- package/dist/preview-client/_static/{index-dd0763bf.js → index-5e4dedda.js} +1 -1
- package/dist/preview-client/_static/{index-0dd5bb36.js → index-70967035.js} +1 -1
- package/dist/preview-client/_static/index-8234e4e2.js +1 -0
- package/dist/preview-client/_static/{index-88650db7.js → index-8784a43a.js} +1 -1
- package/dist/preview-client/_static/index-94594d06.js +1 -0
- package/dist/preview-client/_static/{index-74bcfad9.js → index-a0afef01.js} +1 -1
- package/dist/preview-client/_static/index-ad57c6c8.js +1 -0
- package/dist/preview-client/_static/{index-c3dec278.js → index-b126bb6b.js} +72 -72
- package/dist/preview-client/_static/{index-cdbb2f4d.js → index-c8ed2a45.js} +1 -1
- package/dist/preview-client/_static/{index-05b76766.js → index-cd09e78a.js} +1 -1
- package/dist/preview-client/_static/index-d1484803.js +1 -0
- package/dist/preview-client/_static/index-f7fcda86.js +1 -0
- package/dist/preview-client/_static/{ktx2-encoder-db93524f.js → ktx2-encoder-8498815e.js} +1 -1
- package/dist/preview-client/_static/{module-ada3dced.js → module-113ac03a.js} +1 -1
- package/dist/preview-client/_static/{module-ec094ef6.js → module-83a57161.js} +1 -1
- package/dist/preview-client/_static/{module-de7ee724.js → module-8efda49c.js} +1 -1
- package/dist/preview-client/_static/{postmen-2853c0e6.js → postmen-3b48c572.js} +2 -2
- package/dist/preview-client/_static/{shader-data-utils-f0e4f5a3.js → shader-data-utils-c90e48b8.js} +1 -1
- package/dist/preview-client/index.html +1 -1
- package/package.json +29 -24
- package/dist/preview-client/_static/PrefabAsset-59743dbb.js +0 -1
- package/dist/preview-client/_static/index-29c59aff.js +0 -1
- package/dist/preview-client/_static/index-3680d0e0.js +0 -1
- package/dist/preview-client/_static/index-42aa3a49.js +0 -1
- package/dist/preview-client/_static/index-496f331d.js +0 -1
- package/dist/preview-client/_static/index-9f0122f0.js +0 -1
- package/dist/preview-client/_static/index-c6b7045c.js +0 -1
- package/dist/preview-client/_static/index-dddcae01.js +0 -1
package/dist/preview-client/_static/{ShaderChunkAsset-e43dde8a.js → ShaderChunkAsset-4bea2733.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ni=Object.defineProperty;var ai=(n,e,t)=>e in n?ni(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(ai(n,typeof e!="symbol"?e+"":e,t),t);import{aJ as ut,aM as b,av as y,aO as ve,bz as ri,aI as tt,
|
|
1
|
+
var ni=Object.defineProperty;var ai=(n,e,t)=>e in n?ni(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(ai(n,typeof e!="symbol"?e+"":e,t),t);import{aJ as ut,aM as b,av as y,aO as ve,bz as ri,aI as tt,gb as oi,cm as li,N as Nt,W as ci,aH as it,aK as Rt,ai as Ht,a_ as Fe,by as pi,a$ as hi,gu as ui,b3 as di,cp as fi,di as ke,f6 as gi,aL as mi,eY as yi,e as P,bA as jt,q as et,ay as wi,aP as _t,F as De,j as ot,gv as be,$ as xi,K as Ee,C as R,bV as Pt,aA as vi,p as M,m as E,f as bi,v as Si,aC as Bt,n as Ct,o as Mt,bR as Le,c8 as Ii,bZ as gt,bY as Se,gw as Ri,bk as Ci,dl as _i,es as Ie,ad as Q,T as D,gx as Re,s as Pi,f8 as Wt,aN as Mi,bX as Jt,b_ as Gt,u as $e,S as Ti,x as yt,aT as dt,bW as Ai,dY as pt,ae as ji,dZ as Bi,d_ as Oi}from"./index-b126bb6b.js";import{L as Zt}from"./module-83a57161.js";import{u as re,F as Qt,r as te}from"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{c as Ne}from"./createReactComponent-baa41397.js";import{I as ze}from"./IconPlus-b3ed4c04.js";import{A as Ue}from"./AssetViewer-8338dfe1.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Fi}from"./bundlers-9b0d37fc.js";import{b as Ve,a as qe,c as ki}from"./TextureAsset-ff089b5a.js";import"./GlTFAsset-d2ee4f95.js";import"./MaterialAsset-8f3b3302.js";import"./MeshAsset-3ddf1ac6.js";import"./AnimatorControllerAsset-dcf11a9d.js";import"./AnimationClipAsset-660ecb36.js";import"./AmbientLightAsset-3825f3bf.js";import{L as Di}from"./module-113ac03a.js";import{s as Ei}from"./SpineSkeletonDataAsset-afb4afae.js";import"./FontAsset-dc385d41.js";import"./SceneAsset-c3bb667f.js";import"./ShaderAsset-f4eead79.js";import{l as Li}from"./ShaderUIScriptAsset-3c731f3b.js";import"./PrimitiveMesh-0492d482.js";import"./XRReferenceImageAsset-ff82ab30.js";import"./PrefabAsset-2f94de73.js";import"./PhysicsMaterialAsset-e0491877.js";import"./RenderTargetAsset-dc1f9494.js";import"./AudioAsset-6e607154.js";import"./index-29916a80.js";import"./MarkdownAsset-02477e7c.js";import{F as He}from"./FormItemArray-9ca61884.js";import{F as Kt}from"./index-cd09e78a.js";function $i(n,e){const t={};for(let i=0;i<n.length;i++){const s=n[i],a=e(s);Object.hasOwn(t,a)||(t[a]=[]),t[a].push(s)}return t}function Ni(n,e){const t=[],i=[];for(let s=0;s<n.length;s++){const a=n[s];e(a)?t.push(a):i.push(a)}return[t,i]}function zi(n,e){const t=new Map;for(let i=0;i<n.length;i++){const s=n[i],a=e(s);t.has(a)||t.set(a,s)}return Array.from(t.values())}/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -8,7 +8,7 @@ var ni=Object.defineProperty;var ai=(n,e,t)=>e in n?ni(n,e,{enumerable:!0,config
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the MIT license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var Vi=Ne("outline","minus","IconMinus",[["path",{d:"M5 12l14 0",key:"svg-0"}]]);const qi=ut(function(n){const[e,t]=b.useState(null),i=n.asset,{assetStore:s,inspectorFacade:a}=re(),r=(o,l,h)=>{a.assetChange(o,l,h)};return b.useEffect(()=>{s.getAssetByRef(i.texture).then(o=>{t(o)})},[i.texture]),y.jsxs(y.Fragment,{children:[y.jsx(ve.List,{model:i,configs:i.formSchema.items,onModelChange:(o,l)=>r(i.id,o,l)}),e&&y.jsxs(y.Fragment,{children:[y.jsx(ri,{}),y.jsx(tt,{justifyContent:"between",css:{padding:"$2 0"},children:y.jsx(oi,{children:"Texture Option"})}),y.jsx(li,{label:"Name",value:e.name,readOnly:!0}),y.jsx(ve.List,{model:e,configs:e.formSchema.items,onModelChange:(o,l)=>r(e.id,o,l)})]})]})});class ee{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.spriteRenderer.sprite=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("sprite");this.spriteRenderer=t.addComponent(Nt)}}d(ee,"entity"),d(ee,"spriteRenderer");class Wi extends Ue{constructor(){super()}setViewAsset(e,t){const i=t.createChild("sprite_entity"),s=i.addComponent(Nt);s.sprite=e.engineObject,this._entity=i}getDescription(e){var i;const t=(i=e.engineObject)==null?void 0:i.texture;if(t){const{width:s,height:a}=t;return`${s}x${a}`}else return""}}const at=1,Hi=220,Ji=180,Xt=ci._pixelsPerUnit??100,Gi={left:"x",bottom:"y",right:"z",top:"w"},Ki={left:{axis:"x",fromStart:!0},right:{axis:"x",fromStart:!1},top:{axis:"y",fromStart:!0},bottom:{axis:"y",fromStart:!1}},Xi=[["left","right"],["top","bottom"]],Yi={left:"width",right:"width",top:"height",bottom:"height"},Zi={left:"right",right:"left",top:"bottom",bottom:"top"},Qi=it(tt,{width:"220px"}),ts=it("div",{position:"relative",width:"100%",height:"180px",borderRadius:"$2",border:"1px solid $gray6",overflow:"hidden",backgroundImage:"linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"}),es=it("div",{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",border:"1px solid $gray9",background:"linear-gradient(135deg, rgba(76, 132, 255, 0.26) 0%, rgba(76, 132, 255, 0.08) 48%, rgba(76, 132, 255, 0.2) 100%)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.2)"}),is=it("canvas",{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",pointerEvents:"none"}),ss=it("div",{position:"absolute",borderRadius:"$1",backgroundColor:"rgba(126, 211, 129, 0.1)",pointerEvents:"none"}),Ce=it("div",{position:"absolute",top:0,bottom:0,width:"10px",marginLeft:"-5px",cursor:"ew-resize","&::before":{content:'""',position:"absolute",left:"50%",top:0,bottom:0,borderLeft:"1px dashed $blue9"}}),_e=it("div",{position:"absolute",left:0,right:0,height:"10px",marginTop:"-5px",cursor:"ns-resize","&::before":{content:'""',position:"absolute",top:"50%",left:0,right:0,borderTop:"1px dashed $blue9"}}),ns={flex:1,minWidth:0};function Z(n,e,t){return Math.min(t,Math.max(e,n))}function ht(n,e=2){const t=Math.pow(10,e);return Math.round(n*t)/t}function mt(n,e=0){return Number.isFinite(n)?n:e}function $t(n,e,t,i){return n=Z(mt(n),0,t),e=Z(mt(e),0,t),n+e>t&&(i?e=t-n:n=t-e),[n,e]}function Lt(n,e){const[t,i]=$t(n.x,n.z,1,e==="x"),[s,a]=$t(n.y,n.w,1,e==="y");return{x:ht(t,2),y:ht(s,2),z:ht(i,2),w:ht(a,2)}}function oe(n,e,t,i){const s=Math.max(at,Math.round(mt(e,at))),a=Math.max(at,Math.round(mt(t,at))),[r,o]=$t(n.left,n.right,s,i==="left"),[l,h]=$t(n.top,n.bottom,a,i==="top");return{left:Math.round(r),bottom:Math.round(h),right:Math.round(o),top:Math.round(l)}}function Pe(n,e,t){const i=Lt(n);return oe({left:i.x*e,bottom:i.y*t,right:i.z*e,top:i.w*t},e,t)}function as(n,e,t){const i=oe(n,e,t),s=Math.max(at,e),a=Math.max(at,t),r=ht(Z(i.left/s,0,1),2),o=ht(Z(i.bottom/a,0,1),2),l=ht(Z(i.right/s,0,1-r),2),h=ht(Z(i.top/a,0,1-o),2);return{x:r,y:o,z:l,w:h}}function rs(n,e,t,i){const a=Math.max(1,mt(t,1)),r=Math.max(1,mt(i,1)),o=Math.max(1,n-16*2),l=Math.max(1,e-16*2),h=Math.min(o,l),p=Math.max(a,r),u=h/p;return{width:Math.max(1,a*u),height:Math.max(1,r*u)}}function os(n,e=!0){const[t,i]=b.useState({width:0,height:0});return b.useLayoutEffect(()=>{if(!e){i({width:0,height:0});return}const s=n.current;if(!s)return;const a=()=>{i({width:s.clientWidth,height:s.clientHeight})};a();const r=new ResizeObserver(a);return r.observe(s),()=>{r.disconnect()}},[n,e]),t}const ls=ut(function(e){var de,fe,ge,me,ye,we;const{model:t,inspectorConfig:i,onModelChange:s}=e,{property:a,disabled:r,label:o,info:l}=i,{t:h}=Rt();if(!t||!a)return null;const p={width:t.engineObject.width*Xt,height:t.engineObject.height*Xt},u=Lt(t[a]??{x:0,y:0,z:0,w:0}),c=Pe(u,p.width,p.height),f=b.useRef(null),g=b.useRef(null),v=b.useRef(null),x=b.useRef(null),w=b.useRef(null),S=b.useRef(null),T=b.useRef(!1),k=b.useRef(!1),A=b.useRef(!1),lt=b.useRef(new Wt),z=b.useRef(new Wt),xt=b.useRef(new Wt),[ct,vt]=b.useState(!1),[nt,X]=b.useState(null),O=os(f,ct),L=b.useMemo(()=>({width:O.width>0?O.width:Hi,height:O.height>0?O.height:Ji}),[O.height,O.width]);A.current=ct;const B=b.useMemo(()=>rs(L.width,L.height,p.width,p.height),[p.height,p.width,L.height,L.width]),$=b.useMemo(()=>({left:Z(c.left/Math.max(p.width,at),0,1),bottom:Z(c.bottom/Math.max(p.height,at),0,1),right:Z(c.right/Math.max(p.width,at),0,1),top:Z(c.top/Math.max(p.height,at),0,1)}),[c.bottom,c.left,c.right,c.top,p.height,p.width]),Y=b.useCallback((m=!1)=>{if(S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),T.current=!1,k.current=!1,!m)return;const I=w.current,C=x.current;if(C){const _=(I==null?void 0:I.canvasCtx)??C.getContext("2d");_==null||_.clearRect(0,0,C.width,C.height)}},[]),Ot=b.useCallback(()=>{Y();const m=w.current;if(m){if(m.renderTarget){const I=m.renderTarget.getColorTexture(0);I==null||I.destroy(!0),m.renderTarget.destroy(!0),m.renderTarget=null}try{t.engine.sceneManager.removeScene(m.scene)}catch{}m.scene.destroy(),w.current=null,Y(!0)}},[t.engine,Y]),ce=b.useCallback(()=>{const m=w.current,I=x.current;if(!m||!I)return!1;const C=window.devicePixelRatio||1,_=Math.round(B.width*C),j=Math.round(B.height*C);if(_<=0||j<=0)return!1;if((I.width!==_||I.height!==j)&&(I.width=_,I.height=j),m.renderTarget&&m.renderTarget.width===_&&m.renderTarget.height===j)return m.camera.aspectRatio=_/j,!0;if(m.renderTarget){const bt=m.renderTarget.getColorTexture(0);bt==null||bt.destroy(!0),m.renderTarget.destroy(!0)}const J=new Fe(t.engine,_,j,void 0,!1),rt=new pi(t.engine,_,j,J,hi.Depth,4),qt=new ImageData(new Uint8ClampedArray(_*j*4),_,j);return m.renderTarget=rt,m.imageData=qt,m.camera.aspectRatio=_/j,m.camera.renderTarget=rt,!0},[B.height,B.width,t.engine]),pe=b.useCallback(()=>{const m=w.current;if(!m||!m.spriteRenderer.sprite)return;const I=m.spriteRenderer.bounds,C=lt.current,_=z.current;I.getCenter(C),I.getExtent(_);const j=m.camera.aspectRatio>0?m.camera.aspectRatio:1,J=Math.max(_.x,p.width*.5,.5),rt=Math.max(_.y,p.height*.5,.5);m.camera.isOrthographic=!0,m.camera.orthographicSize=Math.max(rt,J/j)/Xt,m.camera.nearClipPlane=.1,m.camera.farClipPlane=100,m.cameraEntity.transform.setPosition(C.x,C.y,10),xt.current.set(C.x,C.y,0),m.cameraEntity.transform.lookAt(xt.current)},[p.height,p.width]),he=b.useCallback(()=>{const m=w.current,I=x.current;if(!m||!m.renderTarget||!m.imageData||!I)return;const C=t.engine;if(k.current)return;k.current=!0;try{m.camera.renderTarget=m.renderTarget,C.sceneManager.addScene(m.scene),C.update()}finally{try{C.sceneManager.removeScene(m.scene)}catch{}k.current=!1}m.renderTarget.getColorTexture(0).getPixelBuffer(0,0,m.renderTarget.width,m.renderTarget.height,0,m.imageData.data);const j=m.canvasCtx??I.getContext("2d");j==null||j.putImageData(m.imageData,0,0)},[t.engine]),Ft=b.useCallback(()=>{if(w.current)return;const m=x.current;if(!m)return;const I=new ui(t.engine);I.background.solidColor=new di(0,0,0,0);const C=I.createRootEntity("sprite_border_preview_root"),_=C.createChild("sprite_border_preview_camera"),j=_.addComponent(fi),rt=C.createChild("sprite_border_preview_sprite").addComponent(Nt);rt.sprite=t.engineObject??null,w.current={scene:I,camera:j,cameraEntity:_,spriteRenderer:rt,renderTarget:null,imageData:null,canvasCtx:m.getContext("2d")}},[t.engine,t.engineObject]),ue=b.useCallback(()=>{T.current||(T.current=!0,S.current=requestAnimationFrame(()=>{if(T.current=!1,S.current=null,!A.current)return;w.current||Ft();const m=w.current;m&&(m.spriteRenderer.sprite=t.engineObject??null),ce()&&(pe(),he())}))},[ce,pe,Ft,t.engineObject,he]),kt=b.useCallback((m,I)=>{const C=oe(m,p.width,p.height,I),_=as(C,p.width,p.height);t[a]=_;const j=I?Gi[I]:void 0;s==null||s(a,_,j)},[t,s,a,p.height,p.width]),Ke=b.useCallback((m,I)=>{const C=Lt(m,I);t[a]=C,s==null||s(a,C,I)},[t,s,a]),Xe=b.useCallback((m,I)=>{kt({...c,[m]:mt(I,0)},m)},[c,kt]),Dt=b.useMemo(()=>{const m=I=>C=>{C.preventDefault();const _=g.current,j=document.activeElement;_&&j instanceof HTMLElement&&_.contains(j)&&j.blur(),X(I)};return{left:m("left"),right:m("right"),top:m("top"),bottom:m("bottom")}},[]);b.useEffect(()=>{if(!nt)return;const m=Ki[nt],I=_=>{const j=v.current;if(!j)return;const J=j.getBoundingClientRect();if(J.width<=0||J.height<=0)return;const rt=Lt(t[a]??{x:0,y:0,z:0,w:0}),qt=Pe(rt,p.width,p.height),bt=m.axis==="x"?_.clientX:_.clientY,ti=m.axis==="x"?J.left:J.top,ei=m.axis==="x"?J.right:J.bottom,xe=m.axis==="x"?J.width:J.height,ii=m.axis==="x"?p.width:p.height,si=Z(m.fromStart?(bt-ti)/xe:(ei-bt)/xe,0,1);kt({...qt,[nt]:si*ii},nt)},C=()=>{X(null)};return window.addEventListener("mousemove",I),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",C)}},[kt,nt,t,a,p.height,p.width]),b.useEffect(()=>{if(!ct){Ot();return}w.current||Ft();const m=w.current;m&&(m.spriteRenderer.sprite=t.engineObject??null),ue()},[Ot,Ft,ct,ue,B.height,B.width,t.engineObject,t.height,(de=t.pivot)==null?void 0:de.x,(fe=t.pivot)==null?void 0:fe.y,(ge=t.region)==null?void 0:ge.height,(me=t.region)==null?void 0:me.width,(ye=t.region)==null?void 0:ye.x,(we=t.region)==null?void 0:we.y,t.width]),b.useEffect(()=>()=>{Ot()},[Ot]);const Ye=typeof o=="string"?h(o):o,Ze=typeof l=="string"?h(l):l,Qe=b.useMemo(()=>({x:"L",y:"B",z:"R",w:"T"}),[]);return y.jsx(ke,{disabled:r,label:Ye,info:Ze,min:0,max:1,step:.01,dragStep:.01,value:u,slotMapping:Qe,onChange:Ke,formEndSlot:y.jsx(gi,{disabled:r,side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:m=>m.preventDefault(),onOpenChange:m=>{vt(m),m||X(null)},trigger:y.jsx(mi,{variant:"subtle",corner:!0,disabled:r,children:y.jsx(Ui,{size:14})}),children:y.jsxs(Qi,{ref:g,direction:"column",gap:"sm",children:[y.jsx(ts,{ref:f,children:y.jsxs(es,{ref:v,css:{width:`${B.width}px`,height:`${B.height}px`},children:[y.jsx(is,{ref:x}),y.jsx(ss,{css:{left:`${$.left*100}%`,right:`${$.right*100}%`,top:`${$.top*100}%`,bottom:`${$.bottom*100}%`}}),y.jsx(Ce,{onMouseDown:Dt.left,css:{left:`${$.left*100}%`}}),y.jsx(Ce,{onMouseDown:Dt.right,css:{left:`${(1-$.right)*100}%`}}),y.jsx(_e,{onMouseDown:Dt.top,css:{top:`${$.top*100}%`}}),y.jsx(_e,{onMouseDown:Dt.bottom,css:{top:`${(1-$.bottom)*100}%`}})]})}),y.jsx(tt,{direction:"column",gap:"xs",css:{width:"100%"},children:Xi.map(([m,I])=>y.jsx(tt,{gap:"sm",align:"v",children:[m,I].map(C=>y.jsx(tt,{direction:"column",css:ns,children:y.jsx(yi,{min:0,max:Math.max(0,p[Yi[C]]-c[Zi[C]]),dragStep:1,step:1,value:c[C],startSlot:C[0].toUpperCase(),endSlot:"px",onValueChange:_=>Xe(C,_)})},C))},m))})]})})})});class q{constructor(e=0,t=0,i=0,s=0,a=""){d(this,"x",0);d(this,"y",0);d(this,"width",0);d(this,"height",0);d(this,"name","");d(this,"isRotated",!1);d(this,"allowRotate");this.x=e,this.y=t,this.width=i,this.height=s,this.name=a}clone(){return new q(this.x,this.y,this.width,this.height,`${this.name}-clone`)}isContainedIn(e){return this.x>=e.x&&this.y>=e.y&&this.x+this.width<=e.x+e.width&&this.y+this.height<=e.y+e.height}static isContainedIn(e,t){return e.isContainedIn(t)}}var W=(n=>(n[n.BestShortSideFit=0]="BestShortSideFit",n[n.BestLongSideFit=1]="BestLongSideFit",n[n.BestAreaFit=2]="BestAreaFit",n[n.BottomLeftRule=3]="BottomLeftRule",n[n.ContactPointRule=4]="ContactPointRule",n))(W||{});class cs{constructor(){d(this,"binWidth");d(this,"binHeight");d(this,"allowRotate");d(this,"usedRectangles");d(this,"freeRectangles");this.binWidth=0,this.binHeight=0,this.allowRotate=!1,this.usedRectangles=[],this.freeRectangles=[]}init(e,t,i){this.binWidth=e,this.binHeight=t,this.allowRotate=i||!1,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(new q(0,0,e,t))}insert(e,t,i){let s=new q;const a={value:0},r={value:0},o=i||0,l=this.allowRotate;if(!this._canFit(e,t,l))return s;switch(o){case W.BestShortSideFit:s=this._findPositionForNewNodeBestShortSideFit(e,t,a,r,l);break;case W.BottomLeftRule:s=this._findPositionForNewNodeBottomLeft(e,t,a,r,l);break;case W.ContactPointRule:s=this._findPositionForNewNodeContactPoint(e,t,a,l);break;case W.BestLongSideFit:s=this._findPositionForNewNodeBestLongSideFit(e,t,r,a,l);break;case W.BestAreaFit:s=this._findPositionForNewNodeBestAreaFit(e,t,a,r,l);break}return s.height===0||this._placeRectangle(s),s}insert2(e,t){const i=[],s=t||0;for(;e.length>0;){let a=1/0,r=1/0,o=-1,l=new q,h=-1/0;for(let u=0;u<e.length;u++){const c=e[u],f=this._getAllowRotate(c);if(!this._canFit(c.width,c.height,f))continue;const g={value:0},v={value:0},x=this._scoreRectangle(c.width,c.height,s,g,v,f),w=this._getSortKey(c,s);g.value<a||g.value===a&&v.value<r?(a=g.value,r=v.value,l=x,o=u,h=w):o!==-1&&g.value!==1/0&&v.value!==1/0&&g.value===a&&v.value===r&&w>h&&(l=x,o=u,h=w)}if(o===-1)return i;this._placeRectangle(l);const p=e.splice(o,1)[0];p.x=l.x,p.y=l.y,p.isRotated=l.isRotated,i.push(p)}return i}_placeRectangle(e){let t=this.freeRectangles.length;for(let i=0;i<t;i++)this._splitFreeNode(this.freeRectangles[i],e)&&(this.freeRectangles.splice(i,1),i--,t--);this._purgeFreeList(),this._pruneFreeList(),this.usedRectangles.push(e)}_scoreRectangle(e,t,i,s,a,r){let o=new q;switch(s.value=1/0,a.value=1/0,i){case W.BestShortSideFit:o=this._findPositionForNewNodeBestShortSideFit(e,t,s,a,r);break;case W.BottomLeftRule:o=this._findPositionForNewNodeBottomLeft(e,t,s,a,r);break;case W.ContactPointRule:o=this._findPositionForNewNodeContactPoint(e,t,s,r),s.value=-s.value;break;case W.BestLongSideFit:o=this._findPositionForNewNodeBestLongSideFit(e,t,a,s,r);break;case W.BestAreaFit:o=this._findPositionForNewNodeBestAreaFit(e,t,s,a,r);break}return o.height===0&&(s.value=1/0,a.value=1/0),o}_findPositionForNewNodeBottomLeft(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0,s.value=1/0;let l,h;for(let p=0;p<r.length;p++)l=r[p],l.width>=e&&l.height>=t&&(h=l.y+t,(h<i.value||h===i.value&&l.x<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=h,s.value=l.x)),a&&l.width>=t&&l.height>=e&&(h=l.y+e,(h<i.value||h===i.value&&l.x<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=h,s.value=l.x));return o}_findPositionForNewNodeBestShortSideFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)if(l=r[f],l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),c=Math.max(h,p),(u<i.value||u===i.value&&c<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=u,s.value=c)),a&&l.width>=t&&l.height>=e){const g=Math.abs(l.width-t),v=Math.abs(l.height-e),x=Math.min(g,v),w=Math.max(g,v);(x<i.value||x===i.value&&w<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=x,s.value=w)}return o}_findPositionForNewNodeBestLongSideFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;s.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)l=r[f],l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),c=Math.max(h,p),(c<s.value||c===s.value&&u<i.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=u,s.value=c)),a&&l.width>=t&&l.height>=e&&(h=Math.abs(l.width-t),p=Math.abs(l.height-e),u=Math.min(h,p),c=Math.max(h,p),(c<s.value||c===s.value&&u<i.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=u,s.value=c));return o}_findPositionForNewNodeBestAreaFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)l=r[f],c=l.width*l.height-e*t,l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),(c<i.value||c===i.value&&u<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,s.value=u,i.value=c)),a&&l.width>=t&&l.height>=e&&(h=Math.abs(l.width-t),p=Math.abs(l.height-e),u=Math.min(h,p),(c<i.value||c===i.value&&u<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,s.value=u,i.value=c));return o}_commonIntervalLength(e,t,i,s){return t<i||s<e?0:Math.min(t,s)-Math.max(e,i)}_contactPointScoreNode(e,t,i,s){const a=this.usedRectangles;let r=0;(e===0||e+i===this.binWidth)&&(r+=s),(t===0||t+s===this.binHeight)&&(r+=i);let o;for(let l=0;l<a.length;l++)o=a[l],(o.x===e+i||o.x+o.width===e)&&(r+=this._commonIntervalLength(o.y,o.y+o.height,t,t+s)),(o.y===t+s||o.y+o.height===t)&&(r+=this._commonIntervalLength(o.x,o.x+o.width,e,e+i));return r}_findPositionForNewNodeContactPoint(e,t,i,s){const a=this.freeRectangles,r=new q;i.value=-1;let o,l;for(let h=0;h<a.length;h++)o=a[h],o.width>=e&&o.height>=t&&(l=this._contactPointScoreNode(o.x,o.y,e,t),l>i.value&&(r.x=o.x,r.y=o.y,r.width=e,r.height=t,r.isRotated=!1,i.value=l)),s&&o.width>=t&&o.height>=e&&(l=this._contactPointScoreNode(o.x,o.y,t,e),l>i.value&&(r.x=o.x,r.y=o.y,r.width=t,r.height=e,r.isRotated=!0,i.value=l));return r}_splitFreeNode(e,t){const i=this.freeRectangles;if(t.x>=e.x+e.width||t.x+t.width<=e.x||t.y>=e.y+e.height||t.y+t.height<=e.y)return!1;let s;return t.x<e.x+e.width&&t.x+t.width>e.x&&(t.y>e.y&&t.y<e.y+e.height&&(s=e.clone(),s.height=t.y-s.y,s.width>0&&s.height>0&&i.push(s)),t.y+t.height<e.y+e.height&&(s=e.clone(),s.y=t.y+t.height,s.height=e.y+e.height-(t.y+t.height),s.width>0&&s.height>0&&i.push(s))),t.y<e.y+e.height&&t.y+t.height>e.y&&(t.x>e.x&&t.x<e.x+e.width&&(s=e.clone(),s.width=t.x-s.x,s.width>0&&s.height>0&&i.push(s)),t.x+t.width<e.x+e.width&&(s=e.clone(),s.x=t.x+t.width,s.width=e.x+e.width-(t.x+t.width),s.width>0&&s.height>0&&i.push(s))),!0}_pruneFreeList(){const e=this.freeRectangles;let t=0;for(;t<e.length;){let i=t+1;const s=e[t];for(;i<e.length;){const a=e[i];if(q.isContainedIn(s,a)){e.splice(t,1),t--;break}q.isContainedIn(a,s)&&(e.splice(i,1),i--),i++}t++}}_purgeFreeList(){const e=this.freeRectangles;for(let t=e.length-1;t>=0;t--){const i=e[t];(i.width<=0||i.height<=0)&&e.splice(t,1)}}_canFit(e,t,i){return!!(e<=this.binWidth&&t<=this.binHeight||i&&t<=this.binWidth&&e<=this.binHeight)}_getAllowRotate(e){return typeof e.allowRotate=="boolean"?e.allowRotate:this.allowRotate}_getSortKey(e,t){return t===W.BestAreaFit?e.width*e.height:Math.max(e.width,e.height)}}var F=(n=>(n[n.Success=0]="Success",n[n.NoImage=1]="NoImage",n[n.ImageLoadError=2]="ImageLoadError",n[n.OffscreenBlobError=3]="OffscreenBlobError",n[n.CanvasBlobError=4]="CanvasBlobError",n[n.PackError=5]="PackError",n))(F||{});class ps{constructor(){d(this,"mipmap");d(this,"wrapModeV");d(this,"wrapModeU");d(this,"filterMode");d(this,"anisoLevel");d(this,"version",0);d(this,"format",1);d(this,"atlasItems",[])}}class hs{constructor(){d(this,"id");d(this,"name");d(this,"atlasRotated");d(this,"atlasRegion");d(this,"atlasRegionOffset");d(this,"region");d(this,"pivot");d(this,"border");d(this,"pixelsPerUnit");d(this,"width");d(this,"height")}}class zt{}class us extends zt{constructor(){super(...arguments);d(this,"canvas");d(this,"context2D")}async parse(t){const i=t.outPut.info=new ps,s=t.option.padding??0,a=t.bins??[];t.outPut.imageFiles=[];const r=i.atlasItems;for(let o=0,l=a.length;o<l;o++){const h=a[o];this.initCanvas(h.width,h.height);const{context2D:p}=this,{rects:u}=h,c=new Array,f={img:"",type:"",width:h.width,height:h.height,sprites:c};for(let v=0,x=u.length;v<x;v++){const w=new hs,S=u[v];w.name=S.name,w.atlasRotated=S.isRotated,w.atlasRegion={x:S.x,y:S.y,w:S.width,h:S.height};const T=this.getItem(t.images,S.name),k=T==null?void 0:T.image;if(k){const A=S.x,lt=S.y,z=t.option.allowTrim?T.trimRect:void 0,xt=z?z.x:0,ct=z?z.y:0,vt=z?z.w:k.width,nt=z?z.h:k.height;if(z){const B=T.sourceWidth??k.width,$=T.sourceHeight??k.height;w.atlasRegionOffset={x:z.x,y:z.y,z:B-z.x-z.w,w:$-z.y-z.h}}let X,O,L;if(S.isRotated){O=nt,L=vt;let B;try{B=new OffscreenCanvas(O,L)}catch{B=document.createElement("canvas"),B.width=O,B.height=L}const $=B.getContext("2d");$.translate(O,0),$.rotate(Math.PI/2),$.drawImage(k,xt,ct,vt,nt,0,0,vt,nt),X=B}else O=vt,L=nt,X=k;if(S.isRotated?p.drawImage(X,0,0,O,L,A,lt,O,L):p.drawImage(X,xt,ct,O,L,A,lt,O,L),s>0)try{const B=S.isRotated?0:xt,$=S.isRotated?0:ct;for(let Y=1;Y<=s;++Y)p.drawImage(X,B,$,O,1,A,lt-Y,O,1),p.drawImage(X,B,$+L-1,O,1,A,lt+L+Y-1,O,1),p.drawImage(X,B,$,1,L,A-Y,lt,1,L),p.drawImage(X,B+O-1,$,1,L,A+O+Y-1,lt,1,L)}catch(B){console.error(JSON.stringify(B))}}c.push(w)}const g=await this.drawCanvas();if(g)t.outPut.imageFiles.push(g),r.push(f);else return F.CanvasBlobError}return F.Success}getItem(t,i){for(let s=t.length-1;s>=0;s--)if(t[s].name===i)return t[s];return null}initCanvas(t,i){if(this.canvas)this.canvas.width!==t||this.canvas.height!==i?(this.canvas.width=t,this.canvas.height=i):this.context2D.clearRect(0,0,t,i);else{try{this.canvas=new OffscreenCanvas(t,i)}catch{this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=i}this.context2D=this.canvas.getContext("2d",{willReadFrequently:!0})}}async drawCanvas(){return new Promise((t,i)=>{this.canvas instanceof HTMLCanvasElement?this.canvas.toBlob(s=>{s.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert canvas blob to ArrayBuffer"))})},"image/png",1):this.canvas.convertToBlob({type:"image/png",quality:1}).then(s=>{s.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert offscreen blob to ArrayBuffer"))})}).catch(s=>{console.error(JSON.stringify(s)),i(new Error("Failed to convert offscreen canvas to blob"))})})}}class ds extends zt{parse(e){return new Promise((t,i)=>{const{images:s}=e,{width:a,height:r,allowRotate:o,allowTrim:l}=e.option,h=s.length,p=[];for(let u=0;u<h;u++){const c=s[u];let f;const g=c.src;c.image||(g instanceof ArrayBuffer?f=this._loadImageFromBuffer(c):f=this._loadImageFromURL(c),p.push(f))}Promise.all(p).then(u=>{if(!l)for(let c=0,f=u.length;c<f;c++){const g=u[c];if(!(g.width<=a&&g.height<=r||!!o&&g.height<=a&&g.width<=r)){t(F.PackError);return}}t(F.Success)}).catch(u=>{console.error("OptLoadImage:Error",JSON.stringify(u)),i(F.ImageLoadError)})})}_loadImageFromBuffer(e){return new Promise((t,i)=>{const s=e.src,a=new window.Blob([s],{type:e.type}),r=new Image;r.onerror=function(){i(new Error("Failed to load image buffer"))},r.onload=function(){requestAnimationFrame(()=>{r.onload=null,r.onerror=null,r.onabort=null,e.image=r,t(r)})},r.crossOrigin="anonymous",r.src=URL.createObjectURL(a)})}_loadImageFromURL(e){return new Promise((t,i)=>{const s=new Image;s.onerror=function(){i(new Error("Failed to load image buffer"))},s.onload=function(){requestAnimationFrame(()=>{s.onload=null,s.onerror=null,s.onabort=null,e.image=s,t(s)})},s.crossOrigin="anonymous",s.src=e.src})}}const Et=[2048,1024,512,256,128,64,32,16,8,4,2];class fs extends zt{parse(e){const{option:t,images:i}=e,s=t.padding??0,a=!!t.allowRotate,r=t.method??W.BestLongSideFit;let o,l;if(t.square?o=l=Math.min(t.width,t.height):(o=t.width,l=t.height),t.pot){let c=!1,f=!1;for(let g=0,v=Et.length;g<v;++g){const x=Et[g];if(!c&&o>=x&&(o=x,c=!0),!f&&l>=x&&(l=x,f=!0),c&&f)break}}const h=[],p=s*2;for(let c=i.length-1;c>=0;c--){const f=i[c],g=f.image;if(!g)return F.ImageLoadError;const v=t.allowTrim?f.trimRect:void 0,x=v?v.w:g.width,w=v?v.h:g.height;if(!this.checkSizeLegality(x,w,o,l,p,a))return console.log("打包失败,",f.name,"单图尺寸超图集大小"),F.PackError;h.push(new q(0,0,x+p,w+p,f.name))}const u=[];for(;h.length>0;){const c=new cs;c.init(o,l,a);const f=c.insert2(h,r);if(f.length===0)return F.PackError;let g=0,v=0;for(let x=0;x<f.length;x++){const w=f[x],S=w.isRotated?w.height:w.width,T=w.isRotated?w.width:w.height,k=w.x+S,A=w.y+T;g=Math.max(g,k),v=Math.max(v,A),s>0&&(w.x+=s,w.y+=s,w.width-=p,w.height-=p)}if(t.square&&(g=v=Math.max(g,v)),t.pot){let x=!1,w=!1;for(let S=Et.length-1;S>=0;--S){const T=Et[S];if(!x&&g<=T&&(g=T,x=!0),!w&&v<=T&&(v=T,w=!0),x&&w)break}}u.push({rects:f,width:g,height:v})}return e.bins=u,F.Success}checkSizeLegality(e,t,i,s,a,r){const o=e+a,l=t+a;return r?o<=i&&l<=s||l<=i&&o<=s:o<=i&&l<=s}}const St=class St extends zt{static _getTrimContext(){let{_trimContext:e}=St;if(!e){let t;try{t=new OffscreenCanvas(1,1)}catch{t=document.createElement("canvas")}const i=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,ctx:i},St._trimContext=e}return e}parse(e){if(!e.option.allowTrim)return F.Success;const{images:t}=e,{canvas:i,ctx:s}=St._getTrimContext();for(let a=0,r=t.length;a<r;a++){const o=t[a],l=o.image;if(!l)continue;const{width:h,height:p}=l;o.sourceWidth=h,o.sourceHeight=p,i.width=h,i.height=p,s.drawImage(l,0,0);const u=s.getImageData(0,0,h,p).data,c=this._getTrimRect(u,h,p);(c.w<h||c.h<p)&&(o.trimRect=c)}return F.Success}_getTrimRect(e,t,i){let s=t,a=0,r=i,o=0;for(let l=0;l<i;l++){const h=l*t*4;for(let p=0;p<t;p++)e[h+p*4+3]>0&&(p<s&&(s=p),p>a&&(a=p),l<r&&(r=l),l>o&&(o=l))}return a<s||o<r?{x:0,y:0,w:1,h:1}:{x:s,y:r,w:a-s+1,h:o-r+1}}};d(St,"_trimContext",null);let ie=St;const Me=[new ds,new ie,new fs,new us],Yt={width:1024,height:1024,padding:1,allowRotate:!1,square:!1,pot:!1,method:W.BestLongSideFit};async function le(n,e){if(n.length===0)return{code:F.NoImage,msg:Te(F.NoImage)};if(e===void 0)e=Yt;else{const a=Object.keys(Yt);for(let r=a.length-1;r>=0;r--){const o=a[r];e[o]===void 0&&(e[o]=Yt[o])}}const t={};n.sort((a,r)=>r.name.toLowerCase().localeCompare(a.name.toLowerCase()));const i={option:e,images:n,outPut:t};let s=F.Success;for(let a=0;a<Me.length;a++){const r=await Me[a].parse(i);if(r!==F.Success){s=r;break}}return t.code=s,t.msg=Te(s),t}function Te(n){switch(n){case F.Success:return"打包成功!";case F.NoImage:return"传入图片长度为0.";case F.ImageLoadError:return"图片加载失败.";case F.CanvasBlobError:return"画布 blob 转换失败.";case F.OffscreenBlobError:return"离线画布 blob 转换失败.";case F.PackError:return"图集尺寸限制,打包失败。"}}async function It(n,e){await n.root.assetFacade.updateAssetProps(n.id,e)}async function gs(n,e){const t=await Promise.all(n.sprites.map(o=>e.getFileById(o.refId)).map(async o=>({...o,mainData:JSON.parse(await o.content.text())}))),[i,s]=Ni(t,o=>!!o.mainData.texture),a=$i(i,o=>o.mainData.texture.refId);return{packItems:await Promise.all(i.filter(o=>{var h;const l=(h=o.mainData.texture)==null?void 0:h.refId;return l?!!e.getFileById(l):!1}).map(async o=>{const l=o.mainData.texture.refId,p=await(await e.loadFile(l)).arrayBuffer();return{name:l,src:p}})),spriteAssetMap:a,spritesEmpty:s}}async function ms(n){const e=n.root.assetStore,t=await Promise.all(n.sprites.map(a=>e.getAssetByRef(a))),s=(await Promise.all(t.filter(a=>a&&a.texture).map(a=>e.getAssetByRef(a.texture)))).filter(a=>a).map(a=>({name:a.id,src:a.imageBuffer}));return await le(s,{padding:n.padding,width:n.maxWidth,height:n.maxHeight})}async function ys(n,e){let t,i=[];const{spriteAssetMap:s,packItems:a,spritesEmpty:r}=await gs(n,e);if(a.length>0?(t=await le(a,{padding:n.padding,width:n.maxWidth,height:n.maxHeight}),t.code===0?(i=t.info.atlasItems??[],i.forEach(o=>{const{sprites:l}=o;o.sprites=l.flatMap(h=>{const p=s[h.name],{atlasRegion:u,originalSize:c,atlasRotated:f}=h;return p.map(g=>Ae(g,u,c,f))})})):i=[],t.info.atlasItems=i):(t={code:1,msg:P("sprite.atlas.pack-error.no-sprite")},i=[]),r.length>0){const o=r.map(l=>Ae(l));i.push({img:"",sprites:o})}return t.info&&(t.info.atlasItems=i),t}function Ae(n,e,t=0,i=!1){const s=n.mainData,a=s.region,r=s.pivot,o=s.border,l={name:n.path,atlasRegion:e?{x:e.x,y:e.y,w:e.w,h:e.h}:{x:0,y:0,w:1,h:1},originalSize:t,atlasRotated:i,pivot:{x:r.x,y:r.y},region:{x:a.x,y:a.y,w:a.width,h:a.height},border:{x:o.x,y:o.y,z:o.z,w:o.w},width:s.width,height:s.height};return isNaN(s.width)||(l.width=s.width),isNaN(s.height)||(l.height=s.height),l}function ws(n){const e=[],t=i=>{const s=i.children,a=Object.keys(s);for(let r=a.length-1;r>=0;r--){const o=s[a[r]];o instanceof U?e.push(o):o instanceof Qt&&t(o)}};return t(n),e}function Ut(n,e){const t=e.id,i=n.sprites;for(let s=i.length-1;s>=0;s--)if(i[s].refId===t)return s;return-1}function je(n,e,t,i,s="#212324",a=15){var x;const{width:r,height:o}=t,{width:l,height:h}=e;let p,u,c,f;i.clearRect(0,0,t.width,t.height),i.fillStyle=s,r/o>l/h?(u=o,p=o/h*l,c=(r-p)/2,f=0,i.fillRect(0,0,c,o),i.fillRect(c+p,0,c,o)):(p=r,u=r/l*h,c=0,f=(o-u)/2,i.fillRect(0,0,r,f),i.fillRect(0,f+u,r,f)),i.drawImage(e,0,0,e.width,e.height,c,f,p,u);const g="Size: "+l+"x"+h+" Usage: "+n+"%";i.font=a+"px Arial";const v=((x=i.measureText(g))==null?void 0:x.width)||a*g.length;i.fillStyle="#000000",i.fillText(g,(r-v)/2,o-a*1/3-2),i.fillStyle="#ffffff",i.fillText(g,(r-v)/2,o-a/2-2)}function xs(n){return n.sprites.length>0}async function Be(n,e){await It(n,{texture:e?e.getCurrentRef():null})}async function Tt(n,e){const{belongToAtlas:t}=e,i=t==null?void 0:t.refId;if(i&&i!==n.id){const s=await n.root.assetStore.getAssetByRef(t);if(s){const a=s.sprites.filter(r=>r.refId!==e.id);a.length!==s.sprites.length&&await It(s,{sprites:a})}}if(i!==n.id&&await It(e,{belongToAtlas:n.getCurrentRef()}),Ut(n,e)<0){const s=[...n.sprites,e.getCurrentRef()];await It(n,{sprites:s})}}async function se(n,e){var i;((i=e.belongToAtlas)==null?void 0:i.refId)===n.id&&await It(e,{belongToAtlas:null});const t=Ut(n,e);if(t>=0){const s=n.sprites.filter((a,r)=>r!==t);await It(n,{sprites:s})}}const vs=ut(({asset:n,sprite:e})=>{const{assetStore:t}=n.root,i=Object.values(t.assets).filter(s=>s.getMetaConfig().type==="SpriteAtlas");return y.jsx(jt,{direction:"column",dropLayer:et.Sprite,assets:i,onSelect:async s=>{await se(n,e),await Tt(s,e)},onDelete:()=>{se(n,e)},onLocate:()=>{n&&n.id&&t.selectAsset(n.id)},asset:n,value:n.name})}),bs=ut(({model:n})=>{const{t:e}=Rt(),{assetStore:t}=n.root;Ss(n);const i=n.belongToAtlas?t.getAsset(n.belongToAtlas.refId):null,s=Object.values(t.assets).filter(a=>a.getMetaConfig().type==="SpriteAtlas");return y.jsxs(tt,{fullWidth:!0,css:{padding:"0 $0_5 $1"},children:[y.jsx(wi,{size:"1",css:{marginTop:"$1"},children:e("sprite.atlas.belong-to")}),n.belongToAtlas?y.jsx(vs,{asset:i,sprite:n},i.id):y.jsx(jt,{dropLayer:et.Sprite,assets:s,onSelect:a=>{Tt(a,n)},trigger:y.jsx(tt,{align:"h",css:{padding:"$1 $2 $1"},children:y.jsx(_t,{size:"sm",variant:"solid",css:{padding:"$1 $6"},children:e("sprite.atlas.belong-to")})}),label:"",value:null,asset:null})]})});async function Ss(n){const e=n.root.assetStore,t=n.belongToAtlas,i=t?await e.getAssetByRef(t):null;if(i){Ut(i,n)<0&&await n.root.assetFacade.updateAssetProps(i.id,{sprites:[...i.sprites,n.getCurrentRef()]});return}t&&await n.root.assetFacade.updateAssetProps(n.id,{belongToAtlas:null})}var Is=Object.defineProperty,Rs=Object.getOwnPropertyDescriptor,st=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rs(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Is(e,t,s),s};const H=new De;function He(n){return n.quickPivot===9}function Oe(n){switch(n){case 0:H.set(.5,.5);break;case 1:H.set(0,1);break;case 2:H.set(.5,1);break;case 3:H.set(1,1);break;case 4:H.set(0,.5);break;case 5:H.set(1,.5);break;case 6:H.set(0,0);break;case 7:{H.set(.5,0);break}case 8:{H.set(1,0);break}}}let U=class extends ot{constructor(e){super(e);d(this,"_delOnTexDel");d(this,"_customWidth");d(this,"_customHeight");d(this,"acceptDragLayer",et.Texture);d(this,"texture",null);d(this,"width");d(this,"height");d(this,"region",{x:0,y:0,width:1,height:1});d(this,"quickPivot",0);d(this,"pivot",{x:.5,y:.5});d(this,"border",{x:0,y:0,z:0,w:0});d(this,"belongToAtlas",null)}async afterDelete(){this.engineObject.destroy(!0);const{belongToAtlas:e}=this;if(e){const t=await this.root.assetStore.getAssetByRef(e);if(t){const i=Ut(t,this);i>-1&&t.sprites.splice(i,1),this.belongToAtlas=null,await this.root.assetFacade.persistAssetMain(t.id)}}this._delOnTexDel&&(this._delOnTexDel(),this._delOnTexDel=null)}getMainData(){const e=this[be]??{},t={};return Object.keys(e).forEach(i=>{switch(i){case"width":isNaN(this._customWidth)||(t.width=this._customWidth);break;case"height":isNaN(this._customHeight)||(t.height=this._customHeight);break;default:t[i]=this[i];break}}),JSON.stringify(t)}async initByMain(e){const t=new xi(this.engine),i=JSON.parse(await e.text());if(isNaN(i.width)||(t.width=this._customWidth=i.width),isNaN(i.height)||(t.height=this._customHeight=i.height),i.texture){const a=await this.root.assetStore.getAssetByRef(i.texture);a&&(await a.ensureReady(),t.texture=a.engineObject)}for(const a in i)this[a]=i[a];this.bindEngineObject(t);const s=new Ee(this.engine);s.addComponent(Nt).sprite=t,this.setDragTempEntity(s),await this.applyBoundPathChange("name",R.Input,this.name)}async initByCreation(){const{assetStore:e,assetUIStore:t}=this.root,{pickedAssets:i}=t,s=JSON.parse(this.getMainData());if(i&&i.length===1){const a={refId:i[0]},r=await e.getAssetByRef(a);r instanceof Ve?(r.setTextureType(qe.Sprite),s.texture=a):r instanceof U&&r.texture&&(s.texture={refId:r.texture.refId})}return s}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:s}=t.transform,a={components:[{class:"SpriteRenderer",id:Pt(),props:{drawMode:0,enabled:!0,flipX:!1,flipY:!1,maskInteraction:0,maskLayer:vi.Everything,sprite:this.getCurrentRef()}}],id:e.id,isActive:!0,isClone:!1,name:this.name?"sprite-"+this.name:"sprite",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:s.x,y:s.y,z:s.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}initByEngineObject(e){const t=Object.keys(this[be]),i=["texture","quickPivot","belongToAtlas"],s=a=>!i.includes(a);t.filter(s).forEach(a=>{const r=e[a];typeof r=="object"?Object.keys(r).forEach(l=>{this[a][l]=r[l]}):this[a]=r}),this.bindEngineObject(e)}async _onDrop(e,t){const i="texture";this.dropping=!1,this.texture=t.getCurrentRef(),this.formSchema.getPropertyConfig(i).onChange(this,i,t),this.updateThumbnail()}};st([M({info:"sprite.texture.info",label:"sprite.texture.label",type:R.AssetPicker,assetType:"Texture",customFilter:n=>n.isSubAsset===!1,onChange:async(n,e,t)=>{const i=n.engineObject;if(n._delOnTexDel&&(n._delOnTexDel(),n._delOnTexDel=null),await n.applyBoundPathChange("texture",R.AssetPicker,t==null?void 0:t.getCurrentRef()),t){const s=()=>{var a;(a=n._delOnTexDel)==null||a.call(n),n._delOnTexDel=null,n.texture=null,n.applyBoundPathChange("texture",R.AssetPicker,void 0),n.updateThumbnail()};t.on("delete",s),n._delOnTexDel=()=>{t.off("delete",s)}}isNaN(n._customWidth)?n.width=i.width:(n.width=n._customWidth,await n.applyBoundPathChange("width",R.Number,n._customWidth)),isNaN(n._customHeight)?n.height=i.height:(n.height=n._customHeight,await n.applyBoundPathChange("height",R.Number,n._customHeight))}}),E()],U.prototype,"texture",2);st([M({label:"sprite.width.label",info:"sprite.width.info",type:R.Number,triggerAfterInit:!1,async onChange(n,e,t){isNaN(t)||(n._customWidth=t,await n.applyBoundPathChange("width",R.Number,t))}}),E()],U.prototype,"width",2);st([M({label:"sprite.height.label",info:"sprite.height.info",type:R.Number,triggerAfterInit:!1,async onChange(n,e,t){isNaN(t)||(n._customHeight=t,await n.applyBoundPathChange("height",R.Number,t))}}),E()],U.prototype,"height",2);st([M({info:"sprite.region.info",label:"sprite.region.label",type:R.Rect,min:0,max:1,dragStep:.01,onChange(n,e,t){n.applyBoundPathChange("region",R.Rect,t)}}),E()],U.prototype,"region",2);st([bi({setPath:"pivot",getActualEditorValue:n=>(Oe(n),new De().copyFrom(H)),getEditorValue:n=>{const{x:e,y:t}=n;return e===.5&&t===.5?0:e===0&&t===1?1:e===.5&&t===1?2:e===1&&t===1?3:e===0&&t===.5?4:e===1&&t===.5?5:e===0&&t===0?6:e===.5&&t===0?7:e===1&&t===0?8:9}}),M({info:"sprite.quick-pivot.info",label:"sprite.quick-pivot.label",type:R.Select,value:0,options:[{label:"sprite.quick-pivot.center",value:0},{label:"sprite.quick-pivot.top-left",value:1},{label:"sprite.quick-pivot.top",value:2},{label:"sprite.quick-pivot.top-right",value:3},{label:"sprite.quick-pivot.left",value:4},{label:"sprite.quick-pivot.right",value:5},{label:"sprite.quick-pivot.bottom-left",value:6},{label:"sprite.quick-pivot.bottom",value:7},{label:"sprite.quick-pivot.bottom-right",value:8},{label:"sprite.quick-pivot.custom",value:9}],onChange(n,e,t){He(n)?H.copyFrom(n.pivot):Oe(t),n.pivot.x=H.x,n.pivot.y=H.y,n.applyBoundPathChange("pivot",R.Vector2,H)}}),E()],U.prototype,"quickPivot",2);st([M({info:"sprite.pivot.info",label:"sprite.pivot.label",type:R.Vector2,onChange(n,e,t){n.quickPivot===9&&n.applyBoundPathChange("pivot",R.Vector2,t)},when:He}),E()],U.prototype,"pivot",2);st([M({info:"sprite.border.info",label:"sprite.border.label",customComponent:ls,slotMapping:{x:"Left",y:"Down",z:"Right",w:"Up"},onChange(n,e,t){n.applyBoundPathChange("border",R.Vector4,t)}}),E()],U.prototype,"border",2);st([M({info:P("sprite.belong.info"),label:P("sprite.belong.label"),customComponent:bs}),E()],U.prototype,"belongToAtlas",2);st([Si()],U.prototype,"getMainData",1);st([Bt],U.prototype,"_onDrop",1);U=st([Ct({type:"sprite",label:P("asset.sprite.title"),loaderType:"Sprite",extname:"sprite",importMenuConfig:{type:Mt.Upload|Mt.Add,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:Wi,thumbnail:ee,defaultName:"Sprite",dragLayer:et.Sprite,dragType:"2d",preUpload:async(n,e,t,i)=>{const s=Le(n.main,"sprite.png"),a=s.name;if(i)if(i.meta.type==="Texture"){await Ii.assets.update(i.serverId,{file:s});return}else throw`Can't overwrite type: ${i.meta.type}, name: ${a}`;const r=await t.root.assetFacade.createAssetByUpload({uploadAssetFile:{...n,main:s},assetType:"Texture"});return r.setTextureType(qe.Sprite),new File([JSON.stringify({texture:r.getCurrentRef()})],gt(a,Se(a))+"-spr"+Se(a))},customInspector:qi,async bundle({id:n,content:e,path:t},i,s){const a=s.vfs;return{content:new Blob([await Fi(n,await e.text(),t,async r=>{const o=a.getFileById(r);if(!o)return null;const l=o.content??await a.loadFile(o.id);return l?l.text():null})])}}})],U);const Ln=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAsset(){return U}},Symbol.toStringTag,{value:"Module"})),Cs=it("div",{position:"relative",width:"100%",marginBottom:"$2",aspectRatio:"1/1"}),_s=it("div",{position:"absolute",width:"100%",height:"100%",padding:"$1",boxSizing:"border-box","& canvas":{width:"100%",height:"100%",border:"1px solid $grayA4",borderRadius:"$3",overflow:"hidden"}}),Ps=b.forwardRef(function(e,t){const{buttonContent:i,onClick:s}=e;return y.jsxs(tt,{direction:"column",fullWidth:!0,children:[y.jsx(Cs,{children:y.jsx(_s,{children:y.jsx("canvas",{ref:t,width:"400",height:"400"})})}),i&&y.jsx(tt,{align:"h",css:{margin:"$0 auto"},children:y.jsx(_t,{size:"sm",variant:"solid",css:{padding:"0 $14"},onClick:s,children:i})})]})});function Ms(n,e){return new Promise((t,i)=>{const s=new window.Blob([n],{type:e}),a=new window.Image,r=URL.createObjectURL(s);let o=!1;const l=()=>{o||(o=!0,URL.revokeObjectURL(r))};a.crossOrigin="anonymous",a.onerror=()=>{l(),i(new Error("Failed to load image buffer"))},a.onload=()=>{requestAnimationFrame(()=>{l(),t(a)})},a.src=r})}const Ts=ut(({item:n})=>{const[e,t]=b.useState(null),{assetStore:i}=n.root,{t:s}=Rt(),a=Object.values(i.assets).filter(r=>!r.isSubAsset&&r.getMetaConfig().type==="Texture");return b.useEffect(()=>{let r=!1;return n.texture?i.getAssetByRef(n.texture).then(o=>{r||t(o)}):t(null),()=>{r=!0}},[n.texture]),y.jsxs(y.Fragment,{children:[y.jsx(jt,{dropLayer:et.Sprite,assets:a,onSelect:r=>{Be(n,r)},onDelete:()=>{Be(n,null)},onLocate:()=>{var r;(r=n.texture)!=null&&r.refId&&i.selectAsset(n.texture.refId)},label:s("sprite.texture.label"),value:e&&e.name,asset:e}),y.jsx(Ri,{label:s("sprite.region.label"),value:{x:n.region.x,y:n.region.y,width:n.region.width,height:n.region.height},onChange:(r,o)=>{n.root.inspectorFacade.assetChange(n.id,"region",{...n.region,[o]:r[o]})},min:0,max:1}),y.jsx(Ci,{label:s("sprite.quick-pivot.label"),value:n.quickPivot,options:[{label:s("sprite.quick-pivot.center"),value:0},{label:s("sprite.quick-pivot.top-left"),value:1},{label:s("sprite.quick-pivot.top"),value:2},{label:s("sprite.quick-pivot.top-right"),value:3},{label:s("sprite.quick-pivot.left"),value:4},{label:s("sprite.quick-pivot.right"),value:5},{label:s("sprite.quick-pivot.bottom-left"),value:6},{label:s("sprite.quick-pivot.bottom"),value:7},{label:s("sprite.quick-pivot.bottom-right"),value:8},{label:s("sprite.quick-pivot.custom"),value:9}],onChange:r=>{n.root.inspectorFacade.assetChange(n.id,"quickPivot",r)}}),n.quickPivot===9&&y.jsx(_i,{label:"",value:{x:0,y:0}}),y.jsx(ke,{label:s("sprite.border.label"),value:{x:n.border.x,y:n.border.y,z:n.border.z,w:n.border.w},onChange:(r,o)=>{n.root.inspectorFacade.assetChange(n.id,"border",{...n.border,[o]:r[o]})},min:0,max:1})]})}),As=ut(({model:n,inspectorConfig:e})=>{const{label:t}=e,i=n.sprites,{assetStore:s}=n.root,a=xs(n),{t:r}=Rt();js(n);const o=Object.values(s.assets).filter(c=>{switch(c.getMetaConfig().type){case"sprite":return!i.find(g=>g.refId===c.id);case"Folder":return!0}return!1}),l=b.useRef(null);let h,p;b.useLayoutEffect(()=>{h=l.current,p=h==null?void 0:h.getContext("2d"),n.previewImage&&p&&je(n.usage,n.previewImage,h,p)});async function u(){var c;if(a){if(p){const f=await ms(n),g=((c=f.info)==null?void 0:c.atlasItems)??[],v=g.reduce((S,T)=>S+T.sprites.reduce((k,A)=>k+A.width*A.height,0),0),x=g.reduce((S,T)=>S+T.width*T.height,0),w=x>0?Number((v/x*100).toFixed(2)):0;f.code===0?Ms(f.imageFiles[0],"image/png").then(S=>{n.replacePreview(S),je(w,S,h,p)}):Ie({title:r("sprite.atlas.pack-error.title"),description:f.msg})}}else Ie({title:r("sprite.atlas.pack-error.title"),description:r("sprite.atlas.pack-error.no-sprite")})}return y.jsxs(y.Fragment,{children:[y.jsx(We,{label:t,items:i.map((c,f)=>{const g=s.getAsset(c.refId);return{removable:!0,children:y.jsx(Ts,{item:g}),id:`${f}`,name:g.getRouteString()}}),onDelete:async c=>{const f=await s.getAssetByRef(i[c.id]);await se(n,f)}}),y.jsxs(tt,{align:"both",direction:"column",children:[y.jsx(jt,{assets:o,dropLayer:et.Sprite|et.Folder,customFilter:c=>c instanceof U||c instanceof Qt,onSelect:c=>{if(c instanceof U)Tt(n,c);else if(c instanceof Qt){const f=ws(c);for(let g=f.length-1;g>=0;g--)Tt(n,f[g])}},trigger:y.jsx(_t,{size:"sm",variant:"solid",css:{flex:1},startSlot:y.jsx(ze,{}),children:r("sprite.atlas.add-object.label")}),label:r("sprite.atlas.add-sprite"),value:null,asset:null}),y.jsx(_t,{size:"sm",variant:"solid",positive:!0,fullWidth:!0,css:{margin:"$1"},onClick:u,children:r("sprite.atlas.pack-preview.label")})]}),a&&y.jsx(Ps,{ref:l})]})});async function js(n){var s;const e=n.root.assetStore.assets,t=n.sprites,i=[];for(let a=0;a<t.length;a++){const r=t[a],o=e[r.refId];o&&(i.push(r),((s=o.belongToAtlas)==null?void 0:s.refId)!==n.id&&await Tt(n,o))}i.length!==t.length&&await n.root.assetFacade.updateAssetProps(n.id,{sprites:i})}var Bs=Object.defineProperty,Os=Object.getOwnPropertyDescriptor,G=(n,e,t,i)=>{for(var s=i>1?void 0:i?Os(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Bs(e,t,s),s};let N=class extends ot{constructor(e){super(e);d(this,"acceptDragLayer",et.Sprite);d(this,"previewTexture2D");d(this,"previewImage");d(this,"usage",0);d(this,"maxWidth",1024);d(this,"maxHeight",1024);d(this,"padding",2);d(this,"allowRotation",!1);d(this,"tightPacking",!1);d(this,"mipmap",!1);d(this,"filterMode",Q.Bilinear);d(this,"wrapModeU",D.Repeat);d(this,"wrapModeV",D.Repeat);d(this,"anisoLevel",1);d(this,"sprites",[]);this.setNameByIncrease("SpriteAtlas");const t=this.formSchema;t.addGroup(P("sprite.atlas.packing"),["maxWidth","maxHeight","padding","allowRotation","tightPacking"]),t.addGroup(P("sprite.atlas.export"),["filterMode","wrapModeU","wrapModeV","anisoLevel","mipmap"]),t.addGroup(P("sprite.atlas.list"),["sprites"])}static async updateSubTextureAssets(e,t,i,s,a){var f;const r=e.meta,o=a.vfs,l=e.dependencies||(e.dependencies=[]),h=((f=l[t])==null?void 0:f.ref.refId)??Pt(),p=gt(e.name).split(".")[0];l[t]||(l[t]={key:"atlasItems["+t+"].img",ref:{refId:h}});let u=o.getFileById(h),c;return u?c=u.meta:(c={id:h,type:ot.getRegisteredAssetMeta(Ve).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[]},a.addFile({name:p+"_image_"+t,assetId:h,url:null,parentId:e.parentId,main:null,meta:c}),u=o.getFileById(h),u.ignoreBundle=!0),c.colorDilate=r.colorDilate??!1,c.filterMode=r.filterMode??Q.Bilinear,c.wrapModeU=r.wrapModeU??D.Repeat,c.wrapModeV=r.wrapModeV??D.Repeat,c.anisoLevel=r.anisoLevel??1,c.runtimeOptions=r.runtimeOptions??{},a.updateFile(h,{main:new Blob([i],{type:"image/png"}),meta:c}),await a.bundleSingleFile(u,s),u}replacePreview(e){this.previewImage=e;const t=this.previewTexture2D;this.previewTexture2D=new Fe(this.engineObject.engine,e.width,e.height),this.previewTexture2D.setImageSource(e),t&&t.destroy(!0)}async afterDelete(){this.engineObject.destroy(!0);const{sprites:e,id:t}=this,i=this.root.assetStore,a=[...e].map(async r=>{var o;try{const h=await i.getAssetByRef(r);((o=h==null?void 0:h.belongToAtlas)==null?void 0:o.refId)===t&&await this.root.assetFacade.updateAssetProps(h.id,{belongToAtlas:null})}catch(l){console.warn(`[SpriteAtlasAsset] Failed to cleanup sprite relation: ${(r==null?void 0:r.refId)??"unknown"}`,l)}});await Promise.allSettled(a),e.length=0}addSprites(e){const t=zi([...this.sprites,...e.map(s=>({refId:s.id}))],s=>s.refId),i=e.map(s=>this.root.assetFacade.updateAssetProps(s.id,{belongToAtlas:{refId:this.id}}));return i.push(this.root.assetFacade.updateAssetProps(this.id,{sprites:t})),Promise.all(i)}async initByMain(e){const{engine:t}=this,i=JSON.parse(await e.text());for(const a in i)this[a]=i[a];const s=new Re(t);this.bindEngineObject(s),s.asset=this}async initByCreation(){this.setNameByIncrease("SpriteAtlas");const e=new Re(this.engine);return this.bindEngineObject(e),e.asset=this,this.getMainData()}async _onDrop(e,t){this.dropping=!1,!this.sprites.find(i=>i.refId===t.id)&&await this.addSprites([t])}};G([M({info:"sprite.atlas.max-width.info",label:"sprite.atlas.max-width.label",type:R.Input}),E()],N.prototype,"maxWidth",2);G([M({info:"sprite.atlas.max-height.info",label:"sprite.atlas.max-height.label",type:R.Input}),E()],N.prototype,"maxHeight",2);G([M({info:"sprite.atlas.padding.info",label:"sprite.atlas.padding.label",type:R.Number,min:0,max:5,dragStep:1}),E()],N.prototype,"padding",2);G([M({info:"sprite.atlas.rotation.info",label:"sprite.atlas.rotation.label",type:R.Toggle}),E()],N.prototype,"allowRotation",2);G([M({info:"sprite.atlas.tight-packing.info",label:"sprite.atlas.tight-packing.label",type:R.Toggle}),E()],N.prototype,"tightPacking",2);G([M({label:"sprite.atlas.mipmap.label",type:R.Toggle}),E()],N.prototype,"mipmap",2);G([M({label:"sprite.atlas.filter-mode.label",type:R.Select,value:Q.Bilinear,options:[{label:"sprite.atlas.filter-mode.point",value:Q.Point},{label:"sprite.atlas.filter-mode.bilinear",value:Q.Bilinear},{label:"sprite.atlas.filter-mode.trilinear",value:Q.Trilinear}]}),E()],N.prototype,"filterMode",2);G([M({label:"sprite.atlas.wrap-mode-u.label",type:R.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:D.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:D.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:D.Mirror}]}),E()],N.prototype,"wrapModeU",2);G([M({label:"sprite.atlas.wrap-mode-v.label",type:R.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:D.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:D.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:D.Mirror}]}),E()],N.prototype,"wrapModeV",2);G([M({label:"sprite.atlas.aniso-level.label",type:R.Slider,dragStep:1,max:16,min:1}),E()],N.prototype,"anisoLevel",2);G([Pi({key:"addSprite"}),M({label:P("sprite.atlas.sprite-list.label"),customComponent:As}),E()],N.prototype,"sprites",2);G([Bt],N.prototype,"addSprites",1);N=G([Ct({type:"SpriteAtlas",label:P("asset.sprite-atlas.title"),loaderType:"SpriteAtlas",extname:"atlas",importMenuConfig:{type:Mt.Add},async bundle(n,e,t){var l;const i=t.vfs,s=n.content??await i.loadFile(n.id),a=JSON.parse(await s.text()),r=n.meta,o=n.dependencies||(n.dependencies=[]);if(r.ignorePack){const h=a.atlasItems;for(let p=0,u=h.length;p<u;p++){const c=a.atlasItems[p],f=await fetch(c.img).then(v=>v.arrayBuffer()),g=await N.updateSubTextureAssets(n,p,f,e,t);c.type=g.exportType,c.img="./"+gt(g.path)}}else{const h=n.id,p=a.sprites;for(let c=p.length-1;c>=0;c--){const f=p[c].refId,g=i.getFileById(f);if(g){const v=g.content??await i.loadFile(g.id);((l=JSON.parse(await v.text()).belongToAtlas)==null?void 0:l.refId)!==h&&(p.splice(c,1),console.warn("Sprite.belongToAtlas is not equal to this asset."))}else p.splice(c,1),console.warn("SpriteAsset[refId:",f,"] not found")}const u=await ys(a,i);if(u.code===0){const c=u.info;for(const g in c)a[g]=c[g];const f=u.imageFiles;for(let g=0,v=f.length;g<v;g++){const x=await N.updateSubTextureAssets(n,g,f[g],e,t),w=a.atlasItems[g];w.type=x.exportType,w.img="./"+gt(x.path)}}else{for(let c=0,f=o.length;c<f;c++){const g=o[c].ref.refId;i.deleteFile(g)}o.length=0}}return delete a.usage,delete a.allowRotation,delete a.maxHeight,delete a.maxWidth,delete a.padding,delete a.sprites,delete a.tightPacking,{content:new Blob([JSON.stringify(a)])}}})],N);const $n=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAtlasAsset(){return N}},Symbol.toStringTag,{value:"Module"}));var Fs=Object.defineProperty,ks=Object.getOwnPropertyDescriptor,Ds=(n,e,t,i)=>{for(var s=i>1?void 0:i?ks(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Fs(e,t,s),s};let ne=class extends ot{initByMain(n,e){return Promise.resolve()}};ne=Ds([Ct({type:"LottieAnimation",async bundle(n){const e=JSON.parse(await n.content.text());return{content:new Blob([JSON.stringify(e)])}}})],ne);const Es=it("div",{display:"grid",columnGap:"$1",gridColumn:2/-1,gridTemplateColumns:"minmax(0, 4fr) repeat(1, 2fr) repeat(1, auto) repeat(1, 2fr) repeat(1, auto)",marginBottom:"$1"}),Ls=function({clip:n,removeClip:e,onClipChange:t}){const{t:i}=Rt();return y.jsxs(Es,{children:[y.jsx(Ht,{size:"sm",value:n.name??"",placeholder:i("lottie.clip.name"),onChange:s=>{t({name:s.currentTarget.value})}}),y.jsx(Ht,{size:"sm",value:n.start??"",placeholder:i("lottie.clip.start"),onChange:s=>{t({start:+s.currentTarget.value})}}),y.jsx(Vi,{width:12,onClick:e}),y.jsx(Ht,{size:"sm",value:n.end??"",placeholder:i("lottie.clip.end"),onChange:s=>{t({end:+s.currentTarget.value})}})]})},$s=ut(function(n){const e=n.model,t=e.getViewer(),{inspectorFacade:i}=re(),{t:s}=Rt(),[a,r]=b.useState(()=>Array.isArray(e.clips)?[...e.clips]:[]);b.useEffect(()=>{r(Array.isArray(e.clips)?[...e.clips]:[])},[e,e.clips]),b.useEffect(()=>{t==null||t.setClips(a)},[a,t]);const o=u=>{r(u),i.assetChange(e.id,"clips",u,"asset-meta")},l=()=>{o([...a,{}])},h=u=>{u<0||u>=a.length||o(a.filter((c,f)=>f!==u))},p=(u,c)=>{if(u<0||u>=a.length)return;const f={...a[u],...c},g=a.map((v,x)=>x===u?f:v);o(g)};return y.jsxs(Mi,{title:s("lottie.clips.title"),defaultOpen:!0,collapsible:!0,children:[a.map((u,c)=>y.jsx(Ls,{clip:u,removeClip:()=>h(c),onClipChange:f=>p(c,f)},`${e.id}-${c}`)),y.jsx(tt,{align:"h",css:{margin:"0 auto",padding:"$1 0 0 0"},children:y.jsx(_t,{size:"sm",variant:"soft",startSlot:y.jsx(ze,{size:"14px"}),onClick:l,children:s("lottie.clips.add")})})]})});async function Ns(n,e,t={}){try{const i=JSON.parse(n),{assets:s}=i,a=[];for(let o=0,l=s.length;o<l;o++){const h=s[o],{p}=h;p&&a.push({name:h.id,src:p})}const r=await le(a,{width:2048,height:2048,...t});return r.code!==0?(console.log("Atlas Error:",r.msg),r):(i.assets=s.filter(o=>!o.p),r.info.jsonFile=JSON.stringify(i),r)}catch{return{code:11,msg:"Parse lottie file error"}}}async function zs(n){const e={uploadFiles:[],errors:[]};for(const t in n){const i=n[t],s=i.name;if(s.endsWith(".json"))try{const a=await i.text(),r=JSON.parse(a);Vs(r)&&e.uploadFiles.push({main:i})}catch(a){e.errors.push(Je(s,a))}}return e}async function Us(n,e,t){const i=Le(n.main,"lottie.json"),s=await i.text();let a;try{a=JSON.parse(s)}catch(l){return console.error(l),Jt.error(Je(i.name,l)),i}const{nm:r}=a,o=await Ns(s);if(o.code===0)try{const{imageFiles:l,atlasFile:h,jsonFile:p}=o.info,u=JSON.parse(h),{atlasItems:c}=u,f=c.length,g=qs(),v=Ws(r,i.name),x=[];for(let A=0;A<f;++A)l[A]&&x.push(Gt.uploadBlob(`${v}-${g}-${A}.png`,new Blob([l[A]])));const w=await Promise.all(x);for(let A=0;A<f;++A)c[A].img=w[A].url;const[S,T]=await Promise.all([Gt.uploadBlob(`${v}-${g}.atlas`,new Blob([JSON.stringify(u)])),Gt.uploadBlob(`${v}-${g}.json`,new Blob([p]))]),k={jsonUrl:T.url,atlasUrl:S.url};return new File([JSON.stringify(k)],i.name)}catch(l){console.error(l),Jt.error(`parse lottie file fail ${l}`)}else console.error(o.msg),Jt.error(o.msg);return i}function Vs(n){return n.nm&&n.w&&n.h&&n.assets&&n.assets.length>0&&n.layers&&n.layers.length>0}function qs(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Ws(n,e){const t=e.replace(/\.[^.]+$/,"")||"lottie";return(typeof n=="string"&&n.length>0?n:t).trim().replace(/[^\w.-]+/g,"_")||"lottie"}function Je(n,e){const t=e instanceof Error?e.message:String(e);return`Failed to parse JSON file "${n}": ${t}`}var Hs=Object.defineProperty,Js=Object.getOwnPropertyDescriptor,wt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Js(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Hs(e,t,s),s};class ft extends Ue{constructor(){super();d(this,"lottie");d(this,"_updateComponent");d(this,"_lottieAsset");d(this,"playing",!1);d(this,"frameTime",0);d(this,"animationNames",[]);d(this,"animationIndex",0);d(this,"_hasClips",!1);$e(this)}get duration(){const{_lottieAsset:t}=this;return this._hasClips&&t.clips[this.animationIndex]?t.clips[this.animationIndex].end-t.clips[this.animationIndex].start:this._lottieAsset.duration}_setAnimationNames(t){this.animationNames=this._hasClips?t==null?void 0:t.map(i=>i.name):[this._lottieAsset.engineObject.name]}setViewAsset(t,i){const s=t.engineObject,a=i.createChild("lottie_entity"),r=a.addComponent(Zt);this._entity=a,this.lottie=r,r.resource=s,this._lottieAsset=t,this._hasClips=t.clips&&t.clips.length>0,this._setAnimationNames(t.clips),this.animationIndex=0;const o=this;this._updateComponent=this._entity.addComponent(class extends Ti{onUpdate(l){o._onUpdate()}}),this.frameTime=0}getSize(){var t;if((t=this.lottie)!=null&&t.resource){const{width:i,height:s}=this.lottie.resource;return{width:i/100,height:s/100}}return{width:0,height:0}}stopViewAsset(){var t;super.stopViewAsset(),this.lottie=null,(t=this._updateComponent)==null||t.destroy(),this.animationNames=null}setClips(t){this.lottie.resource.setClips(t),this._setAnimationNames(t)}play(t){this.lottie.isLooping=!0,this.lottie.play(t),this.playing=!0}pauseAnimation(){this.lottie.pause(),this.playing=!1}selectAnimation(t){this.animationIndex=t;const i=this._lottieAsset.clips[t];this.play(i==null?void 0:i.name)}playAnimation(){const t=this._lottieAsset.clips[this.animationIndex];this.play(t==null?void 0:t.name)}setFrameTime(t){}_onUpdate(){this.playing&&(this.frameTime=this.lottie.frame)}}wt([yt],ft.prototype,"playing",2);wt([yt],ft.prototype,"frameTime",2);wt([yt],ft.prototype,"animationNames",2);wt([yt],ft.prototype,"animationIndex",2);wt([Bt],ft.prototype,"play",1);wt([Bt],ft.prototype,"pauseAnimation",1);wt([Bt],ft.prototype,"_onUpdate",1);var Gs=Object.defineProperty,Ks=Object.getOwnPropertyDescriptor,K=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ks(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Gs(e,t,s),s};let V=class extends ot{constructor(e){super(e);d(this,"textureSet",new Set);d(this,"width",0);d(this,"height",0);d(this,"duration",0);d(this,"inPoint",0);d(this,"outPoint",0);d(this,"clips",[]);d(this,"mipmap",!1);d(this,"colorDilate",!1);d(this,"filterMode",Q.Bilinear);d(this,"wrapModeU",D.Repeat);d(this,"wrapModeV",D.Repeat);d(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});this.formSchema.addGroup(P("lottie.asset.atlas-export"),["filterMode","wrapModeU","wrapModeV","mipmap","colorDilate"])}destroy(){super.destroy(),this.textureSet.clear(),this.textureSet=null}async initByUploadFile(e){return await this._initByUrl(this.engine,e),this}async initByMain(e){const{engine:t,meta:i}=this;i.runtimeOptions&&(this.runtimeOptions=i.runtimeOptions),this.clips=i.clips||[],this.filterMode=i.filterMode??this.filterMode,this.wrapModeU=i.wrapModeU??this.wrapModeU,this.wrapModeV=i.wrapModeV??this.wrapModeV,this.mipmap=i.mipmap??this.mipmap,this.colorDilate=i.colorDilate??this.colorDilate,await this._initByUrl(t,e);const s=new Ee(this.engine),a=s.addComponent(Zt);a.resource=this.engineObject,this.setDragTempEntity(s)}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:s}=t.transform,a={components:[{class:"LottieAnimation",id:Pt(),props:{resource:this.getCurrentRef(),priority:0,defaultState:{}}}],id:e.id,isActive:!0,isClone:!1,name:this.name?this.name:"lottie",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:s.x,y:s.y,z:s.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}async _createLottieResource(e,t,i){return(await e.resourceManager.load({urls:[t,i],type:"lottie"})).getComponent(Zt).resource}async _initByUrl(e,t){const i=JSON.parse(await t.text()),{jsonUrl:s,atlasUrl:a}=i,r=await this._createLottieResource(e,s,a);this.bindEngineObject(r);const{sprites:o}=r.atlas,{textureSet:l}=this;for(let h=0,p=o.length;h<p;++h){const u=o[h].texture;l.has(u)||(l.add(u),u.filterMode=this.filterMode,u.wrapModeU=this.wrapModeU,u.wrapModeV=this.wrapModeV)}return this.width=r.width,this.height=r.height,this.duration=r.duration,this.inPoint=r.inPoint,this.outPoint=r.outPoint,this}};K([M({type:R.Input,disabled:!0,label:P("lottie.asset.width")})],V.prototype,"width",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.height")})],V.prototype,"height",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.duration")})],V.prototype,"duration",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.in-point")})],V.prototype,"inPoint",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.out-point")})],V.prototype,"outPoint",2);K([M({disabled:!0,customComponent:$s}),dt()],V.prototype,"clips",2);K([M({label:P("lottie.asset.mipmap"),type:R.Toggle}),dt()],V.prototype,"mipmap",2);K([M({label:P("lottie.asset.color-dilate"),type:R.Toggle}),dt()],V.prototype,"colorDilate",2);K([M({label:P("lottie.asset.filter-mode.title"),type:R.Select,value:Q.Bilinear,options:[{label:P("lottie.asset.filter-mode.point"),value:Q.Point},{label:P("lottie.asset.filter-mode.bilinear"),value:Q.Bilinear},{label:P("lottie.asset.filter-mode.trilinear"),value:Q.Trilinear}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.filterMode=t})}}),dt()],V.prototype,"filterMode",2);K([M({label:P("lottie.asset.wrap-mode.u"),type:R.Select,value:D.Repeat,options:[{label:P("lottie.asset.wrap-mode.clamp"),value:D.Clamp},{label:P("lottie.asset.wrap-mode.repeat"),value:D.Repeat},{label:P("lottie.asset.wrap-mode.mirror"),value:D.Mirror}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.wrapModeU=t})}}),dt()],V.prototype,"wrapModeU",2);K([M({label:P("lottie.asset.wrap-mode.v"),type:R.Select,value:D.Repeat,options:[{label:P("lottie.asset.wrap-mode.clamp"),value:D.Clamp},{label:P("lottie.asset.wrap-mode.repeat"),value:D.Repeat},{label:P("lottie.asset.wrap-mode.mirror"),value:D.Mirror}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.wrapModeV=t})}}),dt()],V.prototype,"wrapModeV",2);K([yt,dt()],V.prototype,"runtimeOptions",2);V=K([Ct({type:"Lottie",label:P("asset.lottie.title"),loaderType:"EditorLottie",importMenuConfig:{type:Mt.Upload,accept:".json"},viewer:ft,filterUploadFiles:zs,preUpload:Us,dragLayer:et.Lottie,customInspector:ki,async bundle(n,e,t){var k,A;const i=JSON.parse(await n.content.text()),s=n.meta,{jsonUrl:a,atlasUrl:r}=i,o=gt(n.name).split(".")[0],l=n.dependencies||(n.dependencies=[]),h=t.vfs,p=((k=l[0])==null?void 0:k.ref.refId)??Pt();let u;l[0]||(l[0]={key:"atlasUrl",ref:{refId:p}});let c=h.getFileById(p);c?u=c.meta:(u={id:p,type:ot.getRegisteredAssetMeta(N).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[],ignorePack:!0},t.addFile({name:o+"_atlas.atlas",assetId:p,url:null,parentId:n.parentId,main:null,meta:u}),c=h.getFileById(p),c.ignoreBundle=!0),u.colorDilate=s.colorDilate,u.filterMode=s.filterMode,u.wrapModeU=s.wrapModeU,u.wrapModeV=s.wrapModeV,u.mipmap=s.mipmap;const f=n.meta.runtimeOptions;let g=e.assetOptions.textureOptions;f!=null&&f.overwrite&&(g=Object.assign({},g,f)),u.runtimeOptions=g;const v=await(await fetch(r)).json();t.updateFile(p,{main:new Blob([JSON.stringify(v)]),meta:u}),await t.bundleSingleFile(c,e),i.atlasUrl="./"+gt(c.exportPath);const x=((A=l[1])==null?void 0:A.ref.refId)??Pt();let w;l[1]||(l[1]={key:"jsonUrl",ref:{refId:x}});let S=h.getFileById(x);S?w=S.meta:(w={id:x,type:ot.getRegisteredAssetMeta(ne).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[]},t.addFile({name:o+"_clip.json",assetId:x,url:null,parentId:n.parentId,main:null,meta:w}),S=h.getFileById(x),S.ignoreBundle=!0);const T=await(await fetch(a)).json();return T.lolitaAnimations=s.clips,t.updateFile(x,{main:new Blob([JSON.stringify(T)])}),await t.bundleSingleFile(S,e),i.jsonUrl="./"+gt(S.exportPath),{content:new Blob([JSON.stringify(i)])}}})],V);const Nn=Object.freeze(Object.defineProperty({__proto__:null,get LottieAsset(){return V}},Symbol.toStringTag,{value:"Module"})),Xs=it("div",{marginTop:"20px",fontSize:"12px",fontWeight:500,color:"$gray12"}),Ys=ut(function(n){const{asset:{textures:e,textureAtlas:t,missingTexture:i}}=n,{assetStore:s}=re(),[a,r]=b.useState([]),o=b.useMemo(()=>{if(!t)return[];const l=t.pages,h=[];for(let p=0;p<l.length;p+=1){const u=l[p];h.push({name:u.name,regions:u.regions.map(c=>c.name)})}return h},[t]);return b.useEffect(()=>{let l=!1;return Promise.all(e.map(h=>s.getAssetByRef(h))).then(h=>{l||r(h)}).catch(h=>{l||(console.warn("[SpineAtlasInspector] Failed to load atlas textures:",h),r([]))}),()=>{l=!0}},[s,e]),i?y.jsx(Xs,{children:"Missing atlas texture, please reupload atlas and image files."}):y.jsxs(y.Fragment,{children:[y.jsx(Kt,{label:"atlas textures",value:""}),a.map((l,h)=>y.jsx(jt,{dropLayer:et.Texture,label:"",value:l.name,assets:[],asset:l,onLocate:()=>{var u;const p=(u=e==null?void 0:e[h])==null?void 0:u.refId;p&&s.selectAsset(p)}},l.id)),y.jsx(Kt,{label:"atlas regions",value:""}),y.jsx(We,{label:"",items:o.map((l,h)=>({removable:!1,children:l.regions.map(u=>y.jsx(Kt,{label:"",value:u},u)),id:`${h}`,name:l.name}))})]})});var Zs=Object.defineProperty,Qs=Object.getOwnPropertyDescriptor,Vt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qs(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Zs(e,t,s),s};let At=class extends ot{constructor(e){super(e);d(this,"_textureAtlas");d(this,"textures",[]);d(this,"atlasText","");d(this,"missingTexture",!1)}get textureAtlas(){return this._textureAtlas}async initByMain(e){this.atlasText=await e.text();const t=this.meta,{textures:i}=t;this.textures=i;const a=(await Promise.all(this.textures.map(l=>this.root.assetStore.getAssetByRef(l)))).map(l=>l==null?void 0:l.engineObject),r=a.some(l=>l==null)||i.length===0;if(this.missingTexture=r,r)return;const o=Di.createTextureAtlas(this.atlasText,a);this._textureAtlas=o}};Vt([dt(),yt],At.prototype,"textures",2);Vt([E()],At.prototype,"atlasText",2);Vt([yt],At.prototype,"missingTexture",2);At=Vt([Ct({type:"SpineAtlas",label:P("asset.spine-atlas.title"),dragLayer:et.SpineAtlas,customInspector:Ys,loaderType:"SpineAtlas",preUpload:Ei,bundle(n){return n.dependencies=Ai(n.meta,["textures"]),{content:n.content}}})],At);function tn(n){return`// ${n}
|
|
11
|
+
*/var Vi=Ne("outline","minus","IconMinus",[["path",{d:"M5 12l14 0",key:"svg-0"}]]);const qi=ut(function(n){const[e,t]=b.useState(null),i=n.asset,{assetStore:s,inspectorFacade:a}=re(),r=(o,l,h)=>{a.assetChange(o,l,h)};return b.useEffect(()=>{s.getAssetByRef(i.texture).then(o=>{t(o)})},[i.texture]),y.jsxs(y.Fragment,{children:[y.jsx(ve.List,{model:i,configs:i.formSchema.items,onModelChange:(o,l)=>r(i.id,o,l)}),e&&y.jsxs(y.Fragment,{children:[y.jsx(ri,{}),y.jsx(tt,{justifyContent:"between",css:{padding:"$2 0"},children:y.jsx(oi,{children:"Texture Option"})}),y.jsx(li,{label:"Name",value:e.name,readOnly:!0}),y.jsx(ve.List,{model:e,configs:e.formSchema.items,onModelChange:(o,l)=>r(e.id,o,l)})]})]})});class ee{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.spriteRenderer.sprite=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("sprite");this.spriteRenderer=t.addComponent(Nt)}}d(ee,"entity"),d(ee,"spriteRenderer");class Hi extends Ue{constructor(){super()}setViewAsset(e,t){const i=t.createChild("sprite_entity"),s=i.addComponent(Nt);s.sprite=e.engineObject,this._entity=i}getDescription(e){var i;const t=(i=e.engineObject)==null?void 0:i.texture;if(t){const{width:s,height:a}=t;return`${s}x${a}`}else return""}}const at=1,Wi=220,Ji=180,Yt=ci._pixelsPerUnit??100,Gi={left:"x",bottom:"y",right:"z",top:"w"},Ki={left:{axis:"x",fromStart:!0},right:{axis:"x",fromStart:!1},top:{axis:"y",fromStart:!0},bottom:{axis:"y",fromStart:!1}},Yi=[["left","right"],["top","bottom"]],Xi={left:"width",right:"width",top:"height",bottom:"height"},Zi={left:"right",right:"left",top:"bottom",bottom:"top"},Qi=it(tt,{width:"220px"}),ts=it("div",{position:"relative",width:"100%",height:"180px",borderRadius:"$2",border:"1px solid $gray6",overflow:"hidden",backgroundImage:"linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"}),es=it("div",{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",border:"1px solid $gray9",background:"linear-gradient(135deg, rgba(76, 132, 255, 0.26) 0%, rgba(76, 132, 255, 0.08) 48%, rgba(76, 132, 255, 0.2) 100%)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.2)"}),is=it("canvas",{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",pointerEvents:"none"}),ss=it("div",{position:"absolute",borderRadius:"$1",backgroundColor:"rgba(126, 211, 129, 0.1)",pointerEvents:"none"}),Ce=it("div",{position:"absolute",top:0,bottom:0,width:"10px",marginLeft:"-5px",cursor:"ew-resize","&::before":{content:'""',position:"absolute",left:"50%",top:0,bottom:0,borderLeft:"1px dashed $blue9"}}),_e=it("div",{position:"absolute",left:0,right:0,height:"10px",marginTop:"-5px",cursor:"ns-resize","&::before":{content:'""',position:"absolute",top:"50%",left:0,right:0,borderTop:"1px dashed $blue9"}}),ns={flex:1,minWidth:0};function Z(n,e,t){return Math.min(t,Math.max(e,n))}function ht(n,e=2){const t=Math.pow(10,e);return Math.round(n*t)/t}function mt(n,e=0){return Number.isFinite(n)?n:e}function $t(n,e,t,i){return n=Z(mt(n),0,t),e=Z(mt(e),0,t),n+e>t&&(i?e=t-n:n=t-e),[n,e]}function Lt(n,e){const[t,i]=$t(n.x,n.z,1,e==="x"),[s,a]=$t(n.y,n.w,1,e==="y");return{x:ht(t,2),y:ht(s,2),z:ht(i,2),w:ht(a,2)}}function oe(n,e,t,i){const s=Math.max(at,Math.round(mt(e,at))),a=Math.max(at,Math.round(mt(t,at))),[r,o]=$t(n.left,n.right,s,i==="left"),[l,h]=$t(n.top,n.bottom,a,i==="top");return{left:Math.round(r),bottom:Math.round(h),right:Math.round(o),top:Math.round(l)}}function Pe(n,e,t){const i=Lt(n);return oe({left:i.x*e,bottom:i.y*t,right:i.z*e,top:i.w*t},e,t)}function as(n,e,t){const i=oe(n,e,t),s=Math.max(at,e),a=Math.max(at,t),r=ht(Z(i.left/s,0,1),2),o=ht(Z(i.bottom/a,0,1),2),l=ht(Z(i.right/s,0,1-r),2),h=ht(Z(i.top/a,0,1-o),2);return{x:r,y:o,z:l,w:h}}function rs(n,e,t,i){const a=Math.max(1,mt(t,1)),r=Math.max(1,mt(i,1)),o=Math.max(1,n-16*2),l=Math.max(1,e-16*2),h=Math.min(o,l),p=Math.max(a,r),u=h/p;return{width:Math.max(1,a*u),height:Math.max(1,r*u)}}function os(n,e=!0){const[t,i]=b.useState({width:0,height:0});return b.useLayoutEffect(()=>{if(!e){i({width:0,height:0});return}const s=n.current;if(!s)return;const a=()=>{i({width:s.clientWidth,height:s.clientHeight})};a();const r=new ResizeObserver(a);return r.observe(s),()=>{r.disconnect()}},[n,e]),t}const ls=ut(function(e){var de,fe,ge,me,ye,we;const{model:t,inspectorConfig:i,onModelChange:s}=e,{property:a,disabled:r,label:o,info:l}=i,{t:h}=Rt();if(!t||!a)return null;const p={width:t.engineObject.width*Yt,height:t.engineObject.height*Yt},u=Lt(t[a]??{x:0,y:0,z:0,w:0}),c=Pe(u,p.width,p.height),f=b.useRef(null),g=b.useRef(null),v=b.useRef(null),x=b.useRef(null),w=b.useRef(null),S=b.useRef(null),T=b.useRef(!1),k=b.useRef(!1),A=b.useRef(!1),lt=b.useRef(new Ht),z=b.useRef(new Ht),xt=b.useRef(new Ht),[ct,vt]=b.useState(!1),[nt,Y]=b.useState(null),O=os(f,ct),L=b.useMemo(()=>({width:O.width>0?O.width:Wi,height:O.height>0?O.height:Ji}),[O.height,O.width]);A.current=ct;const B=b.useMemo(()=>rs(L.width,L.height,p.width,p.height),[p.height,p.width,L.height,L.width]),$=b.useMemo(()=>({left:Z(c.left/Math.max(p.width,at),0,1),bottom:Z(c.bottom/Math.max(p.height,at),0,1),right:Z(c.right/Math.max(p.width,at),0,1),top:Z(c.top/Math.max(p.height,at),0,1)}),[c.bottom,c.left,c.right,c.top,p.height,p.width]),X=b.useCallback((m=!1)=>{if(S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),T.current=!1,k.current=!1,!m)return;const I=w.current,C=x.current;if(C){const _=(I==null?void 0:I.canvasCtx)??C.getContext("2d");_==null||_.clearRect(0,0,C.width,C.height)}},[]),Ot=b.useCallback(()=>{X();const m=w.current;if(m){if(m.renderTarget){const I=m.renderTarget.getColorTexture(0);I==null||I.destroy(!0),m.renderTarget.destroy(!0),m.renderTarget=null}try{t.engine.sceneManager.removeScene(m.scene)}catch{}m.scene.destroy(),w.current=null,X(!0)}},[t.engine,X]),ce=b.useCallback(()=>{const m=w.current,I=x.current;if(!m||!I)return!1;const C=window.devicePixelRatio||1,_=Math.round(B.width*C),j=Math.round(B.height*C);if(_<=0||j<=0)return!1;if((I.width!==_||I.height!==j)&&(I.width=_,I.height=j),m.renderTarget&&m.renderTarget.width===_&&m.renderTarget.height===j)return m.camera.aspectRatio=_/j,!0;if(m.renderTarget){const bt=m.renderTarget.getColorTexture(0);bt==null||bt.destroy(!0),m.renderTarget.destroy(!0)}const J=new Fe(t.engine,_,j,void 0,!1),rt=new pi(t.engine,_,j,J,hi.Depth,4),qt=new ImageData(new Uint8ClampedArray(_*j*4),_,j);return m.renderTarget=rt,m.imageData=qt,m.camera.aspectRatio=_/j,m.camera.renderTarget=rt,!0},[B.height,B.width,t.engine]),pe=b.useCallback(()=>{const m=w.current;if(!m||!m.spriteRenderer.sprite)return;const I=m.spriteRenderer.bounds,C=lt.current,_=z.current;I.getCenter(C),I.getExtent(_);const j=m.camera.aspectRatio>0?m.camera.aspectRatio:1,J=Math.max(_.x,p.width*.5,.5),rt=Math.max(_.y,p.height*.5,.5);m.camera.isOrthographic=!0,m.camera.orthographicSize=Math.max(rt,J/j)/Yt,m.camera.nearClipPlane=.1,m.camera.farClipPlane=100,m.cameraEntity.transform.setPosition(C.x,C.y,10),xt.current.set(C.x,C.y,0),m.cameraEntity.transform.lookAt(xt.current)},[p.height,p.width]),he=b.useCallback(()=>{const m=w.current,I=x.current;if(!m||!m.renderTarget||!m.imageData||!I)return;const C=t.engine;if(k.current)return;k.current=!0;try{m.camera.renderTarget=m.renderTarget,C.sceneManager.addScene(m.scene),C.update()}finally{try{C.sceneManager.removeScene(m.scene)}catch{}k.current=!1}m.renderTarget.getColorTexture(0).getPixelBuffer(0,0,m.renderTarget.width,m.renderTarget.height,0,m.imageData.data);const j=m.canvasCtx??I.getContext("2d");j==null||j.putImageData(m.imageData,0,0)},[t.engine]),Ft=b.useCallback(()=>{if(w.current)return;const m=x.current;if(!m)return;const I=new ui(t.engine);I.background.solidColor=new di(0,0,0,0);const C=I.createRootEntity("sprite_border_preview_root"),_=C.createChild("sprite_border_preview_camera"),j=_.addComponent(fi),rt=C.createChild("sprite_border_preview_sprite").addComponent(Nt);rt.sprite=t.engineObject??null,w.current={scene:I,camera:j,cameraEntity:_,spriteRenderer:rt,renderTarget:null,imageData:null,canvasCtx:m.getContext("2d")}},[t.engine,t.engineObject]),ue=b.useCallback(()=>{T.current||(T.current=!0,S.current=requestAnimationFrame(()=>{if(T.current=!1,S.current=null,!A.current)return;w.current||Ft();const m=w.current;m&&(m.spriteRenderer.sprite=t.engineObject??null),ce()&&(pe(),he())}))},[ce,pe,Ft,t.engineObject,he]),kt=b.useCallback((m,I)=>{const C=oe(m,p.width,p.height,I),_=as(C,p.width,p.height);t[a]=_;const j=I?Gi[I]:void 0;s==null||s(a,_,j)},[t,s,a,p.height,p.width]),Ke=b.useCallback((m,I)=>{const C=Lt(m,I);t[a]=C,s==null||s(a,C,I)},[t,s,a]),Ye=b.useCallback((m,I)=>{kt({...c,[m]:mt(I,0)},m)},[c,kt]),Dt=b.useMemo(()=>{const m=I=>C=>{C.preventDefault();const _=g.current,j=document.activeElement;_&&j instanceof HTMLElement&&_.contains(j)&&j.blur(),Y(I)};return{left:m("left"),right:m("right"),top:m("top"),bottom:m("bottom")}},[]);b.useEffect(()=>{if(!nt)return;const m=Ki[nt],I=_=>{const j=v.current;if(!j)return;const J=j.getBoundingClientRect();if(J.width<=0||J.height<=0)return;const rt=Lt(t[a]??{x:0,y:0,z:0,w:0}),qt=Pe(rt,p.width,p.height),bt=m.axis==="x"?_.clientX:_.clientY,ti=m.axis==="x"?J.left:J.top,ei=m.axis==="x"?J.right:J.bottom,xe=m.axis==="x"?J.width:J.height,ii=m.axis==="x"?p.width:p.height,si=Z(m.fromStart?(bt-ti)/xe:(ei-bt)/xe,0,1);kt({...qt,[nt]:si*ii},nt)},C=()=>{Y(null)};return window.addEventListener("mousemove",I),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",C)}},[kt,nt,t,a,p.height,p.width]),b.useEffect(()=>{if(!ct){Ot();return}w.current||Ft();const m=w.current;m&&(m.spriteRenderer.sprite=t.engineObject??null),ue()},[Ot,Ft,ct,ue,B.height,B.width,t.engineObject,t.height,(de=t.pivot)==null?void 0:de.x,(fe=t.pivot)==null?void 0:fe.y,(ge=t.region)==null?void 0:ge.height,(me=t.region)==null?void 0:me.width,(ye=t.region)==null?void 0:ye.x,(we=t.region)==null?void 0:we.y,t.width]),b.useEffect(()=>()=>{Ot()},[Ot]);const Xe=typeof o=="string"?h(o):o,Ze=typeof l=="string"?h(l):l,Qe=b.useMemo(()=>({x:"L",y:"B",z:"R",w:"T"}),[]);return y.jsx(ke,{disabled:r,label:Xe,info:Ze,min:0,max:1,step:.01,dragStep:.01,value:u,slotMapping:Qe,onChange:Ke,formEndSlot:y.jsx(gi,{disabled:r,side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:m=>m.preventDefault(),onOpenChange:m=>{vt(m),m||Y(null)},trigger:y.jsx(mi,{variant:"subtle",corner:!0,disabled:r,children:y.jsx(Ui,{size:14})}),children:y.jsxs(Qi,{ref:g,direction:"column",gap:"sm",children:[y.jsx(ts,{ref:f,children:y.jsxs(es,{ref:v,css:{width:`${B.width}px`,height:`${B.height}px`},children:[y.jsx(is,{ref:x}),y.jsx(ss,{css:{left:`${$.left*100}%`,right:`${$.right*100}%`,top:`${$.top*100}%`,bottom:`${$.bottom*100}%`}}),y.jsx(Ce,{onMouseDown:Dt.left,css:{left:`${$.left*100}%`}}),y.jsx(Ce,{onMouseDown:Dt.right,css:{left:`${(1-$.right)*100}%`}}),y.jsx(_e,{onMouseDown:Dt.top,css:{top:`${$.top*100}%`}}),y.jsx(_e,{onMouseDown:Dt.bottom,css:{top:`${(1-$.bottom)*100}%`}})]})}),y.jsx(tt,{direction:"column",gap:"xs",css:{width:"100%"},children:Yi.map(([m,I])=>y.jsx(tt,{gap:"sm",align:"v",children:[m,I].map(C=>y.jsx(tt,{direction:"column",css:ns,children:y.jsx(yi,{min:0,max:Math.max(0,p[Xi[C]]-c[Zi[C]]),dragStep:1,step:1,value:c[C],startSlot:C[0].toUpperCase(),endSlot:"px",onValueChange:_=>Ye(C,_)})},C))},m))})]})})})});class q{constructor(e=0,t=0,i=0,s=0,a=""){d(this,"x",0);d(this,"y",0);d(this,"width",0);d(this,"height",0);d(this,"name","");d(this,"isRotated",!1);d(this,"allowRotate");this.x=e,this.y=t,this.width=i,this.height=s,this.name=a}clone(){return new q(this.x,this.y,this.width,this.height,`${this.name}-clone`)}isContainedIn(e){return this.x>=e.x&&this.y>=e.y&&this.x+this.width<=e.x+e.width&&this.y+this.height<=e.y+e.height}static isContainedIn(e,t){return e.isContainedIn(t)}}var H=(n=>(n[n.BestShortSideFit=0]="BestShortSideFit",n[n.BestLongSideFit=1]="BestLongSideFit",n[n.BestAreaFit=2]="BestAreaFit",n[n.BottomLeftRule=3]="BottomLeftRule",n[n.ContactPointRule=4]="ContactPointRule",n))(H||{});class cs{constructor(){d(this,"binWidth");d(this,"binHeight");d(this,"allowRotate");d(this,"usedRectangles");d(this,"freeRectangles");this.binWidth=0,this.binHeight=0,this.allowRotate=!1,this.usedRectangles=[],this.freeRectangles=[]}init(e,t,i){this.binWidth=e,this.binHeight=t,this.allowRotate=i||!1,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(new q(0,0,e,t))}insert(e,t,i){let s=new q;const a={value:0},r={value:0},o=i||0,l=this.allowRotate;if(!this._canFit(e,t,l))return s;switch(o){case H.BestShortSideFit:s=this._findPositionForNewNodeBestShortSideFit(e,t,a,r,l);break;case H.BottomLeftRule:s=this._findPositionForNewNodeBottomLeft(e,t,a,r,l);break;case H.ContactPointRule:s=this._findPositionForNewNodeContactPoint(e,t,a,l);break;case H.BestLongSideFit:s=this._findPositionForNewNodeBestLongSideFit(e,t,r,a,l);break;case H.BestAreaFit:s=this._findPositionForNewNodeBestAreaFit(e,t,a,r,l);break}return s.height===0||this._placeRectangle(s),s}insert2(e,t){const i=[],s=t||0;for(;e.length>0;){let a=1/0,r=1/0,o=-1,l=new q,h=-1/0;for(let u=0;u<e.length;u++){const c=e[u],f=this._getAllowRotate(c);if(!this._canFit(c.width,c.height,f))continue;const g={value:0},v={value:0},x=this._scoreRectangle(c.width,c.height,s,g,v,f),w=this._getSortKey(c,s);g.value<a||g.value===a&&v.value<r?(a=g.value,r=v.value,l=x,o=u,h=w):o!==-1&&g.value!==1/0&&v.value!==1/0&&g.value===a&&v.value===r&&w>h&&(l=x,o=u,h=w)}if(o===-1)return i;this._placeRectangle(l);const p=e.splice(o,1)[0];p.x=l.x,p.y=l.y,p.isRotated=l.isRotated,i.push(p)}return i}_placeRectangle(e){let t=this.freeRectangles.length;for(let i=0;i<t;i++)this._splitFreeNode(this.freeRectangles[i],e)&&(this.freeRectangles.splice(i,1),i--,t--);this._purgeFreeList(),this._pruneFreeList(),this.usedRectangles.push(e)}_scoreRectangle(e,t,i,s,a,r){let o=new q;switch(s.value=1/0,a.value=1/0,i){case H.BestShortSideFit:o=this._findPositionForNewNodeBestShortSideFit(e,t,s,a,r);break;case H.BottomLeftRule:o=this._findPositionForNewNodeBottomLeft(e,t,s,a,r);break;case H.ContactPointRule:o=this._findPositionForNewNodeContactPoint(e,t,s,r),s.value=-s.value;break;case H.BestLongSideFit:o=this._findPositionForNewNodeBestLongSideFit(e,t,a,s,r);break;case H.BestAreaFit:o=this._findPositionForNewNodeBestAreaFit(e,t,s,a,r);break}return o.height===0&&(s.value=1/0,a.value=1/0),o}_findPositionForNewNodeBottomLeft(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0,s.value=1/0;let l,h;for(let p=0;p<r.length;p++)l=r[p],l.width>=e&&l.height>=t&&(h=l.y+t,(h<i.value||h===i.value&&l.x<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=h,s.value=l.x)),a&&l.width>=t&&l.height>=e&&(h=l.y+e,(h<i.value||h===i.value&&l.x<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=h,s.value=l.x));return o}_findPositionForNewNodeBestShortSideFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)if(l=r[f],l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),c=Math.max(h,p),(u<i.value||u===i.value&&c<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=u,s.value=c)),a&&l.width>=t&&l.height>=e){const g=Math.abs(l.width-t),v=Math.abs(l.height-e),x=Math.min(g,v),w=Math.max(g,v);(x<i.value||x===i.value&&w<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=x,s.value=w)}return o}_findPositionForNewNodeBestLongSideFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;s.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)l=r[f],l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),c=Math.max(h,p),(c<s.value||c===s.value&&u<i.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,i.value=u,s.value=c)),a&&l.width>=t&&l.height>=e&&(h=Math.abs(l.width-t),p=Math.abs(l.height-e),u=Math.min(h,p),c=Math.max(h,p),(c<s.value||c===s.value&&u<i.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,i.value=u,s.value=c));return o}_findPositionForNewNodeBestAreaFit(e,t,i,s,a){const r=this.freeRectangles,o=new q;i.value=1/0;let l,h,p,u,c;for(let f=0;f<r.length;f++)l=r[f],c=l.width*l.height-e*t,l.width>=e&&l.height>=t&&(h=Math.abs(l.width-e),p=Math.abs(l.height-t),u=Math.min(h,p),(c<i.value||c===i.value&&u<s.value)&&(o.x=l.x,o.y=l.y,o.width=e,o.height=t,o.isRotated=!1,s.value=u,i.value=c)),a&&l.width>=t&&l.height>=e&&(h=Math.abs(l.width-t),p=Math.abs(l.height-e),u=Math.min(h,p),(c<i.value||c===i.value&&u<s.value)&&(o.x=l.x,o.y=l.y,o.width=t,o.height=e,o.isRotated=!0,s.value=u,i.value=c));return o}_commonIntervalLength(e,t,i,s){return t<i||s<e?0:Math.min(t,s)-Math.max(e,i)}_contactPointScoreNode(e,t,i,s){const a=this.usedRectangles;let r=0;(e===0||e+i===this.binWidth)&&(r+=s),(t===0||t+s===this.binHeight)&&(r+=i);let o;for(let l=0;l<a.length;l++)o=a[l],(o.x===e+i||o.x+o.width===e)&&(r+=this._commonIntervalLength(o.y,o.y+o.height,t,t+s)),(o.y===t+s||o.y+o.height===t)&&(r+=this._commonIntervalLength(o.x,o.x+o.width,e,e+i));return r}_findPositionForNewNodeContactPoint(e,t,i,s){const a=this.freeRectangles,r=new q;i.value=-1;let o,l;for(let h=0;h<a.length;h++)o=a[h],o.width>=e&&o.height>=t&&(l=this._contactPointScoreNode(o.x,o.y,e,t),l>i.value&&(r.x=o.x,r.y=o.y,r.width=e,r.height=t,r.isRotated=!1,i.value=l)),s&&o.width>=t&&o.height>=e&&(l=this._contactPointScoreNode(o.x,o.y,t,e),l>i.value&&(r.x=o.x,r.y=o.y,r.width=t,r.height=e,r.isRotated=!0,i.value=l));return r}_splitFreeNode(e,t){const i=this.freeRectangles;if(t.x>=e.x+e.width||t.x+t.width<=e.x||t.y>=e.y+e.height||t.y+t.height<=e.y)return!1;let s;return t.x<e.x+e.width&&t.x+t.width>e.x&&(t.y>e.y&&t.y<e.y+e.height&&(s=e.clone(),s.height=t.y-s.y,s.width>0&&s.height>0&&i.push(s)),t.y+t.height<e.y+e.height&&(s=e.clone(),s.y=t.y+t.height,s.height=e.y+e.height-(t.y+t.height),s.width>0&&s.height>0&&i.push(s))),t.y<e.y+e.height&&t.y+t.height>e.y&&(t.x>e.x&&t.x<e.x+e.width&&(s=e.clone(),s.width=t.x-s.x,s.width>0&&s.height>0&&i.push(s)),t.x+t.width<e.x+e.width&&(s=e.clone(),s.x=t.x+t.width,s.width=e.x+e.width-(t.x+t.width),s.width>0&&s.height>0&&i.push(s))),!0}_pruneFreeList(){const e=this.freeRectangles;let t=0;for(;t<e.length;){let i=t+1;const s=e[t];for(;i<e.length;){const a=e[i];if(q.isContainedIn(s,a)){e.splice(t,1),t--;break}q.isContainedIn(a,s)&&(e.splice(i,1),i--),i++}t++}}_purgeFreeList(){const e=this.freeRectangles;for(let t=e.length-1;t>=0;t--){const i=e[t];(i.width<=0||i.height<=0)&&e.splice(t,1)}}_canFit(e,t,i){return!!(e<=this.binWidth&&t<=this.binHeight||i&&t<=this.binWidth&&e<=this.binHeight)}_getAllowRotate(e){return typeof e.allowRotate=="boolean"?e.allowRotate:this.allowRotate}_getSortKey(e,t){return t===H.BestAreaFit?e.width*e.height:Math.max(e.width,e.height)}}var F=(n=>(n[n.Success=0]="Success",n[n.NoImage=1]="NoImage",n[n.ImageLoadError=2]="ImageLoadError",n[n.OffscreenBlobError=3]="OffscreenBlobError",n[n.CanvasBlobError=4]="CanvasBlobError",n[n.PackError=5]="PackError",n))(F||{});class ps{constructor(){d(this,"mipmap");d(this,"wrapModeV");d(this,"wrapModeU");d(this,"filterMode");d(this,"anisoLevel");d(this,"version",0);d(this,"format",1);d(this,"atlasItems",[])}}class hs{constructor(){d(this,"id");d(this,"name");d(this,"atlasRotated");d(this,"atlasRegion");d(this,"atlasRegionOffset");d(this,"region");d(this,"pivot");d(this,"border");d(this,"pixelsPerUnit");d(this,"width");d(this,"height")}}class zt{}class us extends zt{constructor(){super(...arguments);d(this,"canvas");d(this,"context2D")}async parse(t){const i=t.outPut.info=new ps,s=t.option.padding??0,a=t.bins??[];t.outPut.imageFiles=[];const r=i.atlasItems;for(let o=0,l=a.length;o<l;o++){const h=a[o];this.initCanvas(h.width,h.height);const{context2D:p}=this,{rects:u}=h,c=new Array,f={img:"",type:"",width:h.width,height:h.height,sprites:c};for(let v=0,x=u.length;v<x;v++){const w=new hs,S=u[v];w.name=S.name,w.atlasRotated=S.isRotated,w.atlasRegion={x:S.x,y:S.y,w:S.width,h:S.height};const T=this.getItem(t.images,S.name),k=T==null?void 0:T.image;if(k){const A=S.x,lt=S.y,z=t.option.allowTrim?T.trimRect:void 0,xt=z?z.x:0,ct=z?z.y:0,vt=z?z.w:k.width,nt=z?z.h:k.height;if(z){const B=T.sourceWidth??k.width,$=T.sourceHeight??k.height;w.atlasRegionOffset={x:z.x,y:z.y,z:B-z.x-z.w,w:$-z.y-z.h}}let Y,O,L;if(S.isRotated){O=nt,L=vt;let B;try{B=new OffscreenCanvas(O,L)}catch{B=document.createElement("canvas"),B.width=O,B.height=L}const $=B.getContext("2d");$.translate(O,0),$.rotate(Math.PI/2),$.drawImage(k,xt,ct,vt,nt,0,0,vt,nt),Y=B}else O=vt,L=nt,Y=k;if(S.isRotated?p.drawImage(Y,0,0,O,L,A,lt,O,L):p.drawImage(Y,xt,ct,O,L,A,lt,O,L),s>0)try{const B=S.isRotated?0:xt,$=S.isRotated?0:ct;for(let X=1;X<=s;++X)p.drawImage(Y,B,$,O,1,A,lt-X,O,1),p.drawImage(Y,B,$+L-1,O,1,A,lt+L+X-1,O,1),p.drawImage(Y,B,$,1,L,A-X,lt,1,L),p.drawImage(Y,B+O-1,$,1,L,A+O+X-1,lt,1,L)}catch(B){console.error(JSON.stringify(B))}}c.push(w)}const g=await this.drawCanvas();if(g)t.outPut.imageFiles.push(g),r.push(f);else return F.CanvasBlobError}return F.Success}getItem(t,i){for(let s=t.length-1;s>=0;s--)if(t[s].name===i)return t[s];return null}initCanvas(t,i){if(this.canvas)this.canvas.width!==t||this.canvas.height!==i?(this.canvas.width=t,this.canvas.height=i):this.context2D.clearRect(0,0,t,i);else{try{this.canvas=new OffscreenCanvas(t,i)}catch{this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=i}this.context2D=this.canvas.getContext("2d",{willReadFrequently:!0})}}async drawCanvas(){return new Promise((t,i)=>{this.canvas instanceof HTMLCanvasElement?this.canvas.toBlob(s=>{s.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert canvas blob to ArrayBuffer"))})},"image/png",1):this.canvas.convertToBlob({type:"image/png",quality:1}).then(s=>{s.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert offscreen blob to ArrayBuffer"))})}).catch(s=>{console.error(JSON.stringify(s)),i(new Error("Failed to convert offscreen canvas to blob"))})})}}class ds extends zt{parse(e){return new Promise((t,i)=>{const{images:s}=e,{width:a,height:r,allowRotate:o,allowTrim:l}=e.option,h=s.length,p=[];for(let u=0;u<h;u++){const c=s[u];let f;const g=c.src;c.image||(g instanceof ArrayBuffer?f=this._loadImageFromBuffer(c):f=this._loadImageFromURL(c),p.push(f))}Promise.all(p).then(u=>{if(!l)for(let c=0,f=u.length;c<f;c++){const g=u[c];if(!(g.width<=a&&g.height<=r||!!o&&g.height<=a&&g.width<=r)){t(F.PackError);return}}t(F.Success)}).catch(u=>{console.error("OptLoadImage:Error",JSON.stringify(u)),i(F.ImageLoadError)})})}_loadImageFromBuffer(e){return new Promise((t,i)=>{const s=e.src,a=new window.Blob([s],{type:e.type}),r=new Image;r.onerror=function(){i(new Error("Failed to load image buffer"))},r.onload=function(){requestAnimationFrame(()=>{r.onload=null,r.onerror=null,r.onabort=null,e.image=r,t(r)})},r.crossOrigin="anonymous",r.src=URL.createObjectURL(a)})}_loadImageFromURL(e){return new Promise((t,i)=>{const s=new Image;s.onerror=function(){i(new Error("Failed to load image buffer"))},s.onload=function(){requestAnimationFrame(()=>{s.onload=null,s.onerror=null,s.onabort=null,e.image=s,t(s)})},s.crossOrigin="anonymous",s.src=e.src})}}const Et=[2048,1024,512,256,128,64,32,16,8,4,2];class fs extends zt{parse(e){const{option:t,images:i}=e,s=t.padding??0,a=!!t.allowRotate,r=t.method??H.BestLongSideFit;let o,l;if(t.square?o=l=Math.min(t.width,t.height):(o=t.width,l=t.height),t.pot){let c=!1,f=!1;for(let g=0,v=Et.length;g<v;++g){const x=Et[g];if(!c&&o>=x&&(o=x,c=!0),!f&&l>=x&&(l=x,f=!0),c&&f)break}}const h=[],p=s*2;for(let c=i.length-1;c>=0;c--){const f=i[c],g=f.image;if(!g)return F.ImageLoadError;const v=t.allowTrim?f.trimRect:void 0,x=v?v.w:g.width,w=v?v.h:g.height;if(!this.checkSizeLegality(x,w,o,l,p,a))return console.log("打包失败,",f.name,"单图尺寸超图集大小"),F.PackError;h.push(new q(0,0,x+p,w+p,f.name))}const u=[];for(;h.length>0;){const c=new cs;c.init(o,l,a);const f=c.insert2(h,r);if(f.length===0)return F.PackError;let g=0,v=0;for(let x=0;x<f.length;x++){const w=f[x],S=w.isRotated?w.height:w.width,T=w.isRotated?w.width:w.height,k=w.x+S,A=w.y+T;g=Math.max(g,k),v=Math.max(v,A),s>0&&(w.x+=s,w.y+=s,w.width-=p,w.height-=p)}if(t.square&&(g=v=Math.max(g,v)),t.pot){let x=!1,w=!1;for(let S=Et.length-1;S>=0;--S){const T=Et[S];if(!x&&g<=T&&(g=T,x=!0),!w&&v<=T&&(v=T,w=!0),x&&w)break}}u.push({rects:f,width:g,height:v})}return e.bins=u,F.Success}checkSizeLegality(e,t,i,s,a,r){const o=e+a,l=t+a;return r?o<=i&&l<=s||l<=i&&o<=s:o<=i&&l<=s}}const St=class St extends zt{static _getTrimContext(){let{_trimContext:e}=St;if(!e){let t;try{t=new OffscreenCanvas(1,1)}catch{t=document.createElement("canvas")}const i=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,ctx:i},St._trimContext=e}return e}parse(e){if(!e.option.allowTrim)return F.Success;const{images:t}=e,{canvas:i,ctx:s}=St._getTrimContext();for(let a=0,r=t.length;a<r;a++){const o=t[a],l=o.image;if(!l)continue;const{width:h,height:p}=l;o.sourceWidth=h,o.sourceHeight=p,i.width=h,i.height=p,s.drawImage(l,0,0);const u=s.getImageData(0,0,h,p).data,c=this._getTrimRect(u,h,p);(c.w<h||c.h<p)&&(o.trimRect=c)}return F.Success}_getTrimRect(e,t,i){let s=t,a=0,r=i,o=0;for(let l=0;l<i;l++){const h=l*t*4;for(let p=0;p<t;p++)e[h+p*4+3]>0&&(p<s&&(s=p),p>a&&(a=p),l<r&&(r=l),l>o&&(o=l))}return a<s||o<r?{x:0,y:0,w:1,h:1}:{x:s,y:r,w:a-s+1,h:o-r+1}}};d(St,"_trimContext",null);let ie=St;const Me=[new ds,new ie,new fs,new us],Xt={width:1024,height:1024,padding:1,allowRotate:!1,square:!1,pot:!1,method:H.BestLongSideFit};async function le(n,e){if(n.length===0)return{code:F.NoImage,msg:Te(F.NoImage)};if(e===void 0)e=Xt;else{const a=Object.keys(Xt);for(let r=a.length-1;r>=0;r--){const o=a[r];e[o]===void 0&&(e[o]=Xt[o])}}const t={};n.sort((a,r)=>r.name.toLowerCase().localeCompare(a.name.toLowerCase()));const i={option:e,images:n,outPut:t};let s=F.Success;for(let a=0;a<Me.length;a++){const r=await Me[a].parse(i);if(r!==F.Success){s=r;break}}return t.code=s,t.msg=Te(s),t}function Te(n){switch(n){case F.Success:return"打包成功!";case F.NoImage:return"传入图片长度为0.";case F.ImageLoadError:return"图片加载失败.";case F.CanvasBlobError:return"画布 blob 转换失败.";case F.OffscreenBlobError:return"离线画布 blob 转换失败.";case F.PackError:return"图集尺寸限制,打包失败。"}}async function It(n,e){await n.root.assetFacade.updateAssetProps(n.id,e)}async function gs(n,e){const t=await Promise.all(n.sprites.map(o=>e.getFileById(o.refId)).map(async o=>({...o,mainData:JSON.parse(await o.content.text())}))),[i,s]=Ni(t,o=>!!o.mainData.texture),a=$i(i,o=>o.mainData.texture.refId);return{packItems:await Promise.all(i.filter(o=>{var h;const l=(h=o.mainData.texture)==null?void 0:h.refId;return l?!!e.getFileById(l):!1}).map(async o=>{const l=o.mainData.texture.refId,p=await(await e.loadFile(l)).arrayBuffer();return{name:l,src:p}})),spriteAssetMap:a,spritesEmpty:s}}async function ms(n){const e=n.root.assetStore,t=await Promise.all(n.sprites.map(a=>e.getAssetByRef(a))),s=(await Promise.all(t.filter(a=>a&&a.texture).map(a=>e.getAssetByRef(a.texture)))).filter(a=>a).map(a=>({name:a.id,src:a.imageBuffer}));return await le(s,{padding:n.padding,width:n.maxWidth,height:n.maxHeight})}async function ys(n,e){let t,i=[];const{spriteAssetMap:s,packItems:a,spritesEmpty:r}=await gs(n,e);if(a.length>0?(t=await le(a,{padding:n.padding,width:n.maxWidth,height:n.maxHeight}),t.code===0?(i=t.info.atlasItems??[],i.forEach(o=>{const{sprites:l}=o;o.sprites=l.flatMap(h=>{const p=s[h.name],{atlasRegion:u,originalSize:c,atlasRotated:f}=h;return p.map(g=>Ae(g,u,c,f))})})):i=[],t.info.atlasItems=i):(t={code:1,msg:P("sprite.atlas.pack-error.no-sprite")},i=[]),r.length>0){const o=r.map(l=>Ae(l));i.push({img:"",sprites:o})}return t.info&&(t.info.atlasItems=i),t}function Ae(n,e,t=0,i=!1){const s=n.mainData,a=s.region,r=s.pivot,o=s.border,l={name:n.path,atlasRegion:e?{x:e.x,y:e.y,w:e.w,h:e.h}:{x:0,y:0,w:1,h:1},originalSize:t,atlasRotated:i,pivot:{x:r.x,y:r.y},region:{x:a.x,y:a.y,w:a.width,h:a.height},border:{x:o.x,y:o.y,z:o.z,w:o.w},width:s.width,height:s.height};return isNaN(s.width)||(l.width=s.width),isNaN(s.height)||(l.height=s.height),l}function ws(n){const e=[],t=i=>{const s=i.children,a=Object.keys(s);for(let r=a.length-1;r>=0;r--){const o=s[a[r]];o instanceof U?e.push(o):o instanceof Qt&&t(o)}};return t(n),e}function Ut(n,e){const t=e.id,i=n.sprites;for(let s=i.length-1;s>=0;s--)if(i[s].refId===t)return s;return-1}function je(n,e,t,i,s="#212324",a=15){var x;const{width:r,height:o}=t,{width:l,height:h}=e;let p,u,c,f;i.clearRect(0,0,t.width,t.height),i.fillStyle=s,r/o>l/h?(u=o,p=o/h*l,c=(r-p)/2,f=0,i.fillRect(0,0,c,o),i.fillRect(c+p,0,c,o)):(p=r,u=r/l*h,c=0,f=(o-u)/2,i.fillRect(0,0,r,f),i.fillRect(0,f+u,r,f)),i.drawImage(e,0,0,e.width,e.height,c,f,p,u);const g="Size: "+l+"x"+h+" Usage: "+n+"%";i.font=a+"px Arial";const v=((x=i.measureText(g))==null?void 0:x.width)||a*g.length;i.fillStyle="#000000",i.fillText(g,(r-v)/2,o-a*1/3-2),i.fillStyle="#ffffff",i.fillText(g,(r-v)/2,o-a/2-2)}function xs(n){return n.sprites.length>0}async function Be(n,e){await It(n,{texture:e?e.getCurrentRef():null})}async function Tt(n,e){const{belongToAtlas:t}=e,i=t==null?void 0:t.refId;if(i&&i!==n.id){const s=await n.root.assetStore.getAssetByRef(t);if(s){const a=s.sprites.filter(r=>r.refId!==e.id);a.length!==s.sprites.length&&await It(s,{sprites:a})}}if(i!==n.id&&await It(e,{belongToAtlas:n.getCurrentRef()}),Ut(n,e)<0){const s=[...n.sprites,e.getCurrentRef()];await It(n,{sprites:s})}}async function se(n,e){var i;((i=e.belongToAtlas)==null?void 0:i.refId)===n.id&&await It(e,{belongToAtlas:null});const t=Ut(n,e);if(t>=0){const s=n.sprites.filter((a,r)=>r!==t);await It(n,{sprites:s})}}const vs=ut(({asset:n,sprite:e})=>{const{assetStore:t}=n.root,i=Object.values(t.assets).filter(s=>s.getMetaConfig().type==="SpriteAtlas");return y.jsx(jt,{direction:"column",dropLayer:et.Sprite,assets:i,onSelect:async s=>{await se(n,e),await Tt(s,e)},onDelete:()=>{se(n,e)},onLocate:()=>{n&&n.id&&t.selectAsset(n.id)},asset:n,value:n.name})}),bs=ut(({model:n})=>{const{t:e}=Rt(),{assetStore:t}=n.root;Ss(n);const i=n.belongToAtlas?t.getAsset(n.belongToAtlas.refId):null,s=Object.values(t.assets).filter(a=>a.getMetaConfig().type==="SpriteAtlas");return y.jsxs(tt,{fullWidth:!0,css:{padding:"0 $0_5 $1"},children:[y.jsx(wi,{size:"1",css:{marginTop:"$1"},children:e("sprite.atlas.belong-to")}),n.belongToAtlas?y.jsx(vs,{asset:i,sprite:n},i.id):y.jsx(jt,{dropLayer:et.Sprite,assets:s,onSelect:a=>{Tt(a,n)},trigger:y.jsx(tt,{align:"h",css:{padding:"$1 $2 $1"},children:y.jsx(_t,{size:"sm",variant:"solid",css:{padding:"$1 $6"},children:e("sprite.atlas.belong-to")})}),label:"",value:null,asset:null})]})});async function Ss(n){const e=n.root.assetStore,t=n.belongToAtlas,i=t?await e.getAssetByRef(t):null;if(i){Ut(i,n)<0&&await n.root.assetFacade.updateAssetProps(i.id,{sprites:[...i.sprites,n.getCurrentRef()]});return}t&&await n.root.assetFacade.updateAssetProps(n.id,{belongToAtlas:null})}var Is=Object.defineProperty,Rs=Object.getOwnPropertyDescriptor,st=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rs(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Is(e,t,s),s};const W=new De;function We(n){return n.quickPivot===9}function Oe(n){switch(n){case 0:W.set(.5,.5);break;case 1:W.set(0,1);break;case 2:W.set(.5,1);break;case 3:W.set(1,1);break;case 4:W.set(0,.5);break;case 5:W.set(1,.5);break;case 6:W.set(0,0);break;case 7:{W.set(.5,0);break}case 8:{W.set(1,0);break}}}let U=class extends ot{constructor(e){super(e);d(this,"_delOnTexDel");d(this,"_customWidth");d(this,"_customHeight");d(this,"acceptDragLayer",et.Texture);d(this,"texture",null);d(this,"width");d(this,"height");d(this,"region",{x:0,y:0,width:1,height:1});d(this,"quickPivot",0);d(this,"pivot",{x:.5,y:.5});d(this,"border",{x:0,y:0,z:0,w:0});d(this,"belongToAtlas",null)}async afterDelete(){this.engineObject.destroy(!0);const{belongToAtlas:e}=this;if(e){const t=await this.root.assetStore.getAssetByRef(e);if(t){const i=Ut(t,this);i>-1&&t.sprites.splice(i,1),this.belongToAtlas=null,await this.root.assetFacade.persistAssetMain(t.id)}}this._delOnTexDel&&(this._delOnTexDel(),this._delOnTexDel=null)}getMainData(){const e=this[be]??{},t={};return Object.keys(e).forEach(i=>{switch(i){case"width":isNaN(this._customWidth)||(t.width=this._customWidth);break;case"height":isNaN(this._customHeight)||(t.height=this._customHeight);break;default:t[i]=this[i];break}}),JSON.stringify(t)}async initByMain(e){const t=new xi(this.engine),i=JSON.parse(await e.text());if(isNaN(i.width)||(t.width=this._customWidth=i.width),isNaN(i.height)||(t.height=this._customHeight=i.height),i.texture){const a=await this.root.assetStore.getAssetByRef(i.texture);a&&(await a.ensureReady(),t.texture=a.engineObject)}for(const a in i)this[a]=i[a];this.bindEngineObject(t);const s=new Ee(this.engine);s.addComponent(Nt).sprite=t,this.setDragTempEntity(s),await this.applyBoundPathChange("name",R.Input,this.name)}async initByCreation(){const{assetStore:e,assetUIStore:t}=this.root,{pickedAssets:i}=t,s=JSON.parse(this.getMainData());if(i&&i.length===1){const a={refId:i[0]},r=await e.getAssetByRef(a);r instanceof Ve?(r.setTextureType(qe.Sprite),s.texture=a):r instanceof U&&r.texture&&(s.texture={refId:r.texture.refId})}return s}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:s}=t.transform,a={components:[{class:"SpriteRenderer",id:Pt(),props:{drawMode:0,enabled:!0,flipX:!1,flipY:!1,maskInteraction:0,maskLayer:vi.Everything,sprite:this.getCurrentRef()}}],id:e.id,isActive:!0,isClone:!1,name:this.name?"sprite-"+this.name:"sprite",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:s.x,y:s.y,z:s.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}initByEngineObject(e){const t=Object.keys(this[be]),i=["texture","quickPivot","belongToAtlas"],s=a=>!i.includes(a);t.filter(s).forEach(a=>{const r=e[a];typeof r=="object"?Object.keys(r).forEach(l=>{this[a][l]=r[l]}):this[a]=r}),this.bindEngineObject(e)}async _onDrop(e,t){const i="texture";this.dropping=!1,this.texture=t.getCurrentRef(),this.formSchema.getPropertyConfig(i).onChange(this,i,t),this.updateThumbnail()}};st([M({info:"sprite.texture.info",label:"sprite.texture.label",type:R.AssetPicker,assetType:"Texture",customFilter:n=>n.isSubAsset===!1,onChange:async(n,e,t)=>{const i=n.engineObject;if(n._delOnTexDel&&(n._delOnTexDel(),n._delOnTexDel=null),await n.applyBoundPathChange("texture",R.AssetPicker,t==null?void 0:t.getCurrentRef()),t){const s=()=>{var a;(a=n._delOnTexDel)==null||a.call(n),n._delOnTexDel=null,n.texture=null,n.applyBoundPathChange("texture",R.AssetPicker,void 0),n.updateThumbnail()};t.on("delete",s),n._delOnTexDel=()=>{t.off("delete",s)}}isNaN(n._customWidth)?n.width=i.width:(n.width=n._customWidth,await n.applyBoundPathChange("width",R.Number,n._customWidth)),isNaN(n._customHeight)?n.height=i.height:(n.height=n._customHeight,await n.applyBoundPathChange("height",R.Number,n._customHeight))}}),E()],U.prototype,"texture",2);st([M({label:"sprite.width.label",info:"sprite.width.info",type:R.Number,triggerAfterInit:!1,async onChange(n,e,t){isNaN(t)||(n._customWidth=t,await n.applyBoundPathChange("width",R.Number,t))}}),E()],U.prototype,"width",2);st([M({label:"sprite.height.label",info:"sprite.height.info",type:R.Number,triggerAfterInit:!1,async onChange(n,e,t){isNaN(t)||(n._customHeight=t,await n.applyBoundPathChange("height",R.Number,t))}}),E()],U.prototype,"height",2);st([M({info:"sprite.region.info",label:"sprite.region.label",type:R.Rect,min:0,max:1,dragStep:.01,onChange(n,e,t){n.applyBoundPathChange("region",R.Rect,t)}}),E()],U.prototype,"region",2);st([bi({setPath:"pivot",getActualEditorValue:n=>(Oe(n),new De().copyFrom(W)),getEditorValue:n=>{const{x:e,y:t}=n;return e===.5&&t===.5?0:e===0&&t===1?1:e===.5&&t===1?2:e===1&&t===1?3:e===0&&t===.5?4:e===1&&t===.5?5:e===0&&t===0?6:e===.5&&t===0?7:e===1&&t===0?8:9}}),M({info:"sprite.quick-pivot.info",label:"sprite.quick-pivot.label",type:R.Select,value:0,options:[{label:"sprite.quick-pivot.center",value:0},{label:"sprite.quick-pivot.top-left",value:1},{label:"sprite.quick-pivot.top",value:2},{label:"sprite.quick-pivot.top-right",value:3},{label:"sprite.quick-pivot.left",value:4},{label:"sprite.quick-pivot.right",value:5},{label:"sprite.quick-pivot.bottom-left",value:6},{label:"sprite.quick-pivot.bottom",value:7},{label:"sprite.quick-pivot.bottom-right",value:8},{label:"sprite.quick-pivot.custom",value:9}],onChange(n,e,t){We(n)?W.copyFrom(n.pivot):Oe(t),n.pivot.x=W.x,n.pivot.y=W.y,n.applyBoundPathChange("pivot",R.Vector2,W)}}),E()],U.prototype,"quickPivot",2);st([M({info:"sprite.pivot.info",label:"sprite.pivot.label",type:R.Vector2,onChange(n,e,t){n.quickPivot===9&&n.applyBoundPathChange("pivot",R.Vector2,t)},when:We}),E()],U.prototype,"pivot",2);st([M({info:"sprite.border.info",label:"sprite.border.label",customComponent:ls,slotMapping:{x:"Left",y:"Down",z:"Right",w:"Up"},onChange(n,e,t){n.applyBoundPathChange("border",R.Vector4,t)}}),E()],U.prototype,"border",2);st([M({info:P("sprite.belong.info"),label:P("sprite.belong.label"),customComponent:bs}),E()],U.prototype,"belongToAtlas",2);st([Si()],U.prototype,"getMainData",1);st([Bt],U.prototype,"_onDrop",1);U=st([Ct({type:"sprite",label:P("asset.sprite.title"),loaderType:"Sprite",extname:"sprite",importMenuConfig:{type:Mt.Upload|Mt.Add,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:Hi,thumbnail:ee,defaultName:"Sprite",dragLayer:et.Sprite,dragType:"2d",preUpload:async(n,e,t,i)=>{const s=Le(n.main,"sprite.png"),a=s.name;if(i)if(i.meta.type==="Texture"){await Ii.assets.update(i.serverId,{file:s});return}else throw`Can't overwrite type: ${i.meta.type}, name: ${a}`;const r=await t.root.assetFacade.createAssetByUpload({uploadAssetFile:{...n,main:s},assetType:"Texture"});return r.setTextureType(qe.Sprite),new File([JSON.stringify({texture:r.getCurrentRef()})],gt(a,Se(a))+"-spr"+Se(a))},customInspector:qi,async bundle({id:n,content:e,path:t},i,s){const a=s.vfs;return{content:new Blob([await Fi(n,await e.text(),t,async r=>{const o=a.getFileById(r);if(!o)return null;const l=o.content??await a.loadFile(o.id);return l?l.text():null})])}}})],U);const Ln=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAsset(){return U}},Symbol.toStringTag,{value:"Module"})),Cs=it("div",{position:"relative",width:"100%",marginBottom:"$2",aspectRatio:"1/1"}),_s=it("div",{position:"absolute",width:"100%",height:"100%",padding:"$1",boxSizing:"border-box","& canvas":{width:"100%",height:"100%",border:"1px solid $grayA4",borderRadius:"$3",overflow:"hidden"}}),Ps=b.forwardRef(function(e,t){const{buttonContent:i,onClick:s}=e;return y.jsxs(tt,{direction:"column",fullWidth:!0,children:[y.jsx(Cs,{children:y.jsx(_s,{children:y.jsx("canvas",{ref:t,width:"400",height:"400"})})}),i&&y.jsx(tt,{align:"h",css:{margin:"$0 auto"},children:y.jsx(_t,{size:"sm",variant:"solid",css:{padding:"0 $14"},onClick:s,children:i})})]})});function Ms(n,e){return new Promise((t,i)=>{const s=new window.Blob([n],{type:e}),a=new window.Image,r=URL.createObjectURL(s);let o=!1;const l=()=>{o||(o=!0,URL.revokeObjectURL(r))};a.crossOrigin="anonymous",a.onerror=()=>{l(),i(new Error("Failed to load image buffer"))},a.onload=()=>{requestAnimationFrame(()=>{l(),t(a)})},a.src=r})}const Ts=ut(({item:n})=>{const[e,t]=b.useState(null),{assetStore:i}=n.root,{t:s}=Rt(),a=Object.values(i.assets).filter(r=>!r.isSubAsset&&r.getMetaConfig().type==="Texture");return b.useEffect(()=>{let r=!1;return n.texture?i.getAssetByRef(n.texture).then(o=>{r||t(o)}):t(null),()=>{r=!0}},[n.texture]),y.jsxs(y.Fragment,{children:[y.jsx(jt,{dropLayer:et.Sprite,assets:a,onSelect:r=>{Be(n,r)},onDelete:()=>{Be(n,null)},onLocate:()=>{var r;(r=n.texture)!=null&&r.refId&&i.selectAsset(n.texture.refId)},label:s("sprite.texture.label"),value:e&&e.name,asset:e}),y.jsx(Ri,{label:s("sprite.region.label"),value:{x:n.region.x,y:n.region.y,width:n.region.width,height:n.region.height},onChange:(r,o)=>{n.root.inspectorFacade.assetChange(n.id,"region",{...n.region,[o]:r[o]})},min:0,max:1}),y.jsx(Ci,{label:s("sprite.quick-pivot.label"),value:n.quickPivot,options:[{label:s("sprite.quick-pivot.center"),value:0},{label:s("sprite.quick-pivot.top-left"),value:1},{label:s("sprite.quick-pivot.top"),value:2},{label:s("sprite.quick-pivot.top-right"),value:3},{label:s("sprite.quick-pivot.left"),value:4},{label:s("sprite.quick-pivot.right"),value:5},{label:s("sprite.quick-pivot.bottom-left"),value:6},{label:s("sprite.quick-pivot.bottom"),value:7},{label:s("sprite.quick-pivot.bottom-right"),value:8},{label:s("sprite.quick-pivot.custom"),value:9}],onChange:r=>{n.root.inspectorFacade.assetChange(n.id,"quickPivot",r)}}),n.quickPivot===9&&y.jsx(_i,{label:"",value:{x:0,y:0}}),y.jsx(ke,{label:s("sprite.border.label"),value:{x:n.border.x,y:n.border.y,z:n.border.z,w:n.border.w},onChange:(r,o)=>{n.root.inspectorFacade.assetChange(n.id,"border",{...n.border,[o]:r[o]})},min:0,max:1})]})}),As=ut(({model:n,inspectorConfig:e})=>{const{label:t}=e,i=n.sprites,{assetStore:s}=n.root,a=xs(n),{t:r}=Rt();js(n);const o=Object.values(s.assets).filter(c=>{switch(c.getMetaConfig().type){case"sprite":return!i.find(g=>g.refId===c.id);case"Folder":return!0}return!1}),l=b.useRef(null);let h,p;b.useLayoutEffect(()=>{h=l.current,p=h==null?void 0:h.getContext("2d"),n.previewImage&&p&&je(n.usage,n.previewImage,h,p)});async function u(){var c;if(a){if(p){const f=await ms(n),g=((c=f.info)==null?void 0:c.atlasItems)??[],v=g.reduce((S,T)=>S+T.sprites.reduce((k,A)=>k+A.width*A.height,0),0),x=g.reduce((S,T)=>S+T.width*T.height,0),w=x>0?Number((v/x*100).toFixed(2)):0;f.code===0?Ms(f.imageFiles[0],"image/png").then(S=>{n.replacePreview(S),je(w,S,h,p)}):Ie({title:r("sprite.atlas.pack-error.title"),description:f.msg})}}else Ie({title:r("sprite.atlas.pack-error.title"),description:r("sprite.atlas.pack-error.no-sprite")})}return y.jsxs(y.Fragment,{children:[y.jsx(He,{label:t,items:i.map((c,f)=>{const g=s.getAsset(c.refId);return{removable:!0,children:y.jsx(Ts,{item:g}),id:`${f}`,name:g.getRouteString()}}),onDelete:async c=>{const f=await s.getAssetByRef(i[c.id]);await se(n,f)}}),y.jsxs(tt,{align:"both",direction:"column",children:[y.jsx(jt,{assets:o,dropLayer:et.Sprite|et.Folder,customFilter:c=>c instanceof U||c instanceof Qt,onSelect:c=>{if(c instanceof U)Tt(n,c);else if(c instanceof Qt){const f=ws(c);for(let g=f.length-1;g>=0;g--)Tt(n,f[g])}},trigger:y.jsx(_t,{size:"sm",variant:"solid",css:{flex:1},startSlot:y.jsx(ze,{}),children:r("sprite.atlas.add-object.label")}),label:r("sprite.atlas.add-sprite"),value:null,asset:null}),y.jsx(_t,{size:"sm",variant:"solid",positive:!0,fullWidth:!0,css:{margin:"$1"},onClick:u,children:r("sprite.atlas.pack-preview.label")})]}),a&&y.jsx(Ps,{ref:l})]})});async function js(n){var s;const e=n.root.assetStore.assets,t=n.sprites,i=[];for(let a=0;a<t.length;a++){const r=t[a],o=e[r.refId];o&&(i.push(r),((s=o.belongToAtlas)==null?void 0:s.refId)!==n.id&&await Tt(n,o))}i.length!==t.length&&await n.root.assetFacade.updateAssetProps(n.id,{sprites:i})}var Bs=Object.defineProperty,Os=Object.getOwnPropertyDescriptor,G=(n,e,t,i)=>{for(var s=i>1?void 0:i?Os(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Bs(e,t,s),s};let N=class extends ot{constructor(e){super(e);d(this,"acceptDragLayer",et.Sprite);d(this,"previewTexture2D");d(this,"previewImage");d(this,"usage",0);d(this,"maxWidth",1024);d(this,"maxHeight",1024);d(this,"padding",2);d(this,"allowRotation",!1);d(this,"tightPacking",!1);d(this,"mipmap",!1);d(this,"filterMode",Q.Bilinear);d(this,"wrapModeU",D.Repeat);d(this,"wrapModeV",D.Repeat);d(this,"anisoLevel",1);d(this,"sprites",[]);this.setNameByIncrease("SpriteAtlas");const t=this.formSchema;t.addGroup(P("sprite.atlas.packing"),["maxWidth","maxHeight","padding","allowRotation","tightPacking"]),t.addGroup(P("sprite.atlas.export"),["filterMode","wrapModeU","wrapModeV","anisoLevel","mipmap"]),t.addGroup(P("sprite.atlas.list"),["sprites"])}static async updateSubTextureAssets(e,t,i,s,a){var f;const r=e.meta,o=a.vfs,l=e.dependencies||(e.dependencies=[]),h=((f=l[t])==null?void 0:f.ref.refId)??Pt(),p=gt(e.name).split(".")[0];l[t]||(l[t]={key:"atlasItems["+t+"].img",ref:{refId:h}});let u=o.getFileById(h),c;return u?c=u.meta:(c={id:h,type:ot.getRegisteredAssetMeta(Ve).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[]},a.addFile({name:p+"_image_"+t,assetId:h,url:null,parentId:e.parentId,main:null,meta:c}),u=o.getFileById(h),u.ignoreBundle=!0),c.colorDilate=r.colorDilate??!1,c.filterMode=r.filterMode??Q.Bilinear,c.wrapModeU=r.wrapModeU??D.Repeat,c.wrapModeV=r.wrapModeV??D.Repeat,c.anisoLevel=r.anisoLevel??1,c.runtimeOptions=r.runtimeOptions??{},a.updateFile(h,{main:new Blob([i],{type:"image/png"}),meta:c}),await a.bundleSingleFile(u,s),u}replacePreview(e){this.previewImage=e;const t=this.previewTexture2D;this.previewTexture2D=new Fe(this.engineObject.engine,e.width,e.height),this.previewTexture2D.setImageSource(e),t&&t.destroy(!0)}async afterDelete(){this.engineObject.destroy(!0);const{sprites:e,id:t}=this,i=this.root.assetStore,a=[...e].map(async r=>{var o;try{const h=await i.getAssetByRef(r);((o=h==null?void 0:h.belongToAtlas)==null?void 0:o.refId)===t&&await this.root.assetFacade.updateAssetProps(h.id,{belongToAtlas:null})}catch(l){console.warn(`[SpriteAtlasAsset] Failed to cleanup sprite relation: ${(r==null?void 0:r.refId)??"unknown"}`,l)}});await Promise.allSettled(a),e.length=0}addSprites(e){const t=zi([...this.sprites,...e.map(s=>({refId:s.id}))],s=>s.refId),i=e.map(s=>this.root.assetFacade.updateAssetProps(s.id,{belongToAtlas:{refId:this.id}}));return i.push(this.root.assetFacade.updateAssetProps(this.id,{sprites:t})),Promise.all(i)}async initByMain(e){const{engine:t}=this,i=JSON.parse(await e.text());for(const a in i)this[a]=i[a];const s=new Re(t);this.bindEngineObject(s),s.asset=this}async initByCreation(){this.setNameByIncrease("SpriteAtlas");const e=new Re(this.engine);return this.bindEngineObject(e),e.asset=this,this.getMainData()}async _onDrop(e,t){this.dropping=!1,!this.sprites.find(i=>i.refId===t.id)&&await this.addSprites([t])}};G([M({info:"sprite.atlas.max-width.info",label:"sprite.atlas.max-width.label",type:R.Input}),E()],N.prototype,"maxWidth",2);G([M({info:"sprite.atlas.max-height.info",label:"sprite.atlas.max-height.label",type:R.Input}),E()],N.prototype,"maxHeight",2);G([M({info:"sprite.atlas.padding.info",label:"sprite.atlas.padding.label",type:R.Number,min:0,max:5,dragStep:1}),E()],N.prototype,"padding",2);G([M({info:"sprite.atlas.rotation.info",label:"sprite.atlas.rotation.label",type:R.Toggle}),E()],N.prototype,"allowRotation",2);G([M({info:"sprite.atlas.tight-packing.info",label:"sprite.atlas.tight-packing.label",type:R.Toggle}),E()],N.prototype,"tightPacking",2);G([M({label:"sprite.atlas.mipmap.label",type:R.Toggle}),E()],N.prototype,"mipmap",2);G([M({label:"sprite.atlas.filter-mode.label",type:R.Select,value:Q.Bilinear,options:[{label:"sprite.atlas.filter-mode.point",value:Q.Point},{label:"sprite.atlas.filter-mode.bilinear",value:Q.Bilinear},{label:"sprite.atlas.filter-mode.trilinear",value:Q.Trilinear}]}),E()],N.prototype,"filterMode",2);G([M({label:"sprite.atlas.wrap-mode-u.label",type:R.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:D.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:D.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:D.Mirror}]}),E()],N.prototype,"wrapModeU",2);G([M({label:"sprite.atlas.wrap-mode-v.label",type:R.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:D.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:D.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:D.Mirror}]}),E()],N.prototype,"wrapModeV",2);G([M({label:"sprite.atlas.aniso-level.label",type:R.Slider,dragStep:1,max:16,min:1}),E()],N.prototype,"anisoLevel",2);G([Pi({key:"addSprite"}),M({label:P("sprite.atlas.sprite-list.label"),customComponent:As}),E()],N.prototype,"sprites",2);G([Bt],N.prototype,"addSprites",1);N=G([Ct({type:"SpriteAtlas",label:P("asset.sprite-atlas.title"),loaderType:"SpriteAtlas",extname:"atlas",importMenuConfig:{type:Mt.Add},async bundle(n,e,t){var l;const i=t.vfs,s=n.content??await i.loadFile(n.id),a=JSON.parse(await s.text()),r=n.meta,o=n.dependencies||(n.dependencies=[]);if(r.ignorePack){const h=a.atlasItems;for(let p=0,u=h.length;p<u;p++){const c=a.atlasItems[p],f=await fetch(c.img).then(v=>v.arrayBuffer()),g=await N.updateSubTextureAssets(n,p,f,e,t);c.type=g.exportType,c.img="./"+gt(g.path)}}else{const h=n.id,p=a.sprites;for(let c=p.length-1;c>=0;c--){const f=p[c].refId,g=i.getFileById(f);if(g){const v=g.content??await i.loadFile(g.id);((l=JSON.parse(await v.text()).belongToAtlas)==null?void 0:l.refId)!==h&&(p.splice(c,1),console.warn("Sprite.belongToAtlas is not equal to this asset."))}else p.splice(c,1),console.warn("SpriteAsset[refId:",f,"] not found")}const u=await ys(a,i);if(u.code===0){const c=u.info;for(const g in c)a[g]=c[g];const f=u.imageFiles;for(let g=0,v=f.length;g<v;g++){const x=await N.updateSubTextureAssets(n,g,f[g],e,t),w=a.atlasItems[g];w.type=x.exportType,w.img="./"+gt(x.path)}}else{for(let c=0,f=o.length;c<f;c++){const g=o[c].ref.refId;i.deleteFile(g)}o.length=0}}return delete a.usage,delete a.allowRotation,delete a.maxHeight,delete a.maxWidth,delete a.padding,delete a.sprites,delete a.tightPacking,{content:new Blob([JSON.stringify(a)])}}})],N);const $n=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAtlasAsset(){return N}},Symbol.toStringTag,{value:"Module"}));var Fs=Object.defineProperty,ks=Object.getOwnPropertyDescriptor,Ds=(n,e,t,i)=>{for(var s=i>1?void 0:i?ks(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Fs(e,t,s),s};let ne=class extends ot{initByMain(n,e){return Promise.resolve()}};ne=Ds([Ct({type:"LottieAnimation",async bundle(n){const e=JSON.parse(await n.content.text());return{content:new Blob([JSON.stringify(e)])}}})],ne);const Es=it("div",{display:"grid",columnGap:"$1",gridColumn:2/-1,gridTemplateColumns:"minmax(0, 4fr) repeat(1, 2fr) repeat(1, auto) repeat(1, 2fr) repeat(1, auto)",marginBottom:"$1"}),Ls=function({clip:n,removeClip:e,onClipChange:t}){const{t:i}=Rt();return y.jsxs(Es,{children:[y.jsx(Wt,{size:"sm",value:n.name??"",placeholder:i("lottie.clip.name"),onChange:s=>{t({name:s.currentTarget.value})}}),y.jsx(Wt,{size:"sm",value:n.start??"",placeholder:i("lottie.clip.start"),onChange:s=>{t({start:+s.currentTarget.value})}}),y.jsx(Vi,{width:12,onClick:e}),y.jsx(Wt,{size:"sm",value:n.end??"",placeholder:i("lottie.clip.end"),onChange:s=>{t({end:+s.currentTarget.value})}})]})},$s=ut(function(n){const e=n.model,t=e.getViewer(),{inspectorFacade:i}=re(),{t:s}=Rt(),[a,r]=b.useState(()=>Array.isArray(e.clips)?[...e.clips]:[]);b.useEffect(()=>{r(Array.isArray(e.clips)?[...e.clips]:[])},[e,e.clips]),b.useEffect(()=>{t==null||t.setClips(a)},[a,t]);const o=u=>{r(u),i.assetChange(e.id,"clips",u,"asset-meta")},l=()=>{o([...a,{}])},h=u=>{u<0||u>=a.length||o(a.filter((c,f)=>f!==u))},p=(u,c)=>{if(u<0||u>=a.length)return;const f={...a[u],...c},g=a.map((v,x)=>x===u?f:v);o(g)};return y.jsxs(Mi,{title:s("lottie.clips.title"),defaultOpen:!0,collapsible:!0,children:[a.map((u,c)=>y.jsx(Ls,{clip:u,removeClip:()=>h(c),onClipChange:f=>p(c,f)},`${e.id}-${c}`)),y.jsx(tt,{align:"h",css:{margin:"0 auto",padding:"$1 0 0 0"},children:y.jsx(_t,{size:"sm",variant:"soft",startSlot:y.jsx(ze,{size:"14px"}),onClick:l,children:s("lottie.clips.add")})})]})});async function Ns(n,e,t={}){try{const i=JSON.parse(n),{assets:s}=i,a=[];for(let o=0,l=s.length;o<l;o++){const h=s[o],{p}=h;p&&a.push({name:h.id,src:p})}const r=await le(a,{width:2048,height:2048,...t});return r.code!==0?(console.log("Atlas Error:",r.msg),r):(i.assets=s.filter(o=>!o.p),r.info.jsonFile=JSON.stringify(i),r)}catch{return{code:11,msg:"Parse lottie file error"}}}async function zs(n){const e={uploadFiles:[],errors:[]};for(const t in n){const i=n[t],s=i.name;if(s.endsWith(".json"))try{const a=await i.text(),r=JSON.parse(a);Vs(r)&&e.uploadFiles.push({main:i})}catch(a){e.errors.push(Je(s,a))}}return e}async function Us(n,e,t){const i=Le(n.main,"lottie.json"),s=await i.text();let a;try{a=JSON.parse(s)}catch(l){return console.error(l),Jt.error(Je(i.name,l)),i}const{nm:r}=a,o=await Ns(s);if(o.code===0)try{const{imageFiles:l,atlasFile:h,jsonFile:p}=o.info,u=JSON.parse(h),{atlasItems:c}=u,f=c.length,g=qs(),v=Hs(r,i.name),x=[];for(let A=0;A<f;++A)l[A]&&x.push(Gt.uploadBlob(`${v}-${g}-${A}.png`,new Blob([l[A]])));const w=await Promise.all(x);for(let A=0;A<f;++A)c[A].img=w[A].url;const[S,T]=await Promise.all([Gt.uploadBlob(`${v}-${g}.atlas`,new Blob([JSON.stringify(u)])),Gt.uploadBlob(`${v}-${g}.json`,new Blob([p]))]),k={jsonUrl:T.url,atlasUrl:S.url};return new File([JSON.stringify(k)],i.name)}catch(l){console.error(l),Jt.error(`parse lottie file fail ${l}`)}else console.error(o.msg),Jt.error(o.msg);return i}function Vs(n){return n.nm&&n.w&&n.h&&n.assets&&n.assets.length>0&&n.layers&&n.layers.length>0}function qs(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Hs(n,e){const t=e.replace(/\.[^.]+$/,"")||"lottie";return(typeof n=="string"&&n.length>0?n:t).trim().replace(/[^\w.-]+/g,"_")||"lottie"}function Je(n,e){const t=e instanceof Error?e.message:String(e);return`Failed to parse JSON file "${n}": ${t}`}var Ws=Object.defineProperty,Js=Object.getOwnPropertyDescriptor,wt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Js(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Ws(e,t,s),s};class ft extends Ue{constructor(){super();d(this,"lottie");d(this,"_updateComponent");d(this,"_lottieAsset");d(this,"playing",!1);d(this,"frameTime",0);d(this,"animationNames",[]);d(this,"animationIndex",0);d(this,"_hasClips",!1);$e(this)}get duration(){const{_lottieAsset:t}=this;return this._hasClips&&t.clips[this.animationIndex]?t.clips[this.animationIndex].end-t.clips[this.animationIndex].start:this._lottieAsset.duration}_setAnimationNames(t){this.animationNames=this._hasClips?t==null?void 0:t.map(i=>i.name):[this._lottieAsset.engineObject.name]}setViewAsset(t,i){const s=t.engineObject,a=i.createChild("lottie_entity"),r=a.addComponent(Zt);this._entity=a,this.lottie=r,r.resource=s,this._lottieAsset=t,this._hasClips=t.clips&&t.clips.length>0,this._setAnimationNames(t.clips),this.animationIndex=0;const o=this;this._updateComponent=this._entity.addComponent(class extends Ti{onUpdate(l){o._onUpdate()}}),this.frameTime=0}getSize(){var t;if((t=this.lottie)!=null&&t.resource){const{width:i,height:s}=this.lottie.resource;return{width:i/100,height:s/100}}return{width:0,height:0}}stopViewAsset(){var t;super.stopViewAsset(),this.lottie=null,(t=this._updateComponent)==null||t.destroy(),this.animationNames=null}setClips(t){this.lottie.resource.setClips(t),this._setAnimationNames(t)}play(t){this.lottie.isLooping=!0,this.lottie.play(t),this.playing=!0}pauseAnimation(){this.lottie.pause(),this.playing=!1}selectAnimation(t){this.animationIndex=t;const i=this._lottieAsset.clips[t];this.play(i==null?void 0:i.name)}playAnimation(){const t=this._lottieAsset.clips[this.animationIndex];this.play(t==null?void 0:t.name)}setFrameTime(t){}_onUpdate(){this.playing&&(this.frameTime=this.lottie.frame)}}wt([yt],ft.prototype,"playing",2);wt([yt],ft.prototype,"frameTime",2);wt([yt],ft.prototype,"animationNames",2);wt([yt],ft.prototype,"animationIndex",2);wt([Bt],ft.prototype,"play",1);wt([Bt],ft.prototype,"pauseAnimation",1);wt([Bt],ft.prototype,"_onUpdate",1);var Gs=Object.defineProperty,Ks=Object.getOwnPropertyDescriptor,K=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ks(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Gs(e,t,s),s};let V=class extends ot{constructor(e){super(e);d(this,"textureSet",new Set);d(this,"width",0);d(this,"height",0);d(this,"duration",0);d(this,"inPoint",0);d(this,"outPoint",0);d(this,"clips",[]);d(this,"mipmap",!1);d(this,"colorDilate",!1);d(this,"filterMode",Q.Bilinear);d(this,"wrapModeU",D.Repeat);d(this,"wrapModeV",D.Repeat);d(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});this.formSchema.addGroup(P("lottie.asset.atlas-export"),["filterMode","wrapModeU","wrapModeV","mipmap","colorDilate"])}destroy(){super.destroy(),this.textureSet.clear(),this.textureSet=null}async initByUploadFile(e){return await this._initByUrl(this.engine,e),this}async initByMain(e){const{engine:t,meta:i}=this;i.runtimeOptions&&(this.runtimeOptions=i.runtimeOptions),this.clips=i.clips||[],this.filterMode=i.filterMode??this.filterMode,this.wrapModeU=i.wrapModeU??this.wrapModeU,this.wrapModeV=i.wrapModeV??this.wrapModeV,this.mipmap=i.mipmap??this.mipmap,this.colorDilate=i.colorDilate??this.colorDilate,await this._initByUrl(t,e);const s=new Ee(this.engine),a=s.addComponent(Zt);a.resource=this.engineObject,this.setDragTempEntity(s)}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:s}=t.transform,a={components:[{class:"LottieAnimation",id:Pt(),props:{resource:this.getCurrentRef(),priority:0,defaultState:{}}}],id:e.id,isActive:!0,isClone:!1,name:this.name?this.name:"lottie",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:s.x,y:s.y,z:s.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}async _createLottieResource(e,t,i){return(await e.resourceManager.load({urls:[t,i],type:"lottie"})).getComponent(Zt).resource}async _initByUrl(e,t){const i=JSON.parse(await t.text()),{jsonUrl:s,atlasUrl:a}=i,r=await this._createLottieResource(e,s,a);this.bindEngineObject(r);const{sprites:o}=r.atlas,{textureSet:l}=this;for(let h=0,p=o.length;h<p;++h){const u=o[h].texture;l.has(u)||(l.add(u),u.filterMode=this.filterMode,u.wrapModeU=this.wrapModeU,u.wrapModeV=this.wrapModeV)}return this.width=r.width,this.height=r.height,this.duration=r.duration,this.inPoint=r.inPoint,this.outPoint=r.outPoint,this}};K([M({type:R.Input,disabled:!0,label:P("lottie.asset.width")})],V.prototype,"width",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.height")})],V.prototype,"height",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.duration")})],V.prototype,"duration",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.in-point")})],V.prototype,"inPoint",2);K([M({type:R.Input,disabled:!0,label:P("lottie.asset.out-point")})],V.prototype,"outPoint",2);K([M({disabled:!0,customComponent:$s}),dt()],V.prototype,"clips",2);K([M({label:P("lottie.asset.mipmap"),type:R.Toggle}),dt()],V.prototype,"mipmap",2);K([M({label:P("lottie.asset.color-dilate"),type:R.Toggle}),dt()],V.prototype,"colorDilate",2);K([M({label:P("lottie.asset.filter-mode.title"),type:R.Select,value:Q.Bilinear,options:[{label:P("lottie.asset.filter-mode.point"),value:Q.Point},{label:P("lottie.asset.filter-mode.bilinear"),value:Q.Bilinear},{label:P("lottie.asset.filter-mode.trilinear"),value:Q.Trilinear}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.filterMode=t})}}),dt()],V.prototype,"filterMode",2);K([M({label:P("lottie.asset.wrap-mode.u"),type:R.Select,value:D.Repeat,options:[{label:P("lottie.asset.wrap-mode.clamp"),value:D.Clamp},{label:P("lottie.asset.wrap-mode.repeat"),value:D.Repeat},{label:P("lottie.asset.wrap-mode.mirror"),value:D.Mirror}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.wrapModeU=t})}}),dt()],V.prototype,"wrapModeU",2);K([M({label:P("lottie.asset.wrap-mode.v"),type:R.Select,value:D.Repeat,options:[{label:P("lottie.asset.wrap-mode.clamp"),value:D.Clamp},{label:P("lottie.asset.wrap-mode.repeat"),value:D.Repeat},{label:P("lottie.asset.wrap-mode.mirror"),value:D.Mirror}],onChange(n,e,t){const{textureSet:i}=n;i.forEach(s=>{s.wrapModeV=t})}}),dt()],V.prototype,"wrapModeV",2);K([yt,dt()],V.prototype,"runtimeOptions",2);V=K([Ct({type:"Lottie",label:P("asset.lottie.title"),loaderType:"EditorLottie",importMenuConfig:{type:Mt.Upload,accept:".json"},viewer:ft,filterUploadFiles:zs,preUpload:Us,dragLayer:et.Lottie,customInspector:ki,async bundle(n,e,t){var k,A;const i=JSON.parse(await n.content.text()),s=n.meta,{jsonUrl:a,atlasUrl:r}=i,o=gt(n.name).split(".")[0],l=n.dependencies||(n.dependencies=[]),h=t.vfs,p=((k=l[0])==null?void 0:k.ref.refId)??Pt();let u;l[0]||(l[0]={key:"atlasUrl",ref:{refId:p}});let c=h.getFileById(p);c?u=c.meta:(u={id:p,type:ot.getRegisteredAssetMeta(N).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[],ignorePack:!0},t.addFile({name:o+"_atlas.atlas",assetId:p,url:null,parentId:n.parentId,main:null,meta:u}),c=h.getFileById(p),c.ignoreBundle=!0),u.colorDilate=s.colorDilate,u.filterMode=s.filterMode,u.wrapModeU=s.wrapModeU,u.wrapModeV=s.wrapModeV,u.mipmap=s.mipmap;const f=n.meta.runtimeOptions;let g=e.assetOptions.textureOptions;f!=null&&f.overwrite&&(g=Object.assign({},g,f)),u.runtimeOptions=g;const v=await(await fetch(r)).json();t.updateFile(p,{main:new Blob([JSON.stringify(v)]),meta:u}),await t.bundleSingleFile(c,e),i.atlasUrl="./"+gt(c.exportPath);const x=((A=l[1])==null?void 0:A.ref.refId)??Pt();let w;l[1]||(l[1]={key:"jsonUrl",ref:{refId:x}});let S=h.getFileById(x);S?w=S.meta:(w={id:x,type:ot.getRegisteredAssetMeta(ne).type,version:te.projectStore.engineVersion,extraData:{},dependencies:[]},t.addFile({name:o+"_clip.json",assetId:x,url:null,parentId:n.parentId,main:null,meta:w}),S=h.getFileById(x),S.ignoreBundle=!0);const T=await(await fetch(a)).json();return T.lolitaAnimations=s.clips,t.updateFile(x,{main:new Blob([JSON.stringify(T)])}),await t.bundleSingleFile(S,e),i.jsonUrl="./"+gt(S.exportPath),{content:new Blob([JSON.stringify(i)])}}})],V);const Nn=Object.freeze(Object.defineProperty({__proto__:null,get LottieAsset(){return V}},Symbol.toStringTag,{value:"Module"})),Ys=it("div",{marginTop:"20px",fontSize:"12px",fontWeight:500,color:"$gray12"}),Xs=ut(function(n){const{asset:{textures:e,textureAtlas:t,missingTexture:i}}=n,{assetStore:s}=re(),[a,r]=b.useState([]),o=b.useMemo(()=>{if(!t)return[];const l=t.pages,h=[];for(let p=0;p<l.length;p+=1){const u=l[p];h.push({name:u.name,regions:u.regions.map(c=>c.name)})}return h},[t]);return b.useEffect(()=>{let l=!1;return Promise.all(e.map(h=>s.getAssetByRef(h))).then(h=>{l||r(h)}).catch(h=>{l||(console.warn("[SpineAtlasInspector] Failed to load atlas textures:",h),r([]))}),()=>{l=!0}},[s,e]),i?y.jsx(Ys,{children:"Missing atlas texture, please reupload atlas and image files."}):y.jsxs(y.Fragment,{children:[y.jsx(Kt,{label:"atlas textures",value:""}),a.map((l,h)=>y.jsx(jt,{dropLayer:et.Texture,label:"",value:l.name,assets:[],asset:l,onLocate:()=>{var u;const p=(u=e==null?void 0:e[h])==null?void 0:u.refId;p&&s.selectAsset(p)}},l.id)),y.jsx(Kt,{label:"atlas regions",value:""}),y.jsx(He,{label:"",items:o.map((l,h)=>({removable:!1,children:l.regions.map(u=>y.jsx(Kt,{label:"",value:u},u)),id:`${h}`,name:l.name}))})]})});var Zs=Object.defineProperty,Qs=Object.getOwnPropertyDescriptor,Vt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qs(e,t):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Zs(e,t,s),s};let At=class extends ot{constructor(e){super(e);d(this,"_textureAtlas");d(this,"textures",[]);d(this,"atlasText","");d(this,"missingTexture",!1)}get textureAtlas(){return this._textureAtlas}async initByMain(e){this.atlasText=await e.text();const t=this.meta,{textures:i}=t;this.textures=i;const a=(await Promise.all(this.textures.map(l=>this.root.assetStore.getAssetByRef(l)))).map(l=>l==null?void 0:l.engineObject),r=a.some(l=>l==null)||i.length===0;if(this.missingTexture=r,r)return;const o=Di.createTextureAtlas(this.atlasText,a);this._textureAtlas=o}};Vt([dt(),yt],At.prototype,"textures",2);Vt([E()],At.prototype,"atlasText",2);Vt([yt],At.prototype,"missingTexture",2);At=Vt([Ct({type:"SpineAtlas",label:P("asset.spine-atlas.title"),dragLayer:et.SpineAtlas,customInspector:Xs,loaderType:"SpineAtlas",preUpload:Ei,bundle(n){return n.dependencies=Ai(n.meta,["textures"]),{content:n.content}}})],At);function tn(n){return`// ${n}
|
|
12
12
|
float function() {
|
|
13
13
|
return 3.1415926;
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var N=Object.defineProperty;var B=(t,a,e)=>a in t?N(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var d=(t,a,e)=>(B(t,typeof a!="symbol"?a+"":a,e),e);import{
|
|
1
|
+
var N=Object.defineProperty;var B=(t,a,e)=>a in t?N(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var d=(t,a,e)=>(B(t,typeof a!="symbol"?a+"":a,e),e);import{eD as w,bX as S,e as R,dK as x,aJ as H,C as T,av as A,dW as I,j as Q,u as k,x as X,aT as U,p as $,c2 as j,n as V,q as G,o as q,dZ as z,d_ as W,eE as K,dV as Y,dX as J}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";function Z(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}const E="galacean-local-ide-config";function ee(t,a){const e=t.trim().replace(/^["'`]+|["'`]+$/g,"").replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/\/+$/,"");if(!e)return p("empty",e);if(/[\r\n\t]/.test(e))return p("embedded-newline",e);if(/(^|\/)[a-z][a-z0-9+.-]*:\/\//i.test(e))return p("embedded-url",e);if(e.startsWith("~"))return p("tilde",e);if(!e.startsWith("/")&&!/^[A-Za-z]:\//.test(e))return p("not-absolute",e);if(/[<>"|?*]/.test(e))return p("illegal-chars",e);const r=e.split("/").filter(Boolean);return r.includes("..")||r.includes(".")?p("parent-segment",e):a?r[r.length-1]!==a?{kind:"error",reason:"tail-mismatch",normalized:e,expectedTail:a}:{kind:"ok",normalized:e}:p("no-binding",e)}function p(t,a){return{kind:"error",reason:t,normalized:a}}function ae(t){try{const a=localStorage.getItem(E);if(!a)return null;const e=JSON.parse(a);if(!e||typeof e.workspacePath!="string"||typeof e.ide!="string")return null;if(!e.workspacePath.trim())return localStorage.removeItem(E),null;const r=ee(e.workspacePath,t??null);return r.kind==="error"&&r.reason!=="no-binding"?(localStorage.removeItem(E),null):e}catch{return null}}function te(t){const a=t.replace(/\\/g,"/");return/^[A-Za-z]:\//.test(a)?`/${a}`:a}function re(t,a){switch(t){case"vscode":return`vscode://file${a}`;case"cursor":return`cursor://file${a}`;case"webstorm":return`webstorm://open?file=${encodeURIComponent(a)}`}}function v(t,a,e="",r=""){const s=[a.replace(/[\\/]+$/,""),e,r].filter(Boolean).join("/");return re(t,te(s))}function D(t){const a=document.createElement("a");a.href=t,a.style.display="none",document.body.appendChild(a),a.click(),a.remove()}function se(t,a,e){const{ide:r,workspacePath:s}=t,n=v(r,s,a,e);if(r==="webstorm"){D(n);return}D(v(r,s,a)),setTimeout(()=>D(n),800)}async function ne(t,a,e){const r=a.projectStore.localWorkspaceSync,s=ae(r==null?void 0:r.directoryName);if(!s||!(r!=null&&r.directoryHandle)){e();return}const n=a.projectStore.id,o=w(t);if(!await r.hasSyncedFile(o)){const h=(u,M)=>R(`asset.local-workspace-sync.${u}`,M),m=S.loading(h("syncing"));try{if(!await r.syncEditorAssetsToLocal()||!await r.hasSyncedFile(o)){S.error(r.errorMessage||h("failed"),{id:m}),e();return}S.success(h("success",[r.directoryName||h("local-workspace")]),{id:m})}catch(u){S.error(u instanceof Error?u.message:h("failed"),{id:m}),e();return}}se(s,n,o)}const oe=t=>{const{type:a="esm",varName:e,namedExports:r=null,defaultExport:s=!0}=typeof t=="string"?{varName:t}:t;return{type:a,varName:e,namedExports:r,defaultExport:s}},ie=t=>`module.exports = ${t};`,le=(t,a,e)=>{const r=e?[`export default ${t};`]:[];if(a&&a.length){const s=[...new Set(a)].join(", ");r.push(`const { ${s} } = ${t};`),r.push(`export { ${s} };`)}return r.join(`
|
|
2
2
|
`)},de=t=>{const{type:a,varName:e,namedExports:r,defaultExport:s}=t;switch(a){case"esm":return le(e,r,s);case"cjs":return ie(e)}},f="global-externals",ce=t=>{const{modulePathFilter:a,getModuleInfo:e}=t;return{name:f,setup(r){r.onResolve({filter:a},s=>({path:s.path,namespace:f})),r.onLoad({filter:/.*/,namespace:f},s=>{const n=s.path,o=oe(e(n));return{contents:de(o)}})}}},he=t=>{const a={modulePathFilter:new RegExp(`^(?:${Object.keys(t).join("|")})$`),getModuleInfo:e=>t[e]};return ce(a)},ue=async t=>x(()=>import(t),[]);async function pe(t,a=ue){const e=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));try{return await a(e)}finally{URL.revokeObjectURL(e)}}var c=(t=>(t.Default="default",t.ShaderUI="shader_ui",t.StateMachine="state_machine",t))(c||{});const C=`
|
|
3
3
|
this.onPropertyChanged("isTransparent", (material, isTransparent) => {
|
|
4
4
|
const shaderData = material.shaderData;
|
|
@@ -644,4 +644,4 @@ export default class extends ShaderUIScript {
|
|
|
644
644
|
})
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
`;var y=(t=>(t.Default="default",t[t.StateMachine=c.StateMachine]="StateMachine",t.UnlitUIScript="unlitUIScript",t.PbrUIScript="pbrUIScript",t.DefaultUIScript="defaultUIScript",t.BlinnPhongUIScript="blinnPhongUIScript",t.ParticleTrailUIScript="particleTrailUIScript",t.SkyProceduralUIScript="skyProceduralUIScript",t))(y||{});const P={default:Te,[y.StateMachine]:me,defaultUIScript:Ae,unlitUIScript:Se,pbrUIScript:_e,blinnPhongUIScript:Me,particleTrailUIScript:Ie,skyProceduralUIScript:Ee};class De{constructor(){d(this,"_propertyCallBacks",new Map);d(this,"_macroCallBacks",new Map)}onMaterialShaderSwitched(a){}onPropertyChanged(a,e){this._propertyCallBacks.set(a,e)}onMacroChanged(a,e){this._macroCallBacks.set(a,e)}}const fe=H(t=>{const a=t.asset,e=a.properties.map(n=>({label:n,type:T.PureDisplay,disable:!0,value:"",property:n})),r=a.macros.map(n=>({label:n,type:T.PureDisplay,disable:!0,value:"",property:n})),s=a.referencedShaderList.map(n=>({label:n.includePath,type:T.PureDisplay,disable:!0,value:"",property:n.includePath}));return A.jsxs(A.Fragment,{children:[A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Watched Properties",type:T.Group,children:e},model:a},"ScriptProperties"),A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Watched Macros",type:T.Group,children:r},model:a},"ScriptMacros"),A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Referenced Shaders",type:T.Group,children:s},model:a},"ReferencedShaders")]})});var F=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ce=(t,a,e)=>a in t?F(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,_=(t,a,e,r)=>{for(var s=r>1?void 0:r?Re(a,e):a,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(a,e,s):o(s))||s);return r&&s&&F(a,e,s),s},ye=(t,a,e)=>(Ce(t,typeof a!="symbol"?a+"":a,e),e);let l=class extends Q{constructor(a,e,r){super(a);d(this,"_code");d(this,"isScript",!0);d(this,"subType",c.Default);if(k(this),this.onDoubleClick=this.onDoubleClick.bind(this),r&&r.subType){if(r.subType===c.ShaderUI)return Reflect.construct(l.getScriptConstruct(c.ShaderUI),[a,e]);if(r.subType===c.StateMachine)return Reflect.construct(l.getScriptConstruct(c.StateMachine),[a,e])}return this}static registerScriptConstruct(a,e){return this.registeredScriptMap.set(a,e)}static getScriptConstruct(a){return this.registeredScriptMap.get(a)}get code(){return this._code}set code(a){this._code=a}updateCode(a){this._code=a,this._originMainFile=new File([a],this.name)}async initByMain(a){const e=await a.text();this._code=e,this.subType=this.meta.subType??c.Default}async initByCreation(a,e,r={template:y.Default}){const s=P[r.template];return this._code=s.replace("$$name",Z(this.name)),this._code}onDoubleClick(){ne(this,this.root,()=>{z(this.root.projectStore.id,this.id),W()})}getMainData(){return this._code}};ye(l,"registeredScriptMap",new Map);_([X],l.prototype,"_code",2);_([U()],l.prototype,"subType",2);_([$({type:T.Textarea,label:R("script.source.code")}),j],l.prototype,"code",1);l=_([V({type:"script",label:R("asset.script.title"),defaultName:"Script.ts",extname:"ts",dragLayer:G.Script,importMenuConfig:{type:q.Add},bundle({content:t}){return{content:new Blob([t],{type:"text/plain; charset=utf-8"})}}})],l);var ge=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ve=(t,a,e,r)=>{for(var s=r>1?void 0:r?be(a,e):a,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(a,e,s):o(s))||s);return r&&s&&ge(a,e,s),s};window.Galacean=
|
|
647
|
+
`;var y=(t=>(t.Default="default",t[t.StateMachine=c.StateMachine]="StateMachine",t.UnlitUIScript="unlitUIScript",t.PbrUIScript="pbrUIScript",t.DefaultUIScript="defaultUIScript",t.BlinnPhongUIScript="blinnPhongUIScript",t.ParticleTrailUIScript="particleTrailUIScript",t.SkyProceduralUIScript="skyProceduralUIScript",t))(y||{});const P={default:Te,[y.StateMachine]:me,defaultUIScript:Ae,unlitUIScript:Se,pbrUIScript:_e,blinnPhongUIScript:Me,particleTrailUIScript:Ie,skyProceduralUIScript:Ee};class De{constructor(){d(this,"_propertyCallBacks",new Map);d(this,"_macroCallBacks",new Map)}onMaterialShaderSwitched(a){}onPropertyChanged(a,e){this._propertyCallBacks.set(a,e)}onMacroChanged(a,e){this._macroCallBacks.set(a,e)}}const fe=H(t=>{const a=t.asset,e=a.properties.map(n=>({label:n,type:T.PureDisplay,disable:!0,value:"",property:n})),r=a.macros.map(n=>({label:n,type:T.PureDisplay,disable:!0,value:"",property:n})),s=a.referencedShaderList.map(n=>({label:n.includePath,type:T.PureDisplay,disable:!0,value:"",property:n.includePath}));return A.jsxs(A.Fragment,{children:[A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Watched Properties",type:T.Group,children:e},model:a},"ScriptProperties"),A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Watched Macros",type:T.Group,children:r},model:a},"ScriptMacros"),A.jsx(I,{onModelChange:null,inspectorConfig:{property:"Referenced Shaders",type:T.Group,children:s},model:a},"ReferencedShaders")]})});var F=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ce=(t,a,e)=>a in t?F(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,_=(t,a,e,r)=>{for(var s=r>1?void 0:r?Re(a,e):a,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(a,e,s):o(s))||s);return r&&s&&F(a,e,s),s},ye=(t,a,e)=>(Ce(t,typeof a!="symbol"?a+"":a,e),e);let l=class extends Q{constructor(a,e,r){super(a);d(this,"_code");d(this,"isScript",!0);d(this,"subType",c.Default);if(k(this),this.onDoubleClick=this.onDoubleClick.bind(this),r&&r.subType){if(r.subType===c.ShaderUI)return Reflect.construct(l.getScriptConstruct(c.ShaderUI),[a,e]);if(r.subType===c.StateMachine)return Reflect.construct(l.getScriptConstruct(c.StateMachine),[a,e])}return this}static registerScriptConstruct(a,e){return this.registeredScriptMap.set(a,e)}static getScriptConstruct(a){return this.registeredScriptMap.get(a)}get code(){return this._code}set code(a){this._code=a}updateCode(a){this._code=a,this._originMainFile=new File([a],this.name)}async initByMain(a){const e=await a.text();this._code=e,this.subType=this.meta.subType??c.Default}async initByCreation(a,e,r={template:y.Default}){const s=P[r.template];return this._code=s.replace("$$name",Z(this.name)),this._code}onDoubleClick(){ne(this,this.root,()=>{z(this.root.projectStore.id,this.id),W()})}getMainData(){return this._code}};ye(l,"registeredScriptMap",new Map);_([X],l.prototype,"_code",2);_([U()],l.prototype,"subType",2);_([$({type:T.Textarea,label:R("script.source.code")}),j],l.prototype,"code",1);l=_([V({type:"script",label:R("asset.script.title"),defaultName:"Script.ts",extname:"ts",dragLayer:G.Script,importMenuConfig:{type:q.Add},bundle({content:t}){return{content:new Blob([t],{type:"text/plain; charset=utf-8"})}}})],l);var ge=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ve=(t,a,e,r)=>{for(var s=r>1?void 0:r?be(a,e):a,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(a,e,s):o(s))||s);return r&&s&&ge(a,e,s),s};window.Galacean=K;window.ShaderUIScript=De;var i;const O=(i=class extends l{constructor(){super(...arguments);d(this,"subType",c.ShaderUI);d(this,"_script");d(this,"_referencedShaderList",[])}get referencedShaderList(){return this._referencedShaderList}getMetaConfig(){let e=l.getRegisteredAssetMeta(l);return e={...e,defaultName:"ShaderUIScript.ts",customInspector:fe},e}get properties(){return Array.from(this._script._propertyCallBacks.keys())}get macros(){return Array.from(this._script._macroCallBacks.keys())}addReferencedShader(e){this._referencedShaderList.findIndex(r=>r.id===e.id)===-1&&this._referencedShaderList.push(e)}removeReferencedShader(e){const r=this._referencedShaderList.findIndex(s=>s.id===e.id);r!==-1&&this._referencedShaderList.splice(r,1)}async initByMain(e,r){const s=await e.text();await this.updateCode(s);const n=this.getRouteString();i.assetsMap.set(n,this)}initByCreation(e,r,s){return this._code=P[s.template],Promise.resolve(this.getMainData())}async updateCode(e){this._code=e,this._originMainFile=new File([e],this.name);const r=await this._compile(e),s=await pe(r.contents);this._script=new s.default}async _compile(e){await this.root.esbuildInstancePromise;const{dependencies:r,setting:s}=this.root.projectStore;return(await Y.build({stdin:{contents:e,loader:"ts"},bundle:!0,format:"esm",plugins:[he({"@galacean/engine":{varName:"Galacean",type:"cjs"}}),Le(s.dependencies??r??{})]})).outputFiles[0]}async rename(e){let r=this.getRouteString();i.assetsMap.delete(r),await super.rename(e),r=this.getRouteString(),i.assetsMap.set(r,this),this._refreshShader()}afterDelete(){var r;(r=super.afterDelete)==null||r.call(this);const e=this.getRouteString();i.assetsMap.delete(e),this._refreshShader()}async moveTo(e){let r=this.getRouteString();i.assetsMap.delete(r),await this.moveViaFacade(e),r=this.getRouteString(),i.assetsMap.set(r,this),this._refreshShader()}getPropertyCallback(e){return this._script._propertyCallBacks.get(e)}getMacroCallback(e){return this._script._macroCallBacks.get(e)}onShaderChange(e){return this._script.onMaterialShaderSwitched(e)}onDoubleClick(){if(this.locked){S.error("Cannot edit internal Shader");return}super.onDoubleClick()}_refreshShader(){for(const e of this._referencedShaderList)e.reCompile()}},d(i,"assetsMap",new Map),i);ve([U()],O.prototype,"subType",2);let Ne=O;const L=new Map;function Le(t){return{name:"cdnImport",setup(a){a.onResolve({filter:/^\S/},e=>({namespace:"cdn",path:e.path})),a.onLoad({namespace:"cdn",filter:/^./},async e=>{const r=L.get(e.path);if(r)return{contents:r,loader:"js"};const s=e.path,n=t[s]??"latest",o=`https://registry.npmmirror.com/${s}/${n}/files`,h=await fetch(`${o}/package.json`);if(!h.ok)return{errors:[{text:`package not found: ${s}`}]};const m=await h.json(),u=m.browser||m.main;if(u){const M=J("/",u),g=await fetch(`${o}${M}`);if(g.ok){const b=await g.text();return L.set(s,b),{contents:b,loader:"js"}}else return{errors:[{text:`failed to import ${e.path}`}]}}})}}}export{c as E,De as S,l as a,Ne as b,y as c,he as g,pe as i,ne as l,P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var j=(s,e,r)=>e in s?y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var c=(s,e,r)=>(j(s,typeof e!="symbol"?e+"":e,r),r);import{aJ as m,bm as v,aK as b,av as t,aw as S,ay as d,aH as f,aI as g,aM as u,aO as k,aN as B,f as O,p as h,C as F,s as R}from"./index-
|
|
1
|
+
var y=Object.defineProperty;var j=(s,e,r)=>e in s?y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var c=(s,e,r)=>(j(s,typeof e!="symbol"?e+"":e,r),r);import{aJ as m,bm as v,aK as b,av as t,aw as S,ay as d,aH as f,aI as g,aM as u,aO as k,aN as B,f as O,p as h,C as F,s as R}from"./index-b126bb6b.js";import{u as I}from"./index-c8ed2a45.js";import{c as M}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{c as E}from"./createOnModelChange-89f572a6.js";import{M as _}from"./MaterialInspector-3fb471d9.js";import{M as z}from"./MeshRendererBaseComponent-cd8b743b.js";import"./IconPointFilled-3ba6d082.js";import"./createReactComponent-baa41397.js";const x=m(v),P=m(({model:s,inspectorConfig:e,onModelChange:r})=>{const{disabled:n,property:o}=e,{t:i}=b();return t.jsxs(t.Fragment,{children:[t.jsx(S,{label:i(e.label),info:i(e.info),fieldCss:{minHeight:"$5"},children:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:null})}),t.jsx(x,{label:" ",disabled:n,value:s[o].min,onChange:a=>{r==null||r(o,{...s[o],min:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.min.label")})}),t.jsx(x,{label:" ",disabled:n,value:s[o].max,onChange:a=>{r==null||r(o,{...s[o],max:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.max.label")})})]})}),C=f("div",{marginLeft:"5px"}),T=f(g,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),$=m(function(s){const e=s.data,{t:r}=b();return t.jsxs(T,{align:"v",children:[t.jsx("img",{src:e.thumbnailUrl,alt:"Material Thumbnail",width:"20px",height:"20px"}),t.jsxs(C,{children:[r("skinned-mesh-renderer.material.label"),"(",e.name,")"]})]})}),w=m(function(s){const[e,r]=u.useState(null),n=s.data,{assetStore:o,inspectorFacade:i}=I();return u.useEffect(()=>{o.getAssetByRef(n.material).then(a=>{r(a)})},[n.material]),t.jsxs(t.Fragment,{children:[t.jsx(k.List,{model:n,configs:n.formSchema.items,onModelChange:E("component",n.id,i,n)}),e&&t.jsx(B,{nesting:!0,title:t.jsx($,{data:e}),open:n.materialOpen,onOpenChange:a=>{n.setMaterialOpen(a)},children:t.jsx(_,{asset:e})})]})});var H=Object.defineProperty,V=Object.getOwnPropertyDescriptor,p=(s,e,r,n)=>{for(var o=n>1?void 0:n?V(e,r):e,i=s.length-1,a;i>=0;i--)(a=s[i])&&(o=(n?a(e,r,o):a(o))||o);return n&&o&&H(e,r,o),o};let l=class extends z{constructor(e,r){super(e,r);c(this,"rootBone",null);c(this,"localBounds",{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}})}};p([O({getEngineValue:s=>{var e;return(e=s.skin)==null?void 0:e.rootBone}}),h({label:"skinned-mesh-renderer.skin.root-bone.label",info:"skinned-mesh-renderer.skin.root-bone.info",type:F.EntityPicker,disabled:!0})],l.prototype,"rootBone",2);p([h({label:"skinned-mesh-renderer.local-bounds.title",info:"skinned-mesh-renderer.local-bounds.info",customComponent:P,type:"BoundingBox"}),R()],l.prototype,"localBounds",2);l=p([M({type:"SkinnedMeshRenderer",customInspector:w,componentsMenu:{label:"component.renderer.skinned-mesh.title"}})],l);export{l as SkinnedMeshRendererComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var F=Object.defineProperty;var S=(e,i,n)=>i in e?F(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n;var a=(e,i,n)=>(S(e,typeof i!="symbol"?i+"":i,n),n);import{S as v,a as B}from"./module-
|
|
1
|
+
var F=Object.defineProperty;var S=(e,i,n)=>i in e?F(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n;var a=(e,i,n)=>(S(e,typeof i!="symbol"?i+"":i,n),n);import{S as v,a as B}from"./module-113ac03a.js";import{aJ as h,bk as b,e as y,E as N,bl as O,x as g,p as l,C as f,s as m}from"./index-b126bb6b.js";import{u as k}from"./index-c8ed2a45.js";import{c as P}from"./Component-398551a0.js";import"./postmen-3b48c572.js";const R=h(function(e){const{model:i}=e,{inspectorFacade:n}=k();return b({label:y("spine.animation.label"),value:i.animationName,options:i.animationForm,onChange(t){n.componentChange(i.id,"animationName",t)}})}),T=h(function(e){const{model:i}=e,{inspectorFacade:n}=k();return b({label:y("spine.skin.label"),value:i.skinName,options:i.skinForm,onChange(t){n.componentChange(i.id,"skinName",t)}})});var _=Object.defineProperty,j=Object.getOwnPropertyDescriptor,p=(e,i,n,t)=>{for(var o=t>1?void 0:t?j(i,n):i,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(t?u(i,n,o):u(o))||o);return t&&o&&_(i,n,o),o};let s=class extends N{constructor(i,n){super(i,n);a(this,"animationForm",[]);a(this,"skinForm",[]);a(this,"hasInit",!1);a(this,"resource",null);a(this,"loop",!1);a(this,"animationName","none");a(this,"skinName","default");a(this,"priority",0);a(this,"premultipliedAlpha",!1);a(this,"tintBlack",!1)}deserialize(i){const{props:n}=i;if(this._enabled=(n==null?void 0:n.enabled)??!0,n){this.priority=n.priority,this.resource=n.resource,this.premultipliedAlpha=n.premultipliedAlpha,this.tintBlack=n.tintBlack??!1;const{animationName:t,skinName:o,loop:c}=n.defaultConfig;this.animationName=t||"none",this.skinName=o,this.loop=c}super.deserialize(i)}toJSON(){const i=this.animationName==="none"?null:this.animationName;return{type:this.type,props:O({enabled:this.enabled,priority:this.priority,resource:this.resource,premultipliedAlpha:this.premultipliedAlpha,tintBlack:this.tintBlack,defaultConfig:{animationName:i,skinName:this.skinName,loop:this.loop}})}}};p([g],s.prototype,"animationForm",2);p([g],s.prototype,"skinForm",2);p([l({label:"spine.resource.label",info:"spine.resource.info",type:f.AssetPicker,assetType:"SpineSkeletonData",onChange:async(e,i,n)=>{const t=e.engineObject;if(n){t.enabled=!0;const{skeletonData:o}=n;if(!o)return;const u=o.animations.map(r=>r.name).map(r=>({label:r,value:r}));u.unshift({label:"none",value:"none"}),e.animationForm=u,e.skinForm=o.skins.map(r=>({label:r.name,value:r.name})),e.hasInit?(e.animationName="none",e.skinName="default"):e.hasInit=!0;const{loop:d,skinName:C}=e,A=e.animationName==="none"?null:e.animationName;t.defaultConfig.animationName=A,t.defaultConfig.skinName=C,t.defaultConfig.loop=d,t.resource=new v(t.engine,o)}else t.enabled=!1,e.animationName="none",e.animationForm.length=0,e.skinForm.length=0,e.premultipliedAlpha=!1,e.tintBlack=!1}}),m()],s.prototype,"resource",2);p([l({label:"spine.loop.label",info:"spine.loop.info",type:f.Toggle,onChange(e,i,n){const{state:t}=e.engineObject;if(t){const o=t.getCurrent(0);o&&(o.loop=n)}}}),m()],s.prototype,"loop",2);p([l({info:"spine.animation.info",customComponent:R,onChange(e,i,n){const{state:t}=e.engineObject;t&&(n==="none"?t.setEmptyAnimation(0,0):t.setAnimation(0,n,e.loop))}}),m()],s.prototype,"animationName",2);p([l({info:"spine.skin.info",customComponent:T,onChange(e,i,n){const{engineObject:{skeleton:t}}=e;t&&n&&(t.setSkinByName(n),t.setSlotsToSetupPose())}}),m()],s.prototype,"skinName",2);p([l({label:"spine.priority.label",info:"spine.priority.info",type:f.Number,bindPath:"priority"}),m()],s.prototype,"priority",2);p([l({label:"spine.premultiplied-alpha.label",info:"spine.premultiplied-alpha.info",type:f.Toggle,bindPath:"premultipliedAlpha"}),m()],s.prototype,"premultipliedAlpha",2);p([l({label:"spine.tint-black.label",info:"spine.tint-black.info",type:f.Toggle,bindPath:"tintBlack"}),m()],s.prototype,"tintBlack",2);s=p([P({type:"SpineAnimationRenderer",componentsMenu:{group:"2D",label:"component.spine-animation.title"}})],s);N.registerCustomEngineComponent("SpineAnimationRenderer",B);export{s as SpineAnimationComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var I=Object.defineProperty;var j=(t,s,e)=>s in t?I(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var c=(t,s,e)=>(j(t,typeof s!="symbol"?s+"":s,e),e);import{bR as b,e as w,aH as B,u as $,S as U,aJ as q,aM as C,av as A,bS as z,x as g,aC as k,bT as V,bU as M,j as J,K,bV as W,p as L,C as X,aT as Y,m as H,n as G,q as Q,o as Z,bW as ee,bX as te}from"./index-c3dec278.js";import{b as ne,c as se,T as ie,d as ae,R as oe,M as re,B as le,P as pe,e as ce,C as ue,f as me,a as v,S as T,L as he}from"./module-ada3dced.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import{A as de}from"./AssetViewer-3847c058.js";const x=new Map;function fe(t){return t??""}function ge(t){return`${t.name}|${t.size}|${t.lastModified}|${t.type}`}function ye(t,s){const{uploadAssetFile:e,assetType:n,parentFolderId:i,assetMeta:a}=s,o=i??t.currentFolderId??"",r=b(e.main,"upload.bin"),u=ge(r),l=fe(a);return`${o}|${n}|${u}|${l}`}function N(t,s){const e=ye(t,s),n=x.get(e);if(n)return n;const i=t.createAssetByUpload(s).finally(()=>{x.get(e)===i&&x.delete(e)});return x.set(e,i),i}var O=(t=>(t.region="region",t.boundingbox="boundingbox",t.mesh="mesh",t.linkedmesh="linkedmesh",t.path="path",t.point="point",t.clipping="clipping",t.sequence="sequence",t))(O||{});const Ae=["region","linkedmesh","mesh"];async function we(t,s){const e={uploadFiles:[],usedFiles:[],errors:[]},{atlasRawFiles:n,atlasFound:i}=await ke(t,e),a=await Promise.all(n.map(l=>N(s.root.assetFacade,{uploadAssetFile:l,assetType:"SpineAtlas"})));e.usedFiles.push(...n.flatMap(l=>[b(l.main,"spine.atlas"),...Object.values(l.subFiles)]));const o=await Se(t,e);o.length>0&&!i&&e.errors.push(w("spine.error.no-atlas-file"));const r=o.map(l=>(e.usedFiles.push(l.spineFile),xe(l,a,e)));let u=await Promise.all(r);return u=u.filter(l=>l!==null),e.uploadFiles.push(...u),e}async function ke(t,s){const e=[];let n=!1;for(const i in t){const a=t[i];if(a.name.endsWith(".atlas")){n=!0;const r=await Pe(t,a);if(r.length>0){const u={};r.forEach(l=>u[l.name]=l),e.push({main:a,subFiles:u})}else s.errors.push(w("spine.error.missing-images"))}}return{atlasRawFiles:e,atlasFound:n}}async function Se(t,s){const e=[];for(const n in t){const i=t[n],a=i.name,o=a.split(".")[0];if(a.endsWith(".json"))try{const r=await i.text(),u=JSON.parse(r);u.skeleton&&u.skeleton.spine&&e.push({spineFile:i,spineName:o,isBinary:!1})}catch(r){s.errors.push(P(a,r))}else a.endsWith(".skel")&&e.push({spineFile:i,spineName:o,isBinary:!0})}return e}async function xe(t,s,e){const{spineFile:n}=t,i={type:"SpineSkeletonData",atlas:{refId:null}},a={main:n,meta:null};let o;try{o=await De(t,s,e)}catch(r){return e.errors.push(r instanceof Error?r.message:P(n.name,r)),null}return s.length===0?null:o?(i.atlas.refId=o.id,a.meta=JSON.stringify(i),a):(e.errors.push(w("spine.error.missing-attachments")),null)}async function De(t,s,e){const n=await _e(t);return await Re(s,n)}async function _e(t){const{spineFile:s,isBinary:e}=t,n=new Set;if(e){const r=await s.arrayBuffer();return Fe(r,n),Array.from(n)}const i=await s.text();let a;try{a=JSON.parse(i)}catch(r){throw new Error(P(s.name,r))}return!a||!a.skins?[]:(a.skins.forEach(r=>{if(r.attachments)for(const u in r.attachments){const l=r.attachments[u];for(const y in l){const p=l[y];if(p.type){let h;const f=p.type;try{h=O[f]}catch(F){throw console.warn(w("spine.error.incompatible-version",f)),F}if(!Ae.includes(h))continue}if(p.path)n.add(p.path);else if(p.name)n.add(p.name);else if(p.sequence){const h=new ne(null).readSequence(p.sequence);if(h)for(let f=0;f<h.regions.length;++f)n.add(h.getPath(y,f));else n.add(y)}else n.add(y)}}}),Array.from(n))}function Fe(t,s){new se(new D(s)).readSkeletonData(new Uint8Array(t))}class D{constructor(s){c(this,"requiredPaths");this.requiredPaths=s}static assignDummyRegion(s){s.region=new ie(new ae("dummy"),"")}newRegionAttachment(s,e,n,i){const a=new oe(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newMeshAttachment(s,e,n,i){const a=new re(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newBoundingBoxAttachment(s,e){return new le(e)}newPathAttachment(s,e){return new pe(e)}newPointAttachment(s,e){return new ce(e)}newClippingAttachment(s,e){return new ue(e)}loadSequence(s,e){const n=e.regions;for(let i=0,a=n.length;i<a;i++){const o=e.getPath(s,i);this.requiredPaths.add(o)}}}async function Re(t,s){for(let e=0;e<t.length;e+=1){const n=t[e];if(Te(n.textureAtlas,s))return n}return null}async function Te(t,s){for(let e=0;e<s.length;e+=1){const n=s[e];if(!be(t,n))return!1}return!0}function P(t,s){const e=s instanceof Error?s.message:String(s);return`Failed to parse spine JSON "${t}": ${e}`}function be(t,s){const e=t.findRegion(s);if(e)return e;const n=s.length;for(const i of t.regions){const a=i.name;if(a.startsWith(s)&&a.substring(n).split("").every(r=>r>="0"&&r<="9"))return i}return null}async function Pe(t,s){const e=await s.text(),n=new me(e),i=[];return n.pages.forEach(a=>{const o=a.name,r=t[o];if(r)i.push(r);else return null}),i}async function Me(t,s,e){const n=b(t.main,"spine.atlas"),i=await Ce(t,e);return{main:n,meta:JSON.stringify({textures:i,type:"SpineAtlas"})}}async function Ce(t,s){const e=[];for(const p in t.subFiles){const h=t.subFiles[p];h.name.endsWith(".atlas")||e.push({main:h,type:"Texture"})}const n=[];let i=[],a;const o=s.getAssetFromCurrentFolder();(o==null?void 0:o.length)>0&&(a=o.filter(p=>p.meta.type==="Texture")),a?e.forEach(p=>{const h=a.find(f=>f.name===p.main.name);h?n.push(h.getCurrentRef()):i.push(p)}):i=e;const r=[];i.forEach(p=>{r.push(N(s.root.assetFacade,{uploadAssetFile:p,assetType:"Texture"}))});const l=(await Promise.all(r)).map(p=>p.getCurrentRef());return n.concat(l)}var ve=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,d=(t,s,e,n)=>{for(var i=n>1?void 0:n?Ne(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&ve(s,e,i),i};const Oe=B("div",{position:"absolute",top:8,left:8,display:"grid",gap:"$1",marginTop:"$1 $2",variants:{hasClips:{true:{gridTemplateColumns:"150px 18px 1fr"},false:{gridTemplateColumns:"$4_5 1fr"}}}});class m extends de{constructor(){super();c(this,"_spineAnimationRenderer");c(this,"_animationTrack");c(this,"_updateComponent");c(this,"playing",!1);c(this,"frameTime",0);c(this,"duration",0);c(this,"animationNames",[]);c(this,"skinNames",[]);c(this,"animationIndex",0);c(this,"skinIndex",0);c(this,"_size",{w:0,h:0});c(this,"overridePreviewer",q(({asset:e,viewer:n})=>{const i=e.getViewerRootEntity();return C.useEffect(()=>{this.skinIndex=0},[e]),C.useEffect(()=>{this._spineAnimationRenderer?this.updateViewAsset(e,i):this.setViewAsset(e,i)},[e.skeletonData]),A.jsxs(A.Fragment,{children:[A.jsx(z,{asset:e,viewer:n}),A.jsx(Ee,{selectedKey:this.skinIndex,clips:this.skinNames,onSelectClip:a=>{this.skinIndex=a,this.changeSkin(this.skinNames[a])}})]})}));$(this)}setViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}this.animationIndex=0,this.duration=0;const i=n.engine,a=e.skeletonData,o=n.createChild("spine-entity"),r=o.addComponent(v);this.animationNames=a.animations.map(R=>R.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(R=>R.name),this._entity=o,this._spineAnimationRenderer=r,r.resource=new T(i,a);const{width:u,height:l,x:y,y:p}=a;this._size={w:u,h:l};const h=y+u/2,f=p+l/2;o.transform.setPosition(-h/100,-f/100,0);const F=this;this._updateComponent=this._entity.addComponent(class extends U{onUpdate(){F._onUpdate()}})}updateViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}const i=n.engine,a=e.skeletonData;this.animationNames=a.animations.map(o=>o.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(o=>o.name),this._spineAnimationRenderer.resource=new T(i,a)}getSize(){return{width:this._size.w/100,height:this._size.h/100}}stopViewAsset(){var e;super.stopViewAsset(),this.playing=!1,this.frameTime=0,this.duration=0,this.animationNames=[],this.skinNames=[],this.animationIndex=0,this.skinIndex=0,this._spineAnimationRenderer&&(this._spineAnimationRenderer.enabled=!1),this._spineAnimationRenderer=null,(e=this._updateComponent)==null||e.destroy()}changeSkin(e){const{skeleton:n,state:i}=this._spineAnimationRenderer;n.setSkinByName(e),n.setSlotsToSetupPose(),i.apply(n)}selectAnimation(e){this.animationIndex=e;const n=this.animationNames[e];this.play(n)}play(e){let n;const{state:i}=this._spineAnimationRenderer;e==="none"?n=i.setEmptyAnimation(0,0):n=i.setAnimation(0,e,!0),this._animationTrack=n,this._spineAnimationRenderer.state.timeScale=1,this.playing=!0,this.duration=n.animationEnd}pauseAnimation(){this.pause()}playAnimation(){this._spineAnimationRenderer.state.timeScale=1}pause(){this._spineAnimationRenderer.state.timeScale=0,this.playing=!1}_onUpdate(){if(!this.playing)return;const e=this._animationTrack.trackTime%this.duration;this.frameTime=isNaN(e)?0:e}}d([g],m.prototype,"playing",2);d([g],m.prototype,"frameTime",2);d([g],m.prototype,"duration",2);d([g],m.prototype,"animationNames",2);d([g],m.prototype,"skinNames",2);d([g],m.prototype,"animationIndex",2);d([g],m.prototype,"skinIndex",2);d([k],m.prototype,"changeSkin",1);d([k],m.prototype,"selectAnimation",1);d([k],m.prototype,"play",1);d([k],m.prototype,"pauseAnimation",1);d([k],m.prototype,"playAnimation",1);d([k],m.prototype,"pause",1);d([k],m.prototype,"_onUpdate",1);function Ee({onSelectClip:t,clips:s,selectedKey:e}){return A.jsx(Oe,{hasClips:!!s.length,children:s.length>0&&A.jsx(V,{value:e,onValueChange:t,valueType:"number",size:"xs",sideOffset:8,children:s.map((n,i)=>n?A.jsx(M,{value:i,children:n},i):null)})})}var Ie=Object.defineProperty,je=Object.getOwnPropertyDescriptor,_=(t,s,e,n)=>{for(var i=n>1?void 0:n?je(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&Ie(s,e,i),i};let S=class extends J{constructor(s){super(s);c(this,"_delOnSkeletonDel");c(this,"_delOnAtlasDel");c(this,"_hasInit",!1);c(this,"atlas",null);c(this,"skeletonRawData","");c(this,"skeletonData")}async initByMain(s){const e=await s.text();try{JSON.parse(e),this.skeletonRawData=e}catch{this.skeletonRawData=await s.arrayBuffer()}const n=this.meta,{atlas:i}=n;this.atlas=i;const a=await this.root.assetStore.getAssetByRef(i),o=E(this.skeletonRawData,a,!0);o&&this.createDragTempEntity(o)}createDragTempEntity(s){this.skeletonData=s;const e=new K(this.engine),n=e.addComponent(v);n.resource=new T(this.engine,this.skeletonData),this.setDragTempEntity(e)}instantiate(){if(!this.skeletonData)return;const s=this.root.sceneStore.createEntity(),e=this.getDragTempEntity(),{position:n,rotation:i}=e.transform,a={components:[{class:"SpineAnimationRenderer",id:W(),props:{resource:this.getCurrentRef(),priority:0,defaultConfig:{loop:!1,animationName:"none",skinName:"default"}}}],id:s.id,isActive:!0,isClone:!1,name:this.name?this.name:"spine",position:{x:n.x,y:n.y,z:n.z},rotation:{x:i.x,y:i.y,z:i.z},scale:{x:1,y:1,z:1}};return s.initByFile(a),s}};_([L({assetType:"SpineAtlas",label:w("asset.spine-atlas.title"),type:X.AssetPicker,onChange:async(t,s,e)=>{if(t._delOnAtlasDel&&(t._delOnAtlasDel(),t._delOnAtlasDel=null),e){let n=!0;t._hasInit?n=!1:t._hasInit=!0,t.skeletonData=E(t.skeletonRawData,e,n),t.skeletonData&&t.createDragTempEntity(t.skeletonData);const i=()=>{t._delOnSkeletonDel&&t._delOnSkeletonDel(),t._delOnSkeletonDel=null,t.skeletonData=null};e.on("delete",i),t._delOnSkeletonDel=()=>{e.off("delete",i)}}else t.skeletonData=null}}),Y()],S.prototype,"atlas",2);_([H()],S.prototype,"skeletonRawData",2);_([g.ref],S.prototype,"skeletonData",2);S=_([G({type:"SpineSkeletonData",label:w("asset.spine-skeleton-data.title"),loaderType:"Spine",viewer:m,dragLayer:Q.SpineSkeletonData,dragType:"2d",filterUploadFiles:we,importMenuConfig:{type:Z.Upload,accept:".json,.atlas,.skel,.png,.jpg,.jpeg,.webp",multiple:!0},bundle(t){return t.dependencies=ee(t.meta,["atlas"]),{content:t.content}}})],S);function E(t,s,e){if(!s)return null;try{return he.createSkeletonData(t,s.textureAtlas,.01)}catch{return!e&&te.error(w("spine.error.generate-skeleton-data")),null}}const Je=Object.freeze(Object.defineProperty({__proto__:null,get SpineSkeletonDataAsset(){return S}},Symbol.toStringTag,{value:"Module"}));export{S,Je as a,Me as s};
|
|
1
|
+
var I=Object.defineProperty;var j=(t,s,e)=>s in t?I(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var c=(t,s,e)=>(j(t,typeof s!="symbol"?s+"":s,e),e);import{bR as b,e as w,aH as B,u as $,S as U,aJ as q,aM as C,av as A,bS as z,x as g,aC as k,bT as V,bU as M,j as J,K,bV as W,p as L,C as X,aT as Y,m as H,n as G,q as Q,o as Z,bW as ee,bX as te}from"./index-b126bb6b.js";import{b as ne,c as se,T as ie,d as ae,R as oe,M as re,B as le,P as pe,e as ce,C as ue,f as me,a as v,S as T,L as he}from"./module-113ac03a.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{A as de}from"./AssetViewer-8338dfe1.js";const x=new Map;function fe(t){return t??""}function ge(t){return`${t.name}|${t.size}|${t.lastModified}|${t.type}`}function ye(t,s){const{uploadAssetFile:e,assetType:n,parentFolderId:i,assetMeta:a}=s,o=i??t.currentFolderId??"",r=b(e.main,"upload.bin"),u=ge(r),l=fe(a);return`${o}|${n}|${u}|${l}`}function N(t,s){const e=ye(t,s),n=x.get(e);if(n)return n;const i=t.createAssetByUpload(s).finally(()=>{x.get(e)===i&&x.delete(e)});return x.set(e,i),i}var O=(t=>(t.region="region",t.boundingbox="boundingbox",t.mesh="mesh",t.linkedmesh="linkedmesh",t.path="path",t.point="point",t.clipping="clipping",t.sequence="sequence",t))(O||{});const Ae=["region","linkedmesh","mesh"];async function we(t,s){const e={uploadFiles:[],usedFiles:[],errors:[]},{atlasRawFiles:n,atlasFound:i}=await ke(t,e),a=await Promise.all(n.map(l=>N(s.root.assetFacade,{uploadAssetFile:l,assetType:"SpineAtlas"})));e.usedFiles.push(...n.flatMap(l=>[b(l.main,"spine.atlas"),...Object.values(l.subFiles)]));const o=await Se(t,e);o.length>0&&!i&&e.errors.push(w("spine.error.no-atlas-file"));const r=o.map(l=>(e.usedFiles.push(l.spineFile),xe(l,a,e)));let u=await Promise.all(r);return u=u.filter(l=>l!==null),e.uploadFiles.push(...u),e}async function ke(t,s){const e=[];let n=!1;for(const i in t){const a=t[i];if(a.name.endsWith(".atlas")){n=!0;const r=await Pe(t,a);if(r.length>0){const u={};r.forEach(l=>u[l.name]=l),e.push({main:a,subFiles:u})}else s.errors.push(w("spine.error.missing-images"))}}return{atlasRawFiles:e,atlasFound:n}}async function Se(t,s){const e=[];for(const n in t){const i=t[n],a=i.name,o=a.split(".")[0];if(a.endsWith(".json"))try{const r=await i.text(),u=JSON.parse(r);u.skeleton&&u.skeleton.spine&&e.push({spineFile:i,spineName:o,isBinary:!1})}catch(r){s.errors.push(P(a,r))}else a.endsWith(".skel")&&e.push({spineFile:i,spineName:o,isBinary:!0})}return e}async function xe(t,s,e){const{spineFile:n}=t,i={type:"SpineSkeletonData",atlas:{refId:null}},a={main:n,meta:null};let o;try{o=await De(t,s,e)}catch(r){return e.errors.push(r instanceof Error?r.message:P(n.name,r)),null}return s.length===0?null:o?(i.atlas.refId=o.id,a.meta=JSON.stringify(i),a):(e.errors.push(w("spine.error.missing-attachments")),null)}async function De(t,s,e){const n=await _e(t);return await Re(s,n)}async function _e(t){const{spineFile:s,isBinary:e}=t,n=new Set;if(e){const r=await s.arrayBuffer();return Fe(r,n),Array.from(n)}const i=await s.text();let a;try{a=JSON.parse(i)}catch(r){throw new Error(P(s.name,r))}return!a||!a.skins?[]:(a.skins.forEach(r=>{if(r.attachments)for(const u in r.attachments){const l=r.attachments[u];for(const y in l){const p=l[y];if(p.type){let h;const f=p.type;try{h=O[f]}catch(F){throw console.warn(w("spine.error.incompatible-version",f)),F}if(!Ae.includes(h))continue}if(p.path)n.add(p.path);else if(p.name)n.add(p.name);else if(p.sequence){const h=new ne(null).readSequence(p.sequence);if(h)for(let f=0;f<h.regions.length;++f)n.add(h.getPath(y,f));else n.add(y)}else n.add(y)}}}),Array.from(n))}function Fe(t,s){new se(new D(s)).readSkeletonData(new Uint8Array(t))}class D{constructor(s){c(this,"requiredPaths");this.requiredPaths=s}static assignDummyRegion(s){s.region=new ie(new ae("dummy"),"")}newRegionAttachment(s,e,n,i){const a=new oe(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newMeshAttachment(s,e,n,i){const a=new re(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newBoundingBoxAttachment(s,e){return new le(e)}newPathAttachment(s,e){return new pe(e)}newPointAttachment(s,e){return new ce(e)}newClippingAttachment(s,e){return new ue(e)}loadSequence(s,e){const n=e.regions;for(let i=0,a=n.length;i<a;i++){const o=e.getPath(s,i);this.requiredPaths.add(o)}}}async function Re(t,s){for(let e=0;e<t.length;e+=1){const n=t[e];if(Te(n.textureAtlas,s))return n}return null}async function Te(t,s){for(let e=0;e<s.length;e+=1){const n=s[e];if(!be(t,n))return!1}return!0}function P(t,s){const e=s instanceof Error?s.message:String(s);return`Failed to parse spine JSON "${t}": ${e}`}function be(t,s){const e=t.findRegion(s);if(e)return e;const n=s.length;for(const i of t.regions){const a=i.name;if(a.startsWith(s)&&a.substring(n).split("").every(r=>r>="0"&&r<="9"))return i}return null}async function Pe(t,s){const e=await s.text(),n=new me(e),i=[];return n.pages.forEach(a=>{const o=a.name,r=t[o];if(r)i.push(r);else return null}),i}async function Me(t,s,e){const n=b(t.main,"spine.atlas"),i=await Ce(t,e);return{main:n,meta:JSON.stringify({textures:i,type:"SpineAtlas"})}}async function Ce(t,s){const e=[];for(const p in t.subFiles){const h=t.subFiles[p];h.name.endsWith(".atlas")||e.push({main:h,type:"Texture"})}const n=[];let i=[],a;const o=s.getAssetFromCurrentFolder();(o==null?void 0:o.length)>0&&(a=o.filter(p=>p.meta.type==="Texture")),a?e.forEach(p=>{const h=a.find(f=>f.name===p.main.name);h?n.push(h.getCurrentRef()):i.push(p)}):i=e;const r=[];i.forEach(p=>{r.push(N(s.root.assetFacade,{uploadAssetFile:p,assetType:"Texture"}))});const l=(await Promise.all(r)).map(p=>p.getCurrentRef());return n.concat(l)}var ve=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,d=(t,s,e,n)=>{for(var i=n>1?void 0:n?Ne(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&ve(s,e,i),i};const Oe=B("div",{position:"absolute",top:8,left:8,display:"grid",gap:"$1",marginTop:"$1 $2",variants:{hasClips:{true:{gridTemplateColumns:"150px 18px 1fr"},false:{gridTemplateColumns:"$4_5 1fr"}}}});class m extends de{constructor(){super();c(this,"_spineAnimationRenderer");c(this,"_animationTrack");c(this,"_updateComponent");c(this,"playing",!1);c(this,"frameTime",0);c(this,"duration",0);c(this,"animationNames",[]);c(this,"skinNames",[]);c(this,"animationIndex",0);c(this,"skinIndex",0);c(this,"_size",{w:0,h:0});c(this,"overridePreviewer",q(({asset:e,viewer:n})=>{const i=e.getViewerRootEntity();return C.useEffect(()=>{this.skinIndex=0},[e]),C.useEffect(()=>{this._spineAnimationRenderer?this.updateViewAsset(e,i):this.setViewAsset(e,i)},[e.skeletonData]),A.jsxs(A.Fragment,{children:[A.jsx(z,{asset:e,viewer:n}),A.jsx(Ee,{selectedKey:this.skinIndex,clips:this.skinNames,onSelectClip:a=>{this.skinIndex=a,this.changeSkin(this.skinNames[a])}})]})}));$(this)}setViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}this.animationIndex=0,this.duration=0;const i=n.engine,a=e.skeletonData,o=n.createChild("spine-entity"),r=o.addComponent(v);this.animationNames=a.animations.map(R=>R.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(R=>R.name),this._entity=o,this._spineAnimationRenderer=r,r.resource=new T(i,a);const{width:u,height:l,x:y,y:p}=a;this._size={w:u,h:l};const h=y+u/2,f=p+l/2;o.transform.setPosition(-h/100,-f/100,0);const F=this;this._updateComponent=this._entity.addComponent(class extends U{onUpdate(){F._onUpdate()}})}updateViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}const i=n.engine,a=e.skeletonData;this.animationNames=a.animations.map(o=>o.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(o=>o.name),this._spineAnimationRenderer.resource=new T(i,a)}getSize(){return{width:this._size.w/100,height:this._size.h/100}}stopViewAsset(){var e;super.stopViewAsset(),this.playing=!1,this.frameTime=0,this.duration=0,this.animationNames=[],this.skinNames=[],this.animationIndex=0,this.skinIndex=0,this._spineAnimationRenderer&&(this._spineAnimationRenderer.enabled=!1),this._spineAnimationRenderer=null,(e=this._updateComponent)==null||e.destroy()}changeSkin(e){const{skeleton:n,state:i}=this._spineAnimationRenderer;n.setSkinByName(e),n.setSlotsToSetupPose(),i.apply(n)}selectAnimation(e){this.animationIndex=e;const n=this.animationNames[e];this.play(n)}play(e){let n;const{state:i}=this._spineAnimationRenderer;e==="none"?n=i.setEmptyAnimation(0,0):n=i.setAnimation(0,e,!0),this._animationTrack=n,this._spineAnimationRenderer.state.timeScale=1,this.playing=!0,this.duration=n.animationEnd}pauseAnimation(){this.pause()}playAnimation(){this._spineAnimationRenderer.state.timeScale=1}pause(){this._spineAnimationRenderer.state.timeScale=0,this.playing=!1}_onUpdate(){if(!this.playing)return;const e=this._animationTrack.trackTime%this.duration;this.frameTime=isNaN(e)?0:e}}d([g],m.prototype,"playing",2);d([g],m.prototype,"frameTime",2);d([g],m.prototype,"duration",2);d([g],m.prototype,"animationNames",2);d([g],m.prototype,"skinNames",2);d([g],m.prototype,"animationIndex",2);d([g],m.prototype,"skinIndex",2);d([k],m.prototype,"changeSkin",1);d([k],m.prototype,"selectAnimation",1);d([k],m.prototype,"play",1);d([k],m.prototype,"pauseAnimation",1);d([k],m.prototype,"playAnimation",1);d([k],m.prototype,"pause",1);d([k],m.prototype,"_onUpdate",1);function Ee({onSelectClip:t,clips:s,selectedKey:e}){return A.jsx(Oe,{hasClips:!!s.length,children:s.length>0&&A.jsx(V,{value:e,onValueChange:t,valueType:"number",size:"xs",sideOffset:8,children:s.map((n,i)=>n?A.jsx(M,{value:i,children:n},i):null)})})}var Ie=Object.defineProperty,je=Object.getOwnPropertyDescriptor,_=(t,s,e,n)=>{for(var i=n>1?void 0:n?je(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&Ie(s,e,i),i};let S=class extends J{constructor(s){super(s);c(this,"_delOnSkeletonDel");c(this,"_delOnAtlasDel");c(this,"_hasInit",!1);c(this,"atlas",null);c(this,"skeletonRawData","");c(this,"skeletonData")}async initByMain(s){const e=await s.text();try{JSON.parse(e),this.skeletonRawData=e}catch{this.skeletonRawData=await s.arrayBuffer()}const n=this.meta,{atlas:i}=n;this.atlas=i;const a=await this.root.assetStore.getAssetByRef(i),o=E(this.skeletonRawData,a,!0);o&&this.createDragTempEntity(o)}createDragTempEntity(s){this.skeletonData=s;const e=new K(this.engine),n=e.addComponent(v);n.resource=new T(this.engine,this.skeletonData),this.setDragTempEntity(e)}instantiate(){if(!this.skeletonData)return;const s=this.root.sceneStore.createEntity(),e=this.getDragTempEntity(),{position:n,rotation:i}=e.transform,a={components:[{class:"SpineAnimationRenderer",id:W(),props:{resource:this.getCurrentRef(),priority:0,defaultConfig:{loop:!1,animationName:"none",skinName:"default"}}}],id:s.id,isActive:!0,isClone:!1,name:this.name?this.name:"spine",position:{x:n.x,y:n.y,z:n.z},rotation:{x:i.x,y:i.y,z:i.z},scale:{x:1,y:1,z:1}};return s.initByFile(a),s}};_([L({assetType:"SpineAtlas",label:w("asset.spine-atlas.title"),type:X.AssetPicker,onChange:async(t,s,e)=>{if(t._delOnAtlasDel&&(t._delOnAtlasDel(),t._delOnAtlasDel=null),e){let n=!0;t._hasInit?n=!1:t._hasInit=!0,t.skeletonData=E(t.skeletonRawData,e,n),t.skeletonData&&t.createDragTempEntity(t.skeletonData);const i=()=>{t._delOnSkeletonDel&&t._delOnSkeletonDel(),t._delOnSkeletonDel=null,t.skeletonData=null};e.on("delete",i),t._delOnSkeletonDel=()=>{e.off("delete",i)}}else t.skeletonData=null}}),Y()],S.prototype,"atlas",2);_([H()],S.prototype,"skeletonRawData",2);_([g.ref],S.prototype,"skeletonData",2);S=_([G({type:"SpineSkeletonData",label:w("asset.spine-skeleton-data.title"),loaderType:"Spine",viewer:m,dragLayer:Q.SpineSkeletonData,dragType:"2d",filterUploadFiles:we,importMenuConfig:{type:Z.Upload,accept:".json,.atlas,.skel,.png,.jpg,.jpeg,.webp",multiple:!0},bundle(t){return t.dependencies=ee(t.meta,["atlas"]),{content:t.content}}})],S);function E(t,s,e){if(!s)return null;try{return he.createSkeletonData(t,s.textureAtlas,.01)}catch{return!e&&te.error(w("spine.error.generate-skeleton-data")),null}}const Je=Object.freeze(Object.defineProperty({__proto__:null,get SpineSkeletonDataAsset(){return S}},Symbol.toStringTag,{value:"Module"}));export{S,Je as a,Me as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var c=(t,e,o)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var r=(t,e,o)=>(c(t,typeof e!="symbol"?e+"":e,o),o);import{s as m,az as h,p as g,C as b,f as u}from"./index-
|
|
1
|
+
var f=Object.defineProperty;var c=(t,e,o)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var r=(t,e,o)=>(c(t,typeof e!="symbol"?e+"":e,o),o);import{s as m,az as h,p as g,C as b,f as u}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import{c as d}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{L as P}from"./LightBaseComponent-4cfc9f48.js";var y=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(t,e,o,n)=>{for(var p=n>1?void 0:n?v(e,o):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(p=(n?s(e,o,p):s(p))||p);return n&&p&&y(e,o,p),p};let a=class extends P{constructor(e,o){super(e,o);r(this,"angle",20);r(this,"distance",60);r(this,"penumbra",60)}};i([m(h()),g({type:b.Slider,min:1,max:179,bindPath:"angle",label:"light.spot.angle.label",info:"light.spot.angle.info"}),u({getPath:"angle",getEditorValue:t=>t*180/Math.PI})],a.prototype,"angle",2);i([m(),g({type:b.Number,bindPath:"distance",label:"light.spot.distance.label",info:"light.spot.distance.info"})],a.prototype,"distance",2);i([m(h()),g({type:b.Slider,min:1,max:179,bindPath:"penumbra",label:"light.spot.penumbra.label",info:"light.spot.penumbra.info"}),u({getPath:"penumbra",getEditorValue:t=>t*180/Math.PI})],a.prototype,"penumbra",2);a=i([d({type:"SpotLight",componentsMenu:{group:"light",label:"component.light.spot.title"}})],a);export{a as SpotLightComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var y=(e,r,p)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):e[r]=p;var s=(e,r,p)=>(y(e,typeof r!="symbol"?r+"":r,p),p);import{p as d,C as a,s as c,aF as o,E as w}from"./index-
|
|
1
|
+
var f=Object.defineProperty;var y=(e,r,p)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):e[r]=p;var s=(e,r,p)=>(y(e,typeof r!="symbol"?r+"":r,p),p);import{p as d,C as a,s as c,aF as o,E as w}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";var C=Object.defineProperty,P=Object.getOwnPropertyDescriptor,b=(e,r,p,i)=>{for(var t=i>1?void 0:i?P(r,p):r,l=e.length-1,n;l>=0;l--)(n=e[l])&&(t=(i?n(r,p,t):n(t))||t);return i&&t&&C(r,p,t),t};class m extends w{constructor(){super(...arguments);s(this,"sprite",null);s(this,"color",{r:1,g:1,b:1,a:1});s(this,"drawMode",o.Simple)}}b([d({label:"sprite.renderer.sprite.label",info:"sprite.renderer.sprite.info",type:a.AssetPicker,assetType:"sprite",onChange:async(e,r,p)=>{e.sprite=p?p.getCurrentRef():null,await e.applyBoundPathChange("sprite",a.AssetPicker,e.sprite),e.emit("propertychange","sprite",p)}}),c()],m.prototype,"sprite",2);b([d({bindPath:"color",label:"sprite.renderer.color.label",info:"sprite.renderer.color.info",type:a.Color}),c()],m.prototype,"color",2);b([d({label:"sprite.renderer.draw-mode.label",info:"sprite.renderer.draw-mode.info",type:a.Select,bindPath:"drawMode",value:o.Simple,options:[{label:"sprite.renderer.draw-mode.simple",value:o.Simple},{label:"sprite.renderer.draw-mode.sliced",value:o.Sliced},{label:"sprite.renderer.draw-mode.tiled",value:o.Tiled}]}),c()],m.prototype,"drawMode",2);export{m as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var b=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(b(r,typeof e!="symbol"?e+"":e,t),t);import{E as h,aA as f,p as m,C as y,s as c,l as v,g as C}from"./index-
|
|
1
|
+
var u=Object.defineProperty;var b=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(b(r,typeof e!="symbol"?e+"":e,t),t);import{E as h,aA as f,p as m,C as y,s as c,l as v,g as C}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import{c as P}from"./Component-398551a0.js";import"./postmen-3b48c572.js";var g=Object.defineProperty,S=Object.getOwnPropertyDescriptor,o=(r,e,t,s)=>{for(var p=s>1?void 0:s?S(e,t):e,l=r.length-1,n;l>=0;l--)(n=r[l])&&(p=(s?n(e,t,p):n(p))||p);return s&&p&&g(e,t,p),p};let a=class extends h{constructor(e,t){super(e,t);i(this,"sprite",null);i(this,"alphaCutoff",.5);i(this,"influenceLayers",[f.Everything])}};o([m({label:"sprite.mask.sprite.label",info:"sprite.mask.sprite.info",type:y.AssetPicker,assetType:"sprite",bindPath:"sprite"}),c()],a.prototype,"sprite",2);o([m({label:"sprite.mask.alpha-cutoff.label",info:"sprite.mask.alpha-cutoff.info",dragStep:.01,min:0,max:1,type:y.Slider,bindPath:"alphaCutoff"}),c()],a.prototype,"alphaCutoff",2);o([c(v()),m({label:"sprite.mask.influence-layers.label",info:"sprite.mask.influence-layers.info",type:y.Select,...C([f.Nothing,f.Everything]),bindPath:"influenceLayers"})],a.prototype,"influenceLayers",2);a=o([P({type:"SpriteMask",componentsMenu:{group:"2D",label:"component.sprite-mask.title"}})],a);export{a as SpriteMaskComponent};
|