1import{m as i,j as N,e as g,a as m,b as _,h as T,d as s,l as j,x as F,f as R,o as w,c as V,t as D,g as G,B as k,A as d}from"./app-DWwbkxzy.js";import{_ as W}from"./AdminLayout-DD0R75QB.js";import{_ as M}from"./MedImageWorkbench-QZI6FNxZ.js";import"./SidebarLayout-Dfse5RnS.js";const S={class:"mx-auto max-w-7xl space-y-6 px-4 py-6 sm:px-6 lg:px-8"},A={class:"flex flex-wrap items-start justify-between gap-4"},E={key:0,class:"rounded-md border border-red-200 bg-red-50 px-4 py-2 text-sm text-red-800"},H=Object.assign({layout:null},{__name:"SystemicMedicationImageWorkbench",props:{medication:{type:Object,required:!0}},setup(n){const t=n,u=i(t.medication.image_url||null),h=i(t.medication.generic_name||""),p=i(!1),l=i(null),f=i(null),b=d(()=>[t.medication.brand_names,t.medication.generic_name].filter(e=>typeof e=="string"&&e.trim()!=="").join(" ").trim()),r=t.medication.representative_ndc||"",y=r?`https://ndclist.com/ndc/${r}/images`:"",v=r?`https://www.google.com/search?tbm=isch&q=${encodeURIComponent(r)}`:"",I=d(()=>b.value?`https://www.google.com/search?tbm=isch&q=${encodeURIComponent(b.value)}`:"https://www.google.com/imghp"),U=d(()=>t.medication.generic_name?`https://pubchem.ncbi.nlm.nih.gov/#query=${encodeURIComponent(t.medication.generic_name)}`:"https://pubchem.ncbi.nlm.nih.gov/"),C=d(()=>{const a=[];return y&&a.push({label:"View NDC Images",url:y,iframe:!0}),a.push({label:"Google Images For Medication Name",url:I.value}),v&&a.push({label:"Google Images For NDC",url:v}),a.push({label:"PubChem (molecule diagrams)",url:U.value}),a}),$=async({file:a})=>{var e,o,x;p.value=!0,l.value=null;try{const c=new FormData;c.append("image",a);const{data:B}=await k.post(route("admin.systemic-medications.image.upload",t.medication.id),c,{headers:{"Content-Type":"multipart/form-data"}});u.value=B.image_url,(e=f.value)==null||e.resetFile()}catch(c){l.value=((x=(o=c.response)==null?void 0:o.data)==null?void 0:x.message)||"Image upload failed."}finally{p.value=!1}},q=async()=>{var a,e;try{await k.delete(route("admin.systemic-medications.image.clear",t.medication.id)),u.value=null}catch(o){l.value=((e=(a=o.response)==null?void 0:a.data)==null?void 0:e.message)||"Failed to clear image."}};return(a,e)=>(w(),N(W,{title:`Image Workbench: ${n.medication.display_name}`},{default:g(()=>[m(_(T),{title:`Image Workbench: ${n.medication.display_name}`},null,8,["title"]),s("div",S,[s("div",A,[e[2]||(e[2]=s("div",null,[s("h1",{class:"text-2xl font-semibold text-gray-900"}," Image Workbench "),s("p",{class:"mt-1 text-sm text-gray-600"}," Browse image sources on the right, upload on the left. ")],-1)),m(_(j),{href:a.route("admin.systemic-medications.edit",n.medication.id)},{default:g(()=>[m(F,{variant:"secondary",icon:"mdi-arrow-left"},{default:g(()=>[...e[1]||(e[1]=[R(" Back To Edit ",-1)])]),_:1})]),_:1},8,["href"])]),l.value?(w(),V("div",E,D(l.value),1)):G("",!0),m(M,{ref_key:"workbenchRef",ref:f,title:n.medication.display_name,"image-url":u.value,"alt-text":h.value,"onUpdate:altText":e[0]||(e[0]=o=>h.value=o),"quick-links":C.value,busy:p.value,"can-clear":"","upload-label":"Upload And Save",onUpload:$,onClear:q},null,8,["title","image-url","alt-text","quick-links","busy"])])]),_:1},8,["title"]))}});export{H 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.