(()=>{"use strict";var e,t={526(){const e=window.wp.blocks,t=window.wp.blockEditor,a=window.wp.components,n=window.wp.i18n,s=JSON.parse('{"UU":"gateway/route-link"}'),l=window.ReactJSXRuntime;(0,e.registerBlockType)(s.UU,{edit:({attributes:e,setAttributes:s,context:i})=>{const{path:o,label:r,useDynamicPath:p,pathTemplate:c}=e,{"gateway/itemName":h="item","gateway/inLoop":d=!1,"gateway/availableFields":g=[]}=i,u=(0,t.useBlockProps)({className:"gateway-route-link"}),w=p?c:o;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.InspectorControls,{children:(0,l.jsxs)(a.PanelBody,{title:(0,n.__)("Path Settings","gateway"),children:[(0,l.jsx)(a.ToggleControl,{label:(0,n.__)("Use Dynamic Path Template","gateway"),checked:p,onChange:e=>s({useDynamicPath:e}),help:(0,n.__)("Enable to use template syntax with loop variables","gateway")}),!p&&(0,l.jsx)(a.TextControl,{label:(0,n.__)("Static Path","gateway"),value:o,onChange:e=>s({path:e}),placeholder:"/about",help:(0,n.__)('The route path to navigate to (e.g., "/", "/about", "/course/web-dev").',"gateway")}),p&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.TextControl,{label:(0,n.__)("Path Template","gateway"),value:c,onChange:e=>s({pathTemplate:e}),placeholder:`/course/{${h}.slug}`,help:(0,n.__)("Use {variable.field} syntax for dynamic values","gateway")}),!d&&(0,l.jsx)(a.Notice,{status:"warning",isDismissible:!1,children:(0,n.__)("Dynamic paths work best inside loop blocks where item data is available.","gateway")}),d&&g&&g.length>0&&(0,l.jsxs)("div",{style:{marginTop:"12px"},children:[(0,l.jsx)("p",{className:"components-base-control__label",children:(0,n.__)("Available Fields:","gateway")}),(0,l.jsx)("ul",{style:{margin:"8px 0 0 0",paddingLeft:"20px",fontSize:"12px",fontFamily:"monospace"},children:g.map(e=>(0,l.jsx)("li",{children:(0,l.jsx)("code",{children:`{${h}.${e}}`})},e))})]})]})]})}),(0,l.jsxs)("div",{...u,children:[(0,l.jsx)(t.RichText,{tagName:"span",value:r,onChange:e=>s({label:e}),placeholder:(0,n.__)("Enter link text...","gateway"),className:"gateway-route-link__text"}),(0,l.jsxs)("span",{className:"gateway-route-link__path",children:["→ ",w||"/"]})]})]})},save:({attributes:e})=>{const{path:a,label:n,useDynamicPath:s,pathTemplate:i}=e,o="gateway/route-link";let r={...t.useBlockProps.save({className:"gateway-route-link"}),"data-wp-on--click":"actions.navigate",type:"button"},p={},c={};if(s&&i){const{tokens:e,parts:t}=function(e){if(!e||"string"!=typeof e)return{tokens:[],parts:[""]};const t=[],a=/\{([^}]+)\}/g;let n;for(;null!==(n=a.exec(e));)t.push(n[1].trim());return{tokens:t,parts:e.split(/\{[^}]+\}/)}}(i);r["data-wp-interactive"]=o,r["data-wp-bind--data-path"]="state.dynamicPath",p={templateData:{template:i,tokens:e,parts:t},staticPath:a||"/"},c["data-wp-interactive"]=o,c["data-wp-context"]=JSON.stringify(p)}else r["data-wp-interactive"]="gateway/router",r["data-path"]=a||"/";const h=(0,l.jsx)("button",{...r,children:n||"Link"});return s&&i?(0,l.jsx)("div",{...c,children:h}):h}})}},a={};function n(e){var s=a[e];if(void 0!==s)return s.exports;var l=a[e]={exports:{}};return t[e](l,l.exports,n),l.exports}n.m=t,e=[],n.O=(t,a,s,l)=>{if(!a){var i=1/0;for(c=0;c<e.length;c++){for(var[a,s,l]=e[c],o=!0,r=0;r<a.length;r++)(!1&l||i>=l)&&Object.keys(n.O).every(e=>n.O[e](a[r]))?a.splice(r--,1):(o=!1,l<i&&(i=l));if(o){e.splice(c--,1);var p=s();void 0!==p&&(t=p)}}return t}l=l||0;for(var c=e.length;c>0&&e[c-1][2]>l;c--)e[c]=e[c-1];e[c]=[a,s,l]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={293:0,225:0};n.O.j=t=>0===e[t];var t=(t,a)=>{var s,l,[i,o,r]=a,p=0;if(i.some(t=>0!==e[t])){for(s in o)n.o(o,s)&&(n.m[s]=o[s]);if(r)var c=r(n)}for(t&&t(a);p<i.length;p++)l=i[p],n.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return n.O(c)},a=globalThis.webpackChunkgateway_block_types=globalThis.webpackChunkgateway_block_types||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var s=n.O(void 0,[225],()=>n(526));s=n.O(s)})();