1import{d as M,r as m,i as N,G as I,k as z,w as Y,e as t,a,b as u,t as V,V as w,g as _,P as D,Q as F,h as $,o as r,$ as G}from"./index-DbpIxVVg.js";import{P as R}from"./PageContent-CaO1rUex.js";import{_ as A}from"./ErrorView.vue_vue_type_script_setup_true_lang-rTuR_K5N.js";import{F as T}from"./FormHorizontalSeparator-YmnZb4LI.js";/* empty css */import{u as H,r as B}from"./index-Do6wnMIg.js";import{Z as Q}from"./Zone-B11tA2dI.js";import{Z as J}from"./ZoneService-DSqzE2hY.js";import{S as L}from"./StopService-BhxaPd7K.js";import{j as O,S as W}from"./Stop-8NKSpgr4.js";import{c as X}from"./SearchService-CvvzWgdB.js";import{_ as tt}from"./TransitEntitySelect.vue_vue_type_script_setup_true_lang-Cl4izas8.js";import"./ErrorContent.vue_vue_type_script_setup_true_lang--XFDxIpt.js";import"./RoundedBadge-zDfp8xRL.js";import"./ArrowTopRightOnSquareIcon-Bwi8lzNJ.js";import"./ChevronRightIcon-CKGSa4-R.js";import"./disclosure-DbKVSJYz.js";import"./keyboard-C910qfwt.js";import"./ZoneResult-BCcwIQtm.js";import"./WFCheckIn-C1ZIiw9D.js";import"./PointOfInterest-Buj-zZdX.js";import"./AbstractVehicleResult-8ISW0izZ.js";import"./MapVehicleAnnotation-Bkrf91WN.js";import"./MapAnnotation-Cz1h2O1h.js";/* empty css */import"./RouteGroup-C9eTeiZ3.js";import"./SearchPaletteItem.vue_vue_type_script_setup_true_lang-4nHU3J_8.js";import"./RouteGlyph.vue_vue_type_script_setup_true_lang-CZS1VAaM.js";import"./combobox-Bf1jGWS7.js";import"./form-BG81DLzL.js";import"./calculate-active-index-Bo9BYas1.js";import"./use-tree-walker-DlTPShXD.js";const et={class:"my-2 px-4 sm:px-0"},ot={class:"text-3xl font-extrabold tracking-tight text-gray-900 dark:text-gray-100"},st={key:0},nt={key:1},rt={key:0,class:"sm:ml-6"},at={class:"px-4 py-5 sm:px-6"},it={class:"mt-2 text-lg"},dt={class:"mt-8 text-sm text-gray-500"},lt={key:2,class:"text-center my-5"},mt={key:3,action:"#",method:"post"},ut={class:"md:grid md:grid-cols-3 md:gap-6"},pt={class:"mt-5 md:mt-0 md:col-span-2"},ct={class:"shadow sm:rounded-md"},ft={class:"px-4 py-5 bg-white dark:bg-gray-800 space-y-6 sm:p-6"},gt={class:"mt-1"},yt={key:0,class:"mt-2 text-sm text-red-500"},vt={class:"mt-1"},xt={key:0,class:"mt-2 text-sm text-red-500"},bt={class:"px-4 sm:px-0"},kt={class:"flex justify-end"},ht=["disabled"],ee=M({__name:"TrackworkTaskZoneCreateView",props:{stopGtfsId:{type:String,required:!0},countryCode:{type:String,required:!0},regionCode:{type:String,required:!0}},setup(v){const i=v,o=m(),P=m(!1),x=m(!1),p=m(),b=m(),C=new J,q=new L,k=H({name:{required:B},parentGtfsId:{required:B}},o),c=m();N(async()=>{try{await K()}catch(s){p.value=s}});async function K(){var Z;const s=I.fromKey(i),e={gtfsId:i.stopGtfsId,regionCode:i.regionCode,countryCode:i.countryCode},n=(await C.findByKeys([e.gtfsId])).find(E=>E.key===e.gtfsId);if(n){b.value=n;return}const d=await q.findByGtfsId(e,!0);if(!d)throw new Error("Invalid stop");const f=((Z=d.parentStop)==null?void 0:Z.typeId)===100?d.parentStop:null,g=new X;f&&(g.stop=f,g.title=f.name,g.key=f.gtfsId),c.value=g;const y=Q.create(s);y.name=y.stopZone.name=d.name;const l=y.stopZone;l.stopIds=[i.stopGtfsId],l.roleKeys=["bus_marshal_capture"],l.stopZoneType=O.PlatformIsland,l.parent=d.parentId,l.allowCheckin=!0,l.key=d.gtfsId,o.value=y}async function U(){if(await k.value.$validate()){x.value=!0,p.value=null;try{const s=I.fromKey(i);o.value.stopZone.name=o.value.name,o.value=await C.commit(o.value,s),await G.go(-1)}catch(s){p.value=s}finally{x.value=!1}}}async function S(){await G.go(-1)}function j(){const s=c.value;s&&s.entity instanceof W&&(o.value.stopZone.parent=s.entity.gtfsId)}return(s,e)=>(r(),z(R,null,{default:Y(()=>{var h;return[t("div",et,[t("h1",ot,[(h=o.value)!=null&&h.id?(r(),a("span",st,"Update zone")):(r(),a("span",nt,"Create new zone"))])]),b.value?(r(),a("div",rt,[t("div",at,[t("p",it,"A zone for this stop already exists: "+V(b.value.name)+".",1),e[5]||(e[5]=t("p",{class:"mt-2 text-md text-gray-500"},"You should attach to the existing zone.",-1)),t("p",dt,[t("button",{type:"button",class:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500",onClick:e[0]||(e[0]=w(n=>S(),["prevent"]))}," Go back ")])])])):u("",!0),p.value?(r(),z(A,{key:1,error:p.value,verb:"create",thing:"zone"},null,8,["error"])):u("",!0),P.value&&!o.value?(r(),a("div",lt,e[6]||(e[6]=[t("p",{class:"lead"},[t("i",{class:"fa fa-spinner fa-spin"}),t("span",{class:"ml-3"},"Updating...")],-1)]))):u("",!0),o.value?(r(),a("form",mt,[_(T),t("div",ut,[e[11]||(e[11]=t("div",{class:"md:col-span-1"},[t("div",{class:"px-4 sm:px-0"},[t("h3",{class:"text-lg font-medium leading-6 text-gray-900 dark:text-gray-100"},"Zone details"),t("p",{class:"mt-1 text-sm text-gray-600 dark:text-gray-400"},"Create a new zone.")])],-1)),t("div",pt,[t("div",ct,[t("div",ft,[t("div",null,[e[7]||(e[7]=t("label",{for:"zone-name",class:"block text-sm font-medium text-gray-700 dark:text-gray-300"}," Zone name ",-1)),e[8]||(e[8]=t("p",{class:"mt-1 text-sm text-gray-600 dark:text-gray-400"}
1," This will be set as the stop name by default but can be overwritten. ",-1)),t("div",gt,[D(t("input",{id:"name","onUpdate:modelValue":e[1]||(e[1]=n=>o.value.name=n),type:"text",name:"name",class:"focus:ring-orange-500 focus:border-orange-500 flex-1 block rounded-md shadow-sm w-full sm:text-sm border-gray-300 dark:bg-black dark:border-gray-700",placeholder:"Zone name"},null,512),[[F,o.value.name]]),$(k).name.$error?(r(),a("p",yt,"You must give the zone a name.")):u("",!0)])]),t("div",null,[e[9]||(e[9]=t("label",{for:"zone-name",class:"block text-sm font-medium text-gray-700 dark:text-gray-300"}," Zone parent station ",-1)),e[10]||(e[10]=t("p",{class:"mt-1 text-sm text-gray-600 dark:text-gray-400"}," This should prefill automatically and should usually be left as-is. ",-1)),t("div",vt,[_(tt,{modelValue:c.value,"onUpdate:modelValue":[e[2]||(e[2]=n=>c.value=n),j],placeholder:"Select a station","region-code":v.regionCode,"country-code":v.countryCode,"entity-types":["stop"],"route-types":[100,401]},null,8,["modelValue","region-code","country-code"])]),$(k).parentGtfsId.$error?(r(),a("p",xt,"You must select a parent station.")):u("",!0)])])])])]),_(T),t("div",bt,[t("div",kt,[t("button",{type:"button",class:"bg-white dark:bg-black py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500",onClick:e[3]||(e[3]=w(n=>S(),["prevent"]))}," Cancel "),t("button",{type:"submit",disabled:x.value,class:"ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500",onClick:e[4]||(e[4]=w(n=>U(),["prevent"]))},V("Create zone"),8,ht)])])])):u("",!0)]}),_:1}))}});export{ee as default};
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.