1import{f as R,u as F,H as z,D as I,g as V,r as p,h as H,c as l,a as o,b as P,w as D,l as U,i as B,j as i,t as A,m as s,v as g,I as L,A as O,J as M,e as K,o as u,d as W,G as j}from"#entry";import{u as q}from"./Dy9pVEbO.js";import{u as J}from"./Z8EQgydt.js";import"./DKLWY9DJ.js";const Y={class:"min-h-screen bg-gray-50 py-8"},$={class:"max-w-3xl mx-auto px-4 sm:px-6 lg:px-8"},Q={class:"mb-8"},X={class:"bg-white rounded-lg shadow-md p-6"},Z={class:"mb-6"},ee={class:"flex items-center space-x-6"},oe={class:"shrink-0"},te=["src"],ie={key:1,class:"h-32 w-32 bg-gray-200 rounded-lg flex items-center justify-center border-2 border-gray-300"},re={class:"cursor-pointer"},ne={key:0,class:"text-red-600 text-sm mt-2"},ae={class:"mb-6"},le={class:"mb-6"},se={class:"mb-6"},ue={class:"mb-6"},pe={class:"flex space-x-4"},de={class:"flex items-center"},he={class:"flex items-center"},ve={class:"mb-6"},ge={class:"mb-6"},ce={class:"mb-6"},me={key:0,class:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg"},be={class:"text-red-800"},fe={key:1,class:"mb-6 p-4 bg-green-50 border border-green-200 rounded-lg"},Se={class:"flex justify-end space-x-4"},ye=["disabled"],xe={key:0},Be={key:1},De=R({__name:"new",setup(ke){q({title:"Add a New Dog",description:"Add a dog to your DogHealthy account and start tracking health records, vaccinations and NFC tags in the UK.",path:"/dogs/new",index:!1});const c=F(),k=z(),T=I(),y=V(),t=p({name:"",breedSelection:"",customBreed:"",dateOfBirth:"",gender:"",weight:null,microchipNumber:"",notes:""}),m=p(null),w=p(null),h=p(""),b=p(""),C=p(!1),f=p(!1),G=p(null),N=n=>{const a=n.target.files?.[0];if(h.value="",!a)return;if(!a.type.startsWith("image/")){h.value="Please select an image file";return}if(a.size>5*1024*1024){h.value="File size must be less than 5MB";return}m.value=a;const r=new FileReader;r.onload=v=>{w.value=v.target?.result}
1,r.readAsDataURL(a)},_=async n=>{if(!m.value)return null;try{const e=m.value.name.split(".").pop(),r=`dogs/${`${n}_${Date.now()}.${e}`}`,{data:v,error:d}=await c.storage.from("doghealthy").upload(r,m.value,{cacheControl:"3600",upsert:!1});if(d)throw console.error("Upload error:",d),d;const{data:{publicUrl:S}}=c.storage.from("doghealthy").getPublicUrl(r);return S}catch(e){throw console.error("Error uploading photo:",e),e}},E=async()=>{if(!y.userId){b.value="You must be logged in to add a dog";return}b.value="",C.value=!1,f.value=!0;try{const{count:n,error:e}=await c.from("doghealthy_dogs").select("id",{count:"exact",head:!0}).eq("user_id",y.userId).eq("is_active",!0);if(e)throw e;if((n||0)>=3){await j("/dogs?addPack=1"),f.value=!1;return}const a=t.value.breedSelection==="Other"?t.value.customBreed:t.value.breedSelection,r={user_id:y.userId,name:t.value.name,breed:a||null,birth_date:t.value.dateOfBirth||null,gender:t.value.gender||null,weight_kg:t.value.weight||null,microchip_number:t.value.microchipNumber||null,notes:t.value.notes||null},{data:v,error:d}=await c.from("doghealthy_dogs").insert(r).select().single();if(d)throw console.error("Insert error:",d),d;let S=null;if(m.value&&v)try{if(S=await _(v.id),S){const{error:x}=await c.from("doghealthy_dogs").update({photo_url:S}).eq("id",v.id);x&&console.error("Error updating photo URL:",x)}}catch(x){console.error("Photo upload failed, but dog was created:",x),h.value="Dog added, but photo upload failed. You can add a photo later."}C.value=!0,setTimeout(()=>{k.push("/dogs")},1500)}catch(n){console.error("Error adding dog:",n),b.value=n.message||"Failed to add dog. Please try again."}finally{f.value=!1}};return H(()=>{if(!y.isAuthenticated){k.push("/auth/login");return}if(T.query.subscription==="success"){const{markSubscribed:n}=J();n();const e={...T.query};delete e.subscription,k.replace({path:T.path,query:e})}}),(n,e)=>{const a=K;return u(),l("div",Y,[o("div",$,[o("div",Q,[P(a,{to:"/dogs",class:"text-blue-600 hover:text-blue-700 font-medium mb-4 inline-flex items-center"},{default:D(()=>[...e[9]||(e[9]=[o("svg",{class:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})],-1),W(" Back to Dogs ",-1)])]),_:1}),e[10]||(e[10]=o("h1",{class:"text-3xl font-bold text-gray-900 mt-4"},"Add New Dog",-1)),e[11]||(e[11]=o("p",{class:"text-gray-600 mt-2"},"Fill in your dog's information below",-1))]),o("div",X,[o("form",{onSubmit:U(E,["prevent"])},[o("div",Z,[e[14]||(e[14]=o("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Dog Photo ",-1)),o("div",ee,[o("div",oe,[i(w)?(u(),l("img",{key:0,src:i(w),alt:"Dog photo preview",class:"h-32 w-32 object-cover rounded-lg border-2 border-gray-300"},null,8,te)):(u(),l("div",ie,[...e[12]||(e[12]=[o("svg",{class:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})],-1)])]))]),o("label",re,[e[13]||(e[13]=o("span",{class:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors inline-block"}," Choose Photo ",-1)),o("input",{type:"file",ref_key:"fileInput",ref:G,accept:"image/*",onChange:N,class:"hidden"},null,544)])]),i(h)?(u(),l("p",ne,A(i(h)),1)):B("",!0)]),o("div",ae,[e[15]||(e[15]=o("label",{for:"name",class:"block text-sm font-medium text-gray-700 mb-2"}," Dog Name * ",-1)),s(o("input",{id:"name","onUpdate:modelValue":e[0]||(e[0]=r=>i(t).name=r),type:"text",required:"",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your dog's name"},null,512),[[g,i(t).name]])]),o("div",le,[e[17]||(e[17]=o("label",{for:"breed",class:"block text-sm font-medium text-gray-700 mb-2"}," Breed ",-1)),s(o("select",{id:"breed","onUpdate:modelValue":e[1]||(e[1]=r=>i(t).breedSelection=r),class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"},[...e[16]||(e[16]=[O('<option value="">Select a breed...</option><option value="Affenpinscher">Affenpinscher</option><option value="Afghan Hound">Afghan Hound</option><option value="Airedale Terrier">Airedale Terrier</option><option value="Akita">Akita</option><option value="Alaskan Malamute">Alaskan Malamute</option><option value="American Bulldog">American Bulldog</option><option value="American Eskimo Dog">American Eskimo Dog</option><option value="American Staffordshire Terrier">American Staffordshire Terrier</option><option value="Australian Cattle Dog">Australian Cattle Dog</option><option value="Australian Shepherd">Australian Shepherd</option><option value="Australian Terrier">Australian Terrier</option><option value="Basenji">Basenji</option><option value="Basset Hound">Basset Hound</option><option value="Beagle">Beagle</option><option value="Bearded Collie">Bearded Collie</option><option value="Bedlington Terrier">Bedlington Terrier</option><option value="Belgian Malinois">Belgian Malinois</option><option value="Belgian Sheepdog">Belgian Sheepdog</option><option value="Belgian Tervuren">Belgian Tervuren</option><option value="Bernese Mountain Dog">Bernese Mountain Dog</option><option value="Bichon Frise">
1Bichon Frise</option><option value="Bloodhound">Bloodhound</option><option value="Border Collie">Border Collie</option><option value="Border Terrier">Border Terrier</option><option value="Borzoi">Borzoi</option><option value="Boston Terrier">Boston Terrier</option><option value="Bouvier des Flandres">Bouvier des Flandres</option><option value="Boxer">Boxer</option><option value="Briard">Briard</option><option value="Brittany">Brittany</option><option value="Brussels Griffon">Brussels Griffon</option><option value="Bull Terrier">Bull Terrier</option><option value="Bulldog">Bulldog</option><option value="Bullmastiff">Bullmastiff</option><option value="Cairn Terrier">Cairn Terrier</option><option value="Canaan Dog">Canaan Dog</option><option value="Cane Corso">Cane Corso</option><option value="Cardigan Welsh Corgi">Cardigan Welsh Corgi</option><option value="Cavalier King Charles Spaniel">Cavalier King Charles Spaniel</option><option value="Chesapeake Bay Retriever">Chesapeake Bay Retriever</option><option value="Chihuahua">Chihuahua</option><option value="Chinese Crested">Chinese Crested</option><option value="Chinese Shar-Pei">Chinese Shar-Pei</option><option value="Chow Chow">Chow Chow</option><option value="Clumber Spaniel">Clumber Spaniel</option><option value="Cocker Spaniel">Cocker Spaniel</option><option value="Collie">Collie</option><option value="Coton de Tulear">Coton de Tulear</option><option value="Dachshund">Dachshund</option><option value="Dalmatian">Dalmatian</option><option value="Doberman Pinscher">Doberman Pinscher</option><option value="Dogo Argentino">Dogo Argentino</option><option value="English Cocker Spaniel">English Cocker Spaniel</option><option value="English Setter">English Setter</option><option value="English Springer Spaniel">English Springer Spaniel</option><option value="English Toy Spaniel">English Toy Spaniel</option><option value="Finnish Spitz">Finnish Spitz</option><option value="Flat-Coated Retriever">Flat-Coated Retriever</option><option value="French Bulldog">French Bulldog</option><option value="German Pinscher">German Pinscher</option><option value="German Shepherd">German Shepherd</option><option value="German Shorthaired Pointer">German Shorthaired Pointer</option><option value="German Wirehaired Pointer">German Wirehaired Pointer</option><option value="Giant Schnauzer">Giant Schnauzer</option><option value="Golden Retriever">Golden Retriever</option><option value="Gordon Setter">Gordon Setter</option><option value="Great Dane">Great Dane</option><option value="Great Pyrenees">Great Pyrenees</option><option value="Greater Swiss Mountain Dog">Greater Swiss Mountain Dog</option><option value="Greyhound">Greyhound</option><option value="Havanese">Havanese</option><option value="Ibizan Hound">Ibizan Hound</option><option value="Irish Setter">Irish Setter</option><option value="Irish Terrier">Irish Terrier</option><option value="Irish Water Spaniel">Irish Water Spaniel</option><option value="Irish Wolfhound">Irish Wolfhound</option><option value="Italian Greyhound">Italian Greyhound</option><option value="Jack Russell Terrier">Jack Russell Terrier</option><option value="Japanese Chin">Japanese Chin</option><option value="Keeshond">Keeshond</option><option value="Kerry Blue Terrier">Kerry Blue Terrier</option><option value="Komondor">Komondor</option><option value="Kuvasz">Kuvasz</option><option value="Labrador Retriever">Labrador Retriever</option><option value="Lakeland Terrier">Lakeland Terrier</option><option value="Leonberger">Leonberger</option><option value="Lhasa Apso">Lhasa Apso</option><option value="Maltese">Maltese</option><option value="Manchester Terrier">Manchester Terrier</option><option value="Mastiff">Mastiff</option><option value="Miniature Pinscher">Miniature Pinscher</option><option value="Miniature Schnauzer">Miniature Schnauzer</option><option value="Mixed Breed">Mixed Breed</option><option value="Newfoundland">Newfoundland</option><option value="Norfolk Terrier">Norfolk Terrier</option><option value="Norwegian Elkhound">Norwegian Elkhound</option><option value="Norwich Terrier">Norwich Terrier</option><option value="Nova Scotia Duck Tolling Retriever">Nova Scotia Duck Tolling Retriever</option><option value="Old English Sheepdog">Old English Sheepdog</option><option value="Papillon">Papillon</option><option value="Parson Russell Terrier">Parson Russell Terrier</option><option value="Pekingese">Pekingese</option><option value="Pembroke Welsh Corgi">Pembroke Welsh Corgi</option><option value="Pharaoh Hound">Pharaoh Hound</option><option value="Pointer">Pointer</option><option value="Pomeranian">Pomeranian</option><option value="Poodle (Standard)">Poodle (Standard)</option><option value="Poodle (Miniature)">Poodle (Miniature)</option><option value="Poodle (Toy)">Poodle (Toy)</option><option value="Portuguese Water Dog">Portuguese Water Dog</option><option value="Pug">Pug</option><option value="Puli">Puli</option><option value="Rhodesian Ridgeback">Rhodesian Ridgeback</option><option value="Rottweiler">Rottweiler</option><option value="Saint Bernard">Saint Bernard</option><option value="Saluki">Saluki</option><option value="Samoyed">Samoyed</option><option value="Schipperke">Schipperke</option><option value="Scottish Deerhound">Scottish Deerhound</option><option value="Scottish Terrier">Scottish Terrier</option><option value="Shetland Sheepdog">Shetland Sheepdog</option><option value="Shiba Inu">Shiba Inu</option><option value="Shih Tzu">Shih Tzu</option><option value="Siberian Husky">Siberian Husky</option><option value="Silky Terrier">Silky Terrier</option><option value="Smooth Fox Terrier">Smooth Fox Terrier</option><option value="Soft Coated Wheaten Terrier">Soft Coated Wheaten Terrier</option><option value="Staffordshire Bull Terrier">Staffordshire Bull Terrier</option><option value="Standard Schnauzer">Standard Schnauzer</option><option value="Sussex Spaniel">Sussex Spaniel</option><option value="Tibetan Mastiff">Tibetan Mastiff</option><option value="Tibetan Spaniel">Tibetan Spaniel</option><option value="Tibetan Terrier">Tibetan Terrier</option><option value="Vizsla">Vizsla</option><option value="Weimaraner">Weimaraner</option>
1<option value="Welsh Springer Spaniel">Welsh Springer Spaniel</option><option value="Welsh Terrier">Welsh Terrier</option><option value="West Highland White Terrier">West Highland White Terrier</option><option value="Whippet">Whippet</option><option value="Wire Fox Terrier">Wire Fox Terrier</option><option value="Wirehaired Pointing Griffon">Wirehaired Pointing Griffon</option><option value="Yorkshire Terrier">Yorkshire Terrier</option><option value="Other">Other</option>',144)])],512),[[L,i(t).breedSelection]]),i(t).breedSelection==="Other"?s((u(),l("input",{key:0,"onUpdate:modelValue":e[2]||(e[2]=r=>i(t).customBreed=r),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent mt-3",placeholder:"Enter your dog's breed"},null,512)),[[g,i(t).customBreed]]):B("",!0)]),o("div",se,[e[18]||(e[18]=o("label",{for:"dateOfBirth",class:"block text-sm font-medium text-gray-700 mb-2"}," Date of Birth ",-1)),s(o("input",{id:"dateOfBirth","onUpdate:modelValue":e[3]||(e[3]=r=>i(t).dateOfBirth=r),type:"date",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"},null,512),[[g,i(t).dateOfBirth]])]),o("div",ue,[e[21]||(e[21]=o("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Gender ",-1)),o("div",pe,[o("label",de,[s(o("input",{"onUpdate:modelValue":e[4]||(e[4]=r=>i(t).gender=r),type:"radio",value:"male",class:"mr-2 text-blue-600 focus:ring-blue-500"},null,512),[[M,i(t).gender]]),e[19]||(e[19]=o("span",{class:"text-gray-700"},"Male",-1))]),o("label",he,[s(o("input",{"onUpdate:modelValue":e[5]||(e[5]=r=>i(t).gender=r),type:"radio",value:"female",class:"mr-2 text-blue-600 focus:ring-blue-500"},null,512),[[M,i(t).gender]]),e[20]||(e[20]=o("span",{class:"text-gray-700"},"Female",-1))])])]),o("div",ve,[e[22]||(e[22]=o("label",{for:"weight",class:"block text-sm font-medium text-gray-700 mb-2"}," Weight (kg) ",-1)),s(o("input",{id:"weight","onUpdate:modelValue":e[6]||(e[6]=r=>i(t).weight=r),type:"number",step:"0.1",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"e.g., 25.5"},null,512),[[g,i(t).weight,void 0,{number:!0}]])]),o("div",ge,[e[23]||(e[23]=o("label",{for:"microchipNumber",class:"block text-sm font-medium text-gray-700 mb-2"}," Microchip Number ",-1)),s(o("input",{id:"microchipNumber","onUpdate:modelValue":e[7]||(e[7]=r=>i(t).microchipNumber=r),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter microchip number"},null,512),[[g,i(t).microchipNumber]])]),o("div",ce,[e[24]||(e[24]=o("label",{for:"notes",class:"block text-sm font-medium text-gray-700 mb-2"}," Notes ",-1)),s(o("textarea",{id:"notes","onUpdate:modelValue":e[8]||(e[8]=r=>i(t).notes=r),rows:"4",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Any additional information about your dog..."},null,512),[[g,i(t).notes]])]),i(b)?(u(),l("div",me,[o("p",be,A(i(b)),1)])):B("",!0),i(C)?(u(),l("div",fe,[...e[25]||(e[25]=[o("p",{class:"text-green-800"},"Dog added successfully!",-1)])])):B("",!0),o("div",Se,[P(a,{to:"/dogs",class:"px-6 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors"},{default:D(()=>[...e[26]||(e[26]=[W(" Cancel ",-1)])]),_:1}),o("button",{type:"submit",disabled:i(f),class:"px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[i(f)?(u(),l("span",xe,"Saving...")):(u(),l("span",Be,"Add Dog"))],8,ye)])],32)])])])}}});export{De 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.