1const __vite__fileDeps=["js/RumpusAPIForm-BHk114Pv.js","js/index-kY4EFsKJ.js","css/index-BuRDkfm_.css","js/formDates-DxeVnQC_.js","js/initialCaps-B9NrDe1M.js","js/validator-uRJGMinT.js","js/md2html-DV_Sq4v2.js","js/marked.esm-gV2jD0VQ.js","js/pixelRatio-BxNCYp4s.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); 2import{d as f,P as I,Q as g,U as b,$ as y,as as c,r as v,ar as k,aL as C,_ as $,a as w,o as r,c as n,b as a,t as m,g as o,q as l,M as u}from"./index-kY4EFsKJ.js";import{P as R}from"./prism-g2CvQ9jZ.js";const O=[{name:"name",type:"text",label:"Name",placeholder:"[Optional] Unique name",description:"Item names are optional, but when specified must be unique within the crate. These are handy as easier references than random itemIds. Like an itemId, they are only set on creation and cannot be changed after."},{name:"tags",type:"text",label:"Tags",parser:"cssv",placeholder:"[Optional] Comma-separated Item Tags",description:"Tags are strings that can be used in searches (exact matches only) or to store metadata about this Item."},{name:"collaborators",type:"text",label:"Collaborators",parser:"cssv",placeholder:"[Optional] Comma-separated collaborator Lookup Codes",description:"Items can have collaborators with special access permissions."},{name:"note",type:"text",label:"Note",description:"A note is a short string (256 max length) that is not searchable, but that is returned along with the rest of the Item metadata. This can be used to store small amounts of data retrievable in a single request. It can also be used to store something like a tag without creating an indexing burden."},{name:"content-type",type:"select",options:[{value:"application/json"},{value:"text/markdown"},{value:"text/plain"}]},{name:"text",type:"markdown-editor",label:"Text Content",description:"You can directly create content here instead of using file uploads, for content that is some sort of text/* type. If a file is also provided, only the file will be uploaded."},{name:"file",type:"file",label:"File Content",placeholder:"File containing content",description:"Items can be any standard filetype. If neither Text nor File Content are provided, will result in an Item with metadata only. This is perfectly fine!"}];function U(e){const t=new URL("https://bscotch.github.io/redirect");return t.searchParams.append("to",e),t}const _=f({components:{"rumpus-api-form":I(()=>g(()=>import("./RumpusAPIForm-BHk114Pv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])))},mixins:[b,y],data(){return{item:null,content:null,downloadingContent:!1,properties:[],creating:!1,editing:!1,apiDocURL:"/api/docs/storage/crates.html",deleteRequest:{url:"/api/storage/crates/{crateId}/items/{itemId}?permissionsOverride=true",method:"delete",headers:{"If-Match":"*"}},apiRequest:{url:"/api/storage/crates/{crateId}/items",method:"post"}}},computed:{crateId(){return this.$route.params.crateId},itemId(){return this.$route.params.itemId},itemURI(){return`${`${location.protocol}//${location.host}`}/api/storage/crates/${this.crateId}/items/${this.itemId}?permissionsOverride=true`},gameUri(){var s,i;let e;const t=C?"prod":c;if(this.crateId==="public-library"&&c==="localhost"?e=[`example://${c}/crate-items/public-library/${this.itemId}`,"Sample Deep Link URI (non-functional)"]:this.crateId==="cl2-saves"?e=[`crashlands-2://${t}/saves/${this.itemId}`,"Open this save in Crashlands 2"]:this.crateId==="cl2-workshop"&&((s=this.item)!=null&&s.tags.includes("snapshot"))?e=[`crashlands-2://${t}
2/snapshots/${this.itemId}`,"Open this Snapshot in Crashlands 2"]:this.crateId==="cl2-workshop"&&!((i=this.item)!=null&&i.tags.length)&&(e=[`crashlands-2://${t}/worlds/${this.itemId}`,"Open this World in Crashlands 2"]),e)return[e[0],U(e[0]).toString(),e[1]]},requestForm(){const e=[].concat(O);return this.creating||e.splice(0,1),e},stringifiedItem(){return this.$nextTick(()=>R.highlightElement(this.$refs.metadata)),JSON.stringify(this.item,null,2)}},created(){this.itemId&&this.itemId!="@new"?this.getItem():this.creating=!0},methods:{loadContent(){this.downloadingContent=!0,this.downloadCrateItem(this.crateId,this.itemId,{permissionsOverride:!0}).then(e=>{this.content=e.data,this.downloadingContent=!1})},parseAPIResponse(e){const t=Array.isArray(e.data)?e.data[0]:e.data;if(t&&t.itemId){this.itemId=="@new"&&(this.creating=!1,this.$router.push(`./${t.itemId}`)),this.editing=!1,this.item=t;const s=this.$refs.item;s&&s.scrollIntoView();const i=[];for(let d of t.records)i.push(t.records[d].userId);this.updateUsernames(this.item.collaborators.concat(i))}},getItem(){const e=`/api/storage/crates/${this.crateId}/items`,t={itemIds:this.itemId,permissionsOverride:!0};v(e,{params:t}).then(s=>{this.parseAPIResponse(s)}).catch(s=>{console.log(s)})},updateFilter(e){const{file:t,text:s}=e.data,i=e.data["content-type"];if(Reflect.deleteProperty(e.data,"file"),Reflect.deleteProperty(e.data,"text"),this.creating||(e.method="put",e.url+=`/${this.itemId}`,!t&&!s&&(e.url+="/metadata")),e.params={permissionsOverride:!0},k(e),e.data=t||s||null,e.headers["Content-Type"]=t?e.data.type||"text/plain":i,i=="application/json")try{JSON.parse(e.data)}catch{return"You specified JSON as the content-type, but the input could not be parsed as JSON."}return i?(e.headers["If-Match"]="*",e):"Content-type is required."},rerouteOnDelete(){this.$router.replace(`/admin/crates/${this.crateId}/items`)}}}),T={key:0,class:"crate-management"},P={class:"crate-details"},A={ref:"item",class:"crate"},S={key:0,class:"crate-summary"},D={class:"crateId"},F={class:"url-container"},L={class:"url"},N={class:"links reset"},E=["href"],q={key:0},V=["title","href"],B=["href"],J={class:"edit"},j={key:0},M=["href"],Y={key:1},H=["href"];function Q(e,t,s,i,d,W){const h=w("rumpus-api-form");return e.item||e.creating?(r(),n("div",T,[a("div",P,[a("div",A,[e.item?(r(),n("div",S,[a("div",D,"["+m(e.item.name||e.item.itemId)+"]",1),a("div",F,[a("div",L,m(e.itemURI),1)]),a("ul",N,[a("li",null,[a("a",{href:e.itemURI,download:""},"download",8,E)]),e.gameUri?(r(),n("li",q,[a("a",{title:e.gameUri[2],href:e.gameUri[0]},"deeplink",8,V),o("["),a("a",{title:"Shareable redirect link.",href:e.gameUri[1]},"shareable",8,B),o("] ")])):l("",!0)]),a("div",null,[a("pre",null,[a("code",{ref:"metadata",class:"language-javascript"},m(e.stringifiedItem),513)])])])):l("",!0),a("div",J,[!e.editing&&e.item?(r(),n("div",j,[a("p",null,[o(" Only edit this Item if you are absolutely, 100% sure you know what you're doing (refer to the "),a("a",{href:e.apiDocURL,target:"_blank"},"API docs",8,M),o(" for reference). ")]),a("button",{class:"btn rumpus-button",onClick:t[0]||(t[0]=p=>e.editing=!0)}," Edit this Item "),o(" Â "),e.creating?l("",!0):(r(),u(h,{key:"delete",class:"inline-block","button-text":"Delete this Item","confirmation-required":"Delete it FOREVER?","button-classes":{"rumpus-button-danger":1},request:e.deleteRequest,payload:{crateId:e.crateId,itemId:e.itemId},"success-callback":e.rerouteOnDelete},null,8,["request","payload","success-callback"]))])):(r(),n("div",Y,[a("p",null,[o(" See the "),a("a",{href:e.apiDocURL,target:"_blank"},"API docs",8,H),o(" for reference. ")]),a("p",null,[!e.creating&&!e.downloadingContent?(r(),n("a",{key:0,role:"button",onClick:t[1]||(t[1]=(...p)=>e.loadContent&&e.loadContent(...p))}," Load data into form ")):l("",!0)]),e.item&&e.requestForm.length&&!e.downloadingContent?(r(),u(h,{key:"edit","button-text":e.creating?"Create!":"Submit Changes!",request:e.apiRequest,form:e.requestForm,"request-filter":e.updateFilter,payload:{crateId:e.crateId,itemId:e.itemId},"success-callback":e.parseAPIResponse,"initial-values":e.item},null,8,["button-text","request","form","request-filter","payload","success-callback","initial-values"])):l("",!0)]))])],512)])])):l("",!0)}const K=$(_,[["render",Q],["__scopeId","data-v-9456c6a1"]]);export{K as default}; 3//# sourceMappingURL=CrateItem-ydmo8d9a.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.