"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4707],{65134:function(e,t,s){s.d(t,{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,s(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"}]])},47603:function(e,t,s){s.d(t,{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,s(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1125:function(e,t,s){s.d(t,{C:function(){return c}});var a=s(85893),n=s(67294),l=s(34209),i=s(84283);let r=e=>{if(!e||"string"!=typeof e)return e;let t=e.split("\n"),s=[];for(let e=0;e<t.length;e++){let a=t[e];if(""===a.trim()){let n=!1,l=0;for(let s=e-1;s>=0;s--){let e=t[s],a=e.trim();if(a&&e.match(/:\s*[|>]\s*$/)){n=!0;for(let e=s+1;e<t.length;e++){let s=t[e];if(s.trim()){l=s.search(/\S/);break}}break}if(a&&0===e.search(/\S/))break}if(n)for(let n=e+1;n<t.length;n++){let e=t[n];if(e.trim()){e.search(/\S/)>=l?s.push("  #YAML_BLANK_LINE_MARKER#"):s.push(a);break}}else s.push(a)}else s.push(a)}return s.join("\n")};function c(e){let{children:t,className:s=""}=e,c=(0,n.useRef)(null),d=r(t);(0,n.useEffect)(()=>{if(c.current){let e=c.current;setTimeout(()=>{let t;let s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);for(;t=s.nextNode();)t.textContent&&t.textContent.includes("#YAML_BLANK_LINE_MARKER#")&&(t.textContent=t.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:s,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})})}},84707:function(e,t,s){s.r(t),s.d(t,{RecipeDetail:function(){return R}});var a=s(85893),n=s(67294),l=s(11163),i=s(41664),r=s.n(i),c=s(55739),d=s(1272),o=s(47603),x=s(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 m=(0,x.Z)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var h=s(24544),p=s(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 u=(0,x.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"}]]),y=(0,x.Z)("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var j=s(27325),b=s(65134);s(37673);var f=s(30803),g=s(50326),N=s(42557),v=s(36185);s(69123);var w=s(65089);s(62935);var k=s(1125),C=s(15821),_=s(79586),S=s(98691),L=s(470);function Z(e){let{isOpen:t,onClose:s,template:l,onSave:i}=e,[r,o]=(0,n.useState)(""),[x,m]=(0,n.useState)(""),[h,p]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l&&t&&(o(l.description||""),m(l.content||""))},[l,t]);let u=async e=>{e.preventDefault(),p(!0);try{d.ZP.load(x)}catch(e){(0,C.C)("Invalid YAML: ".concat(e.message),"error"),p(!1);return}try{await i({description:r||null,content:x}),s()}catch(e){(0,C.C)("Error: ".concat(e.message),"error")}finally{p(!1)}};return l?(0,a.jsx)(g.Vq,{open:t,onOpenChange:s,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto px-8",children:[(0,a.jsxs)(g.fK,{children:[(0,a.jsxs)(g.$N,{className:"text-xl text-gray-900",children:["Edit Recipe: ",l.name]}),(0,a.jsx)(g.Be,{children:"Update your recipe description and content."})]}),(0,a.jsxs)("form",{onSubmit:u,className:"space-y-4 mt-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(v._,{htmlFor:"description",children:"Description"}),(0,a.jsx)(N.I,{id:"description",value:r,onChange:e=>o(e.target.value),placeholder:"Optional description...",className:"placeholder:text-gray-500"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(v._,{htmlFor:"content",children:"YAML Content *"}),(0,a.jsx)(w.X,{value:x,onChange:m,maxHeight:"400px"})]}),(0,a.jsxs)(g.cN,{children:[(0,a.jsx)(f.z,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),(0,a.jsx)(f.z,{type:"submit",disabled:h,className:"bg-sky-600 hover:bg-sky-700 text-white",children:h?(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:t,onClose:s,template:l,onDelete:i}=e,[r,d]=(0,n.useState)(!1),x=async()=>{d(!0);try{await i(),s()}catch(e){(0,C.C)("Delete failed: ".concat(e.message),"error")}finally{d(!1)}};return l?(0,a.jsx)(g.Vq,{open:t,onOpenChange:s,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(g.fK,{children:[(0,a.jsx)(g.$N,{className:"text-xl text-red-600",children:"Delete Recipe"}),(0,a.jsxs)(g.Be,{children:['Are you sure you want to delete "',l.name,'"? This action cannot be undone.']})]}),(0,a.jsxs)(g.cN,{className:"mt-4",children:[(0,a.jsx)(f.z,{variant:"outline",onClick:s,disabled:r,children:"Cancel"}),(0,a.jsx)(f.z,{onClick:x,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)(o.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})})]})]})}):null}function R(){let e=(0,l.useRouter)(),{recipe:t}=e.query,[s,i]=(0,n.useState)(null),[d,x]=(0,n.useState)(!0),[g,N]=(0,n.useState)(null),[v,w]=(0,n.useState)(!1),[R,A]=(0,n.useState)(!1),[E,D]=(0,n.useState)(!1),[F,z]=(0,n.useState)(!1),[U,I]=(0,n.useState)(!1),T=(0,n.useCallback)(async()=>{if(!e.isReady||!t)return;let s=t||null;if(!s){N("Invalid template URL"),x(!1);return}x(!0),N(null);try{let e=await (0,_.G3)(s);e?i(e):N("Recipe not found")}catch(e){N(e.message||"Failed to load recipe")}finally{x(!1)}},[e.isReady,t]);(0,n.useEffect)(()=>{T()},[T]);let K=async e=>{let t=await (0,_.DI)(s.name,e);if(t)i(t),(0,C.C)("Recipe updated successfully!","success");else throw Error("Failed to update recipe")},O=async()=>{if(await (0,_.eI)(s.name))(0,C.C)("Recipe deleted successfully!","success"),e.push("/recipes");else throw Error("Failed to delete recipe")},Y=async()=>{try{let e=await (0,_.Uu)(s.name,!s.pinned);e&&(i(e),(0,C.C)(e.pinned?"Recipe pinned!":"Recipe unpinned!","success"))}catch(e){(0,C.C)("Recipe pin operation failed: ".concat(e.message),"error")}},q=async(e,t,s)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}s(!0),(0,C.C)(t,"success"),setTimeout(()=>s(!1),2e3)}catch(e){(0,C.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(g)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:g}),(0,a.jsx)(r(),{href:"/recipes",children:(0,a.jsxs)(f.z,{variant:"outline",children:[(0,a.jsx)(m,{className:"w-4 h-4 mr-2"}),"Back to Hub"]})})]});if(!s)return null;let B=(0,S.NL)(s.recipe_type),H=B.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)(m,{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"===B.color?"text-sky-600":"purple"===B.color?"text-purple-600":"green"===B.color?"text-green-600":"orange"===B.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:s.name}),s.pinned&&(0,a.jsx)(h.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:B.fullLabel})})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("button",{onClick:()=>{q(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)(u,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:v?"Copied!":"Share"})]}),(0,a.jsx)("button",{onClick:!1!==s.is_pinnable?Y:void 0,className:"flex items-center ".concat(!1===s.is_pinnable?"text-gray-400 cursor-not-allowed":"text-sky-blue hover:text-sky-blue-bright"),title:!1===s.is_pinnable?"Default recipes cannot be pinned/unpinned":"",disabled:!1===s.is_pinnable,children:s.pinned?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Unpin"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Pin"})]})}),(0,a.jsxs)("button",{onClick:()=>{let t={name:"".concat(s.name,"-copied"),description:s.description,content:s.content,recipe_type:s.recipe_type};e.push({pathname:"/recipes",query:{copy:JSON.stringify(t)}})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(j.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Copy to New"})]}),(0,a.jsxs)("button",{onClick:!1!==s.is_editable?()=>z(!0):void 0,className:"flex items-center ".concat(!1===s.is_editable?"text-gray-400 cursor-not-allowed":"text-sky-blue hover:text-sky-blue-bright"),title:!1===s.is_editable?"Default recipes cannot be edited":"",disabled:!1===s.is_editable,children:[(0,a.jsx)(b.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Edit"})]}),(0,a.jsxs)("button",{onClick:!1!==s.is_editable?()=>I(!0):void 0,className:"flex items-center ".concat(!1===s.is_editable?"text-gray-400 cursor-not-allowed":"text-red-600 hover:text-red-700"),title:!1===s.is_editable?"Default recipes cannot be deleted":"",disabled:!1===s.is_editable,children:[(0,a.jsx)(o.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:s.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:B.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:s.user_name||s.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)(L.Zg,{date:s.updated_at?new Date(1e3*s.updated_at):null})," ","by ",s.updated_by_name||s.user_name||"Unknown"]})]})]}),s.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:s.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:()=>{s&&q((0,S.UU)(s.recipe_type,s.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:R?"Copied!":"Copy command",children:R?(0,a.jsx)(p.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(j.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,S.UU)(s.recipe_type,s.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:()=>{s&&q(s.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)(j.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)(k.C,{className:"whitespace-pre-wrap",children:s.content})})]})]})]}),(0,a.jsx)(Z,{isOpen:F,onClose:()=>z(!1),template:s,onSave:K}),(0,a.jsx)(M,{isOpen:U,onClose:()=>I(!1),template:s,onDelete:O})]})}}}]);