import{u as R}from"./BdkQROIT.js";import{ay as l}from"./CGbLrLYS.js";function z(r,y={},C={}){const u=R({content:l(r,"content"),activeKey:l(r,"activeKey"),editable:l(r,"editable"),onContentClick:r.onContentClick,textStyle:r.textStyle}),{pick:x,resolveKey:S,resolveTextStyle:b,isActive:w,handleClick:I,interactive:f}=u,o=t=>typeof t=="string"?x(t):t;function v(t,n){const e=String(o(t)?.attribute?.[n]??"");return(C.rawText&&n==="value"?e:e.trim())||(r.generatorPreview&&typeof t=="string"?y[t]?.[n]??"":"")}const k=t=>v(t,"value"),L=t=>v(t,"src");function P(t){const n=o(t)?.attribute,e=String(n?.target??"").trim();if(!e)return;const g=e.match(/^([a-z][a-z\d+.-]*):/i)?.[1]?.toLowerCase();if(g&&!["http","https","mailto","tel"].includes(g))return;const c=Number(n?.categoriesId);if(!Number.isSafeInteger(c)||c<=0||!e.startsWith("/")||e.startsWith("//"))return r.footerData?.resolveCategoryLink?.(e)??e;const i=e.indexOf("#"),K=i>=0?e.slice(i):"",s=i>=0?e.slice(0,i):e,a=s.indexOf("?"),O=a>=0?s.slice(0,a):s,h=new URLSearchParams(a>=0?s.slice(a+1):"");h.set("categoriesId",String(c));const m=`${O}?${h.toString()}${K}`;return r.footerData?.resolveCategoryLink?.(m)??m}function d(t,n){return f.value?(n?.preventDefault(),n?.stopPropagation(),I(o(t)),!0):!1}function D(t){const n=o(t);return{"data-content-key":S(n)||(typeof t=="string"?t:void 0),style:b(n),class:{"cursor-pointer":f.value,"outline outline-2 outline-offset-4 outline-[var(--theme-primary-color)]":r.editable&&w(n)},onClick:e=>d(t,e)}}return{...u,text:k,src:L,href:P,select:d,bind:D}}export{z as u};
