1import{j as e}from"./app-C1iegf7Q.js";import{u as F,H as T,L as u}from"./inertia-BpyZy4w-.js";import{T as L,V as E}from"./video-url-input-DQIKuIRO.js";import{R as V}from"./RichTextEditor-CGDxVgC4.js";import{B as j}from"./button-BE4q1_FS.js";import{I as g}from"./input-DJt0nBB3.js";import{L as o}from"./label-Czc25Mye.js";import{S as n,e as c,f as m,a as d,c as x}from"./select-Bn8hgKYl.js";import{S as f}from"./switch-DhdMz2rn.js";import{T as _}from"./textarea-CXLxrYIG.js";import{a as A}from"./admin-layout-BhXWbUlP.js";import{A as I}from"./arrow-left-DCX0fhKH.js";/* empty css */import"./criterion-select-CKY8-FHk.js";import"./sparkles-C0aC1RHI.js";import"./createLucideIcon-wqc1LSWg.js";import"./video-CJHgxwGi.js";import"./youtube-D44Ae3nQ.js";import"./circle-check-big-AJlsIacq.js";import"./circle-alert-D8tEThd5.js";import"./index-DgRF6w_M.js";import"./index-DJlprK4q.js";import"./index-DV0GpYST.js";import"./index-B9qJRYKv.js";import"./utils-BiuKVCuu.js";import"./link-DKPEjeqT.js";import"./underline-BUwyLhKb.js";import"./list-BgP0xxm1.js";import"./quote-BLp7dxmt.js";import"./undo-BjvUJKje.js";import"./loader-circle-C_KBZAGS.js";import"./image-vCg-0Xge.js";import"./minus-BxBzNlIL.js";import"./index-CGXdj8xB.js";import"./index-DdRFMukF.js";import"./index-BdQq_4o_.js";import"./index-Dc_FVRD7.js";import"./index-B0NHTN87.js";import"./index-C48dRAib.js";import"./index-BDqbV96p.js";import"./index-Cja0wFUH.js";import"./index-CL12STDK.js";import"./Combination-Cr5kvm8y.js";import"./index-C_n-C52S.js";import"./index-D4vO54bj.js";import"./index-BRU_LjHB.js";import"./index-XydtsrKA.js";import"./index-Cs5D2gCo.js";import"./index-DyGg2PJd.js";import"./chevron-down-B1YaU0K5.js";import"./check-0O-UND6N.js";import"./chevron-up-CLp5HMgA.js";import"./app-logo-Dz0wogSq.js";import"./logo-light-DU4bWymm.js";import"./flash-toast-C6O0iVL1.js";import"./info-D2ZN_yLm.js";import"./triangle-alert-C7AVwNi-.js";import"./circle-x-Bp6Mbpgt.js";import"./circle-check-BMWvzPMx.js";import"./x-DQSeRCcH.js";import"./menu-BR3Nc3Gr.js";import"./users-BCcupCXV.js";import"./folder-open-I72SPUVk.js";import"./pound-sterling-D16GLaAZ.js";import"./book-open-DVFlG_9t.js";function Xe({resource:i,categories:v,types:y,accessLevels:b,journeys:N,criteria:k}){const{data:s,setData:r,patch:w,processing:p,errors:a}=F({title:i.title,category_id:i.category_id?.toString()||"",type:i.type,journey_key:i.journey_key??"general",content:i.content||"",excerpt:i.excerpt||"",access_level:i.access_level,is_published:i.is_published,featured_image:i.featured_image||"",metadata:i.metadata||{},use_markdown:i.use_markdown,criterion_code:i.criterion_code||"",template_schema:i.template_schema?JSON.stringify(i.template_schema,null,2):"",source_docx_path:i.source_docx_path||""}),S=t=>{t.preventDefault(),w(`/admin/resources/${i.id}`)},C=async t=>{const l=new FormData;l.append("image",t);const h=await fetch("/api/upload/image",{method:"POST",body:l,headers:{"X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")||""}});if(!h.ok)throw new Error("Upload failed");return(await h.json()).url};return e.jsxs(A,{children:[e.jsx(T,{title:`Edit: ${i.title} · Admin`}),e.jsx("div",{className:"px-4 py-5 sm:px-6 sm:py-7",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs(u,{href:"/admin/resources",className:"mb-2 inline-flex items-center gap-1 text-xs font-medium text-ink-3 hover:text-ink",children:[e.jsx(I,{className:"h-3.5 w-3.5"})," Back to Resources"]}),e.jsx("h1",{className:"text-xl font-semibold text-ink",children:"Edit Resource"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:i.title}),e.jsxs("p",{className:"text-xs text-ink-3",children:["Slug: ",i.slug]})]}),e.jsx("form",{onSubmit:S,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-ink",children:"Basic Information"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Core details about the resource"}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"title",children:"Title *"}),e.jsx(g,{id:"title",value:s.title,onChange:t=>r("title",t.target.value),placeholder:"e.g., Guide to UK Visa Applications",required:!0}),a.title&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.title}),e.jsx("p",{className:"mt-1 text-xs text-ink-3",children:"Slug will be updated if the title changes"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"category_id",children:"Category *"}),e.jsxs(n,{value:s.category_id,onValueChange:t=>r("category_id",t),children:[e.jsx(c,{children:e.jsx(m,{placeholder:"Select category"})}),e.jsx(d,{children:v.map(t=>e.jsx(x,{value:t.id.toString(),children:t.name},t.id))})]}),a.category_id&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.category_id})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"type",children:"Type *"}),e.jsxs(n,{value:s.type,onValueChange:t=>r("type",t),children:[e.jsx(c,{children:e.jsx(m,{placeholder:"Select type"})}),e.jsx(d,{children:Object.entries(y).map(([t,l])=>e.jsx(x,{value:t,children:l},t))})]}),a.type&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.type})]})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"journey_key",children:"Journey (Library grouping)"}),e.jsxs(n,{value:s.journey_key,onValueChange:t=>r("journey_key",t),children:[e.jsx(c,{className:"max-w-xs",children:e.jsx(m,{placeholder:"Select journey"})}),e.jsx(d,{children:Object.entries(N).map(([t,l])=>e.jsx(x,{value:t,children:l},t))})]}),e.jsx("p",{className:"mt-1 text-xs text-ink-3",children:"Groups this under a route in the members Library. Leave as general if it applies to everyone."}),a.journey_key&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.journey_key})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"excerpt",children:"Excerpt"}),e.jsx(_,{id:"excerpt",value:s.excerpt,onChange:t=>r("excerpt",t.target.value),rows:2,placeholder:"Brief summary for previews (max 500 characters)"}),a.excerpt&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.excerpt})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"content",children:"Content"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(f,{id:"use-markdown",checked:s.use_markdown,onCheckedChange:t=>r("use_markdown",t)}),e.jsx(o,{htmlFor:"airplane-mode",children:"Use Markdown"})]}
1),s.use_markdown?e.jsx(_,{id:"excerpt",value:s.content,onChange:t=>r("content",t.target.value),rows:30,placeholder:"Full content of the resource..."}):e.jsx(V,{value:s.content,onChange:t=>r("content",t),placeholder:"Full content of the resource...",error:a.content,onImageUpload:C,minHeight:"300px"})]})]})]}),s.type==="template"&&e.jsx(L,{title:s.title,journeyKey:s.journey_key,criterionCode:s.criterion_code,templateSchema:s.template_schema,sourceDocxPath:s.source_docx_path,criteria:k,onCriterion:t=>r("criterion_code",t),onSchema:t=>r("template_schema",t),onSourcePath:t=>r("source_docx_path",t),errors:a}),s.type==="video"&&e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-ink",children:"Video Settings"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Configure the video source for this resource"}),e.jsx("div",{className:"mt-4",children:e.jsx(E,{value:s.metadata?.video,onChange:t=>{const l={...s.metadata};t?(l.video=t,t.thumbnail&&!s.featured_image&&r("featured_image",t.thumbnail)):delete l.video,r("metadata",l)}})})]}),e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-ink",children:"Media"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Featured image for the resource"}),e.jsxs("div",{className:"mt-4",children:[e.jsx(o,{htmlFor:"featured_image",children:"Featured Image URL"}),e.jsx(g,{id:"featured_image",value:s.featured_image,onChange:t=>r("featured_image",t.target.value),placeholder:"https://example.com/image.jpg"}),a.featured_image&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.featured_image}),s.featured_image&&e.jsx("div",{className:"mt-2",children:e.jsx("img",{src:s.featured_image,alt:"Preview",className:"max-w-xs rounded border border-line",onError:t=>{t.target.style.display="none"}})})]})]}),e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-ink",children:"Access & Publishing"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Control who can access this resource"}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"access_level",children:"Access Level *"}),e.jsxs(n,{value:s.access_level,onValueChange:t=>r("access_level",t),children:[e.jsx(c,{className:"max-w-xs",children:e.jsx(m,{placeholder:"Select access level"})}),e.jsx(d,{children:Object.entries(b).map(([t,l])=>e.jsx(x,{value:t,children:l},t))})]}),a.access_level&&e.jsx("p",{className:"mt-1 text-xs text-red",children:a.access_level})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"is_published",children:"Published"}),e.jsx("p",{className:"text-sm text-ink-3",children:s.is_published?"This resource is visible to users":"This resource is saved as a draft"})]}),e.jsx(f,{id:"is_published",checked:s.is_published,onCheckedChange:t=>r("is_published",t)})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(j,{type:"button",variant:"outline",asChild:!0,children:e.jsx(u,{href:"/admin/resources",children:"Cancel"})}),e.jsx(j,{type:"submit",disabled:p,children:p?"Saving...":"Save Changes"})]})]})})]})})]})}export{Xe 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.