"use strict";(self.webpackChunkmulti_token_edit=self.webpackChunkmulti_token_edit||[]).push([[394],{394:(e,t,n)=>{n.d(t,{registerActions:()=>o});var a=n(6596),i=n(8652),s=n(8118);async function o(e){e.registerTileGroup(a.Do,"Mass Edit"),e.registerTileAction(a.Do,"me-spawn-preset",{name:"Spawn Preset",requiresGM:!0,ctrls:[{type:"line",help:"Target"},{id:"location",name:"Location",type:"select",subtype:"location",options:{show:["tile","token","within","players","previous","tagger"]},restrict:(e,t)=>(e instanceof foundry.canvas.placeables.Token||e instanceof foundry.canvas.placeables.Tile||e instanceof foundry.canvas.placeables.Drawing||e instanceof foundry.canvas.placeables.Region||e instanceof foundry.canvas.placeables.AmbientLight||e instanceof foundry.canvas.placeables.AmbientSound||e instanceof foundry.canvas.placeables.Note)&&t?.parent?.id==e?.document?.parent?.id||t?.parent?.id==e?.id,required:!0},{type:"line",help:"Presets to Spawn"},{id:"query",name:"Query",type:"text",placeholder:"e.g. tree #summer -palm"},{id:"uuids",name:"UUIDs",type:"text",subtype:"multiline",placeholder:"One UUID per line"}],values:{},group:a.Do,fn:async(t={})=>{const{tile:n,action:o,userId:r,value:l,method:c,change:u}=t;let{uuids:d,query:p}=o.data;d=d.trim(),p=p.trim();const f=new Collection;if(d){(await i.P0.retrieve({uuid:d.split("\n").map(e=>e.trim()).filter(Boolean)})).forEach(e=>{f.set(e.uuid,e)})}if(p){(await i.P0.retrieve({query:p})).forEach(e=>{f.set(e.uuid,e)})}if(!f.size)return;console.log({presetCollection:f});const y=await e.getLocation.call(n,o.data.location,t);if(!y?.length)return;const m=[...f],g={world:{spawnPreset:{originTileId:n.id,signature:o.data.signature}}};for(const e of y){const t={x:e.x,y:e.y};e.dest&&e.dest instanceof foundry.documents.TileDocument&&({x:t.x,y:t.y}=e.dest.shape.center);const n=m[Math.floor(Math.random()*m.length)];await s.T.spawnPreset({preset:n,x:t.x,y:t.y,scaleToGrid:!1,sceneId:e.dest.parent.id,pivot:a.S8.CENTER,flags:g})}console.log({locations:y})},content:async(e,t)=>"Mass Edit TESTING"})}}}]);
//# sourceMappingURL=394.mass-edit.js.map