"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[940],{65134:function(e,s,t){t.d(s,{Z:function(){return a}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=(0,t(60998).Z)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},1125:function(e,s,t){t.d(s,{C:function(){return c}});var a=t(85893),n=t(67294),l=t(34209),i=t(84283);let r=e=>{if(!e||"string"!=typeof e)return e;let s=e.split("\n"),t=[];for(let e=0;e<s.length;e++){let a=s[e];if(""===a.trim()){let n=!1,l=0;for(let t=e-1;t>=0;t--){let e=s[t],a=e.trim();if(a&&e.match(/:\s*[|>]\s*$/)){n=!0;for(let e=t+1;e<s.length;e++){let t=s[e];if(t.trim()){l=t.search(/\S/);break}}break}if(a&&0===e.search(/\S/))break}if(n)for(let n=e+1;n<s.length;n++){let e=s[n];if(e.trim()){e.search(/\S/)>=l?t.push("  #YAML_BLANK_LINE_MARKER#"):t.push(a);break}}else t.push(a)}else t.push(a)}return t.join("\n")};function c(e){let{children:s,className:t=""}=e,c=(0,n.useRef)(null),d=r(s);(0,n.useEffect)(()=>{if(c.current){let e=c.current;setTimeout(()=>{let s;let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);for(;s=t.nextNode();)s.textContent&&s.textContent.includes("#YAML_BLANK_LINE_MARKER#")&&(s.textContent=s.textContent.replace(/#YAML_BLANK_LINE_MARKER#/g,""))},0)}},[d]);let o={...i.mQ,'code[class*="language-"]':{...i.mQ['code[class*="language-"]'],whiteSpace:"pre !important"},'pre[class*="language-"]':{...i.mQ['pre[class*="language-"]'],whiteSpace:"pre !important"}};return(0,a.jsx)("div",{ref:c,className:t,children:(0,a.jsx)(l.Z,{language:"yaml",style:o,customStyle:{margin:0,padding:0,background:"transparent",fontSize:"0.875rem",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace'},wrapLines:!0,wrapLongLines:!0,showLineNumbers:!1,useInlineStyles:!0,children:d})})}},50940:function(e,s,t){t.r(s),t.d(s,{RecipeDetail:function(){return A}});var a=t(85893),n=t(67294),l=t(11163),i=t(41664),r=t.n(i),c=t(55739),d=t(1272),o=t(96122),x=t(47603),m=t(60998);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let h=(0,m.Z)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var u=t(24544),p=t(70282);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let j=(0,m.Z)("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);var y=t(81021),b=t(27325),f=t(65134);t(37673);var g=t(30803),N=t(50326),v=t(42557),w=t(36185);t(69123);var k=t(65089);t(62935);var C=t(1125),_=t(15821),S=t(79586),L=t(98691),Z=t(470);function R(e){let{isOpen:s,onClose:t,template:l,onSave:i}=e,[r,x]=(0,n.useState)(""),[m,h]=(0,n.useState)(""),[u,p]=(0,n.useState)(!1),[j,y]=(0,n.useState)(null);(0,n.useEffect)(()=>{l&&s&&(x(l.description||""),h(l.content||""),y(null))},[l,s]);let b=async e=>{e.preventDefault(),p(!0),y(null);try{d.ZP.load(m)}catch(e){y("Invalid YAML: ".concat(e.message)),p(!1);return}try{await i({description:r||null,content:m}),t()}catch(e){y(e.message)}finally{p(!1)}};return l?(0,a.jsx)(N.Vq,{open:s,onOpenChange:t,children:(0,a.jsxs)(N.cZ,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto px-8",children:[(0,a.jsxs)(N.fK,{children:[(0,a.jsxs)(N.$N,{className:"text-xl text-gray-900",children:["Edit Recipe: ",l.name]}),(0,a.jsx)(N.Be,{children:"Update your recipe description and content."})]}),(0,a.jsxs)("form",{onSubmit:b,className:"space-y-4 mt-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(w._,{htmlFor:"description",children:"Description"}),(0,a.jsx)(v.I,{id:"description",value:r,onChange:e=>x(e.target.value),placeholder:"Optional description...",className:"placeholder:text-gray-500"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(w._,{htmlFor:"content",children:"YAML Content *"}),(0,a.jsx)(k.X,{value:m,onChange:e=>{h(e),y(null)},maxHeight:"400px"})]}),j&&(0,a.jsxs)("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 flex items-start gap-2",children:[(0,a.jsx)(o.Z,{className:"w-4 h-4 text-red-600 mt-0.5 flex-shrink-0"}),(0,a.jsx)("p",{className:"text-sm text-red-800",children:j})]}),(0,a.jsxs)(N.cN,{children:[(0,a.jsx)(g.z,{type:"button",variant:"outline",onClick:t,disabled:u,children:"Cancel"}),(0,a.jsx)(g.z,{type:"submit",disabled:u,className:"bg-sky-600 hover:bg-sky-700 text-white",children:u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:16,className:"mr-2"}),"Saving..."]}):"Save Changes"})]})]})]})}):null}function M(e){let{isOpen:s,onClose:t,template:l,onDelete:i}=e,[r,d]=(0,n.useState)(!1),o=async()=>{d(!0);try{await i(),t()}catch(e){(0,_.C)("Delete failed: ".concat(e.message),"error")}finally{d(!1)}};return l?(0,a.jsx)(N.Vq,{open:s,onOpenChange:t,children:(0,a.jsxs)(N.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(N.fK,{children:[(0,a.jsx)(N.$N,{className:"text-xl text-red-600",children:"Delete Recipe"}),(0,a.jsxs)(N.Be,{children:['Are you sure you want to delete "',l.name,'"? This action cannot be undone.']})]}),(0,a.jsxs)(N.cN,{className:"mt-4",children:[(0,a.jsx)(g.z,{variant:"outline",onClick:t,disabled:r,children:"Cancel"}),(0,a.jsx)(g.z,{onClick:o,disabled:r,className:"bg-red-600 hover:bg-red-700 text-white",children:r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:16,className:"mr-2"}),"Deleting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})})]})]})}):null}function A(){let e=(0,l.useRouter)(),{recipe:s}=e.query,[t,i]=(0,n.useState)(null),[d,o]=(0,n.useState)(!0),[m,N]=(0,n.useState)(null),[v,w]=(0,n.useState)(!1),[k,A]=(0,n.useState)(!1),[E,D]=(0,n.useState)(!1),[F,z]=(0,n.useState)(!1),[U,I]=(0,n.useState)(!1),K=(0,n.useCallback)(async()=>{if(!e.isReady||!s)return;let t=s||null;if(!t){N("Invalid template URL"),o(!1);return}o(!0),N(null);try{let e=await (0,S.G3)(t);e?i(e):N("Recipe not found")}catch(e){N(e.message||"Failed to load recipe")}finally{o(!1)}},[e.isReady,s]);(0,n.useEffect)(()=>{K()},[K]);let T=async e=>{let s=await (0,S.DI)(t.name,e);if(s)i(s),(0,_.C)("Recipe updated successfully!","success");else throw Error("Failed to update recipe")},Y=async()=>{if(await (0,S.eI)(t.name))(0,_.C)("Recipe deleted successfully!","success"),e.push("/recipes");else throw Error("Failed to delete recipe")},B=async()=>{try{let e=await (0,S.Uu)(t.name,!t.pinned);e&&(i(e),(0,_.C)(e.pinned?"Recipe pinned!":"Recipe unpinned!","success"))}catch(e){(0,_.C)("Recipe pin operation failed: ".concat(e.message),"error")}},O=async(e,s,t)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{let s=document.createElement("textarea");s.value=e,s.style.position="fixed",s.style.left="-999999px",s.style.top="-999999px",document.body.appendChild(s),s.focus(),s.select(),document.execCommand("copy"),s.remove()}t(!0),(0,_.C)(s,"success"),setTimeout(()=>t(!1),2e3)}catch(e){(0,_.C)("Failed to copy to clipboard","error")}};if(d)return(0,a.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."})]});if(m)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)("div",{className:"text-red-500 mb-4",children:m}),(0,a.jsx)(r(),{href:"/recipes",children:(0,a.jsxs)(g.z,{variant:"outline",children:[(0,a.jsx)(h,{className:"w-4 h-4 mr-2"}),"Back to Hub"]})})]});if(!t)return null;let q=(0,L.NL)(t.recipe_type),H=q.icon;return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)(r(),{href:"/recipes",className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(h,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Back"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(H,{className:"w-5 h-5 ".concat("sky"===q.color?"text-sky-600":"purple"===q.color?"text-purple-600":"green"===q.color?"text-green-600":"orange"===q.color?"text-orange-600":"text-gray-600")}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h1",{className:"text-base text-sky-blue leading-none",children:t.name}),t.pinned&&(0,a.jsx)(u.Z,{className:"w-4 h-4 text-amber-500"})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:(0,a.jsx)("span",{children:q.fullLabel})})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("button",{onClick:()=>{O(window.location.href,"Link copied to clipboard!",w)},className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[v?(0,a.jsx)(p.Z,{className:"h-4 w-4 mr-1.5 text-green-600"}):(0,a.jsx)(j,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:v?"Copied!":"Share"})]}),(0,a.jsx)("button",{onClick:!1!==t.is_pinnable?B:void 0,className:"flex items-center ".concat(!1===t.is_pinnable?"text-gray-400 cursor-not-allowed":"text-sky-blue hover:text-sky-blue-bright"),title:!1===t.is_pinnable?"Default recipes cannot be pinned/unpinned":"",disabled:!1===t.is_pinnable,children:t.pinned?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Unpin"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Pin"})]})}),(0,a.jsxs)("button",{onClick:()=>{let s={name:"".concat(t.name,"-copied"),description:t.description,content:t.content,recipe_type:t.recipe_type};e.push({pathname:"/recipes",query:{copy:JSON.stringify(s)}})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(b.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Copy to New"})]}),(0,a.jsxs)("button",{onClick:!1!==t.is_editable?()=>z(!0):void 0,className:"flex items-center ".concat(!1===t.is_editable?"text-gray-400 cursor-not-allowed":"text-sky-blue hover:text-sky-blue-bright"),title:!1===t.is_editable?"Default recipes cannot be edited":"",disabled:!1===t.is_editable,children:[(0,a.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Edit"})]}),(0,a.jsxs)("button",{onClick:!1!==t.is_editable?()=>I(!0):void 0,className:"flex items-center ".concat(!1===t.is_editable?"text-gray-400 cursor-not-allowed":"text-red-600 hover:text-red-700"),title:!1===t.is_editable?"Default recipes cannot be deleted":"",disabled:!1===t.is_editable,children:[(0,a.jsx)(x.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Delete"})]})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Details"})}),(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:t.name})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Type"}),(0,a.jsx)("div",{className:"text-base mt-1",children:q.fullLabel})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Authored by"}),(0,a.jsx)("div",{className:"text-base mt-1",children:t.user_name||t.user_id||"Unknown"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Updated"}),(0,a.jsxs)("div",{className:"text-base mt-1",children:[(0,a.jsx)(Z.Zg,{date:t.updated_at?new Date(1e3*t.updated_at):null})," ","by ",t.updated_by_name||t.user_name||"Unknown"]})]})]}),t.description&&(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base mb-1",children:"Description"}),(0,a.jsx)("p",{className:"text-base text-gray-700",children:t.description})]}),(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Launch Command"}),(0,a.jsx)("button",{onClick:()=>{t&&O((0,L.UU)(t.recipe_type,t.name),"Command copied to clipboard!",A)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",title:k?"Copied!":"Copy command",children:k?(0,a.jsx)(p.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(b.Z,{className:"w-4 h-4"})})]}),(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 mt-2",children:(0,a.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:(0,L.UU)(t.recipe_type,t.name)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"YAML Content"}),(0,a.jsx)("button",{onClick:()=>{t&&O(t.content,"YAML copied to clipboard!",D)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",title:E?"Copied!":"Copy YAML",children:E?(0,a.jsx)(p.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(b.Z,{className:"w-4 h-4"})})]}),(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto mt-2",children:(0,a.jsx)(C.C,{className:"whitespace-pre-wrap",children:t.content})})]})]})]}),(0,a.jsx)(R,{isOpen:F,onClose:()=>z(!1),template:t,onSave:T}),(0,a.jsx)(M,{isOpen:U,onClose:()=>I(!1),template:t,onDelete:Y})]})}}}]);