import{a1 as e,h as a,o as l,X as t,a3 as s,a4 as o,Z as i,c as n,aq as p,ao as d}from"./index.9313841a.js";import{Q as r}from"./QPage.51e20052.js";import{u as c}from"./use-quasar.ca800b49.js";import{F as u}from"./FileUploadS3.c9d78bff.js";import{b as m}from"./common.356e5c35.js";import{u as v}from"./T3Data.889a220d.js";import{l as f}from"./api.c096d0cb.js";import"./index.57b723e8.js";import"./_commonjsHelpers.a5007c1f.js";import"./plugin-vue_export-helper.21dcd24c.js";import"./index.d11c4764.js";const y={class:"flex flex-col w-full max-w-7xl"},g={class:"flex items-center"},b={class:"image-container relative w-52"},h={class:"flex grid-cols-4 gap-4"},w={__name:"CreateApp",setup(w){var j,x;const A=c(),_=e(),I=a({}),E=a(null);function T(e){return delete e.type,delete e.id,delete e.pid,delete e.command,delete e.decom,e}function U(e){const a=e.body;I.value.imageId=a.id,P()}async function D(){var e,a;v.value&&((null==(a=null==(e=E.value)?void 0:e.uppy.getFiles())?void 0:a.length)>0?E.value.upload():P())}function P(){f.post("t3Apps",{json:I.value}).then((async()=>{_.push({path:"/apps-library/user/apps"}),A.notify({type:"positive",message:"Application saved"})})).catch((e=>{}))}return l((()=>{var e,a;m.value.title="Create Application",m.value.back="/apps-library",null==(a=null==(e=window.chrome)?void 0:e.webview)||a.postMessage({action:1})})),null==(x=null==(j=window.chrome)?void 0:j.webview)||x.addEventListener("message",(e=>{var a,l,t;"action"in e.data&&("GET_INITIAL_DATA_RES"===e.data.action?(e.data.data&&(e.data.data=JSON.parse(e.data.data)),null==(l=null==(a=window.chrome)?void 0:a.webview)||l.postMessage({action:0,panelId:e.data.entry.pid})):"GET_PANEL_DATA_RES"===e.data.action&&(null==(t=e.data)?void 0:t.panel_id)&&(I.value=function(e){const a=(e,a)=>{const l=e.filter(a);return l.length?l.map(T):void 0},{panel_id:l,ranges:t,data:s}=e,o=a(s,(e=>"INPUT"===e.type)),i=a(s,(e=>"OUTPUT"===e.type)),n=a(s,(e=>"VARIABLE"===e.type)),p=a(s,(e=>"GRP"===e.type)),d=a(s,(e=>"PID"===e.type)),r=a(s,(e=>"SCHEDULE"===e.type)),c=a(s,(e=>"PROGRAM"===e.type)),u=a(s,(e=>"HOLIDAY"===e.type));return{panelId:l||0,inputs:o,outputs:i,variables:n,graphics:p,pids:d,schedules:r,programs:c,holidays:u,ranges:t}}(e.data)))})),(e,a)=>(t(),s(r,{class:"flex justify-center p-4"},{default:o((()=>[i("div",y,[i("div",g,[i("div",b,[n(u,{ref_key:"fileUploaderRef",ref:E,path:"app-images",types:["image/*"],height:150,onUploaded:U},null,512)]),n(p,{class:"grow px-4",modelValue:I.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>I.value.name=e),label:"Name"},null,8,["modelValue"])]),n(p,{class:"py-2",modelValue:I.value.description,"onUpdate:modelValue":a[1]||(a[1]=e=>I.value.description=e),label:"Description",type:"textarea",autogrow:""},null,8,["modelValue"]),i("div",h,[n(d,{label:"Save",color:"primary",icon:"save",onClick:D}),n(d,{label:"Cancel",icon:"cancel",to:"/apps-library"})])])])),_:1}))}};export{w as default};
