import{a2 as e,h as a,o as l,Y as t,a4 as s,a5 as o,$ as i,c as n,ar as p,ap as d}from"./index.3938ccd1.js";import{Q as r}from"./QPage.62812de7.js";import{u as c}from"./use-quasar.63a27b45.js";import{F as u}from"./FileUploadS3.c8d8f3ba.js";import{globalNav as m}from"./common.0a9f0488.js";import{u as v}from"./T3Data.cbe80363.js";import{l as f}from"./api.bf47c78e.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 A,_;const j=c(),x=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()=>{x.push({path:"/apps-library/user/apps"}),j.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==(_=null==(A=window.chrome)?void 0:A.webview)||_.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};
