1import{N as ee,e as U}from"./main-DQIWCOKl.js";import{U as L}from"./utils-BGIwY-9G.js";import{_ as Xe}from"./preload-helper-DusM-f9e.js";class Ge{constructor({eventManager:e}){this.eventManager=e}async _renderLayerCreate(e){const t=this,s=Habersoft.routes.ajax["layer_create.render"],r=document.querySelector(".layout-create-modal");if(!r)return;const i=t.textContent;t.disabled=!0,t.textContent="Yükleniyor...";try{const a=await(await L.customFetch(s,{method:"POST"})).json(),l=L.parseHTMLWithScripts(a);r.innerHTML=l.html,L.executeScripts(l.scripts)}catch(o){console.error("Katman içeriÄi yüklenirken hata oluÅtu:",o),ee.error("Bir sorun oluÅtu.")}finally{t.disabled=!1,t.textContent=i}}init(){this.eventManager.subscribe("click",".layout-create",this._renderLayerCreate.bind(this))}}class Je{constructor({eventManager:e}){this.eventManager=e,this.init()}clearSideMenuContainers(){document.querySelectorAll("#moduleEditPanel .homepage-edit-panel, #moduleEditStylePanel .homepage-edit-panel").forEach(t=>{t.textContent=""})}setTabStartState(){document.getElementById("modules-content-tab").classList.add("show","active"),document.getElementById("modules-styles-pane").classList.remove("show","active"),document.getElementById("modules-content-tab-opener").classList.add("active"),document.getElementById("modules-styles-pane-tab-opener").classList.remove("active"),document.getElementById("pills-tab")?.classList.remove("d-none")}generateContrastColor(e){const t=parseInt(e.substr(1,2),16),s=parseInt(e.substr(3,2),16),r=parseInt(e.substr(5,2),16);return(.299*t+.587*s+.114*r)/255>.5?"#000000":"#FFFFFF"}initShadowControls(e){e.querySelectorAll(".shadow-control").forEach(t=>{const s=t.dataset.checkstylevalue??"";t.checked=!s.includes("none"),t.addEventListener("input",()=>{const r=t.dataset.customizationElement;document.querySelectorAll(r).forEach(i=>{i.style.textShadow=t.checked?"1px 1px 1px #000":"none"})})})}initHoverStyleInputs(e){let t=document.getElementById("__pseudo-preview-style");t||(t=document.createElement("style"),t.id="__pseudo-preview-style",document.head.appendChild(t)),e.querySelectorAll('.module-style-items input[data-customization-element*=":hover"],.module-style-items select[data-customization-element*=":hover"]').forEach(s=>{const r=s.dataset.customizationElement,i=r.replace(/:[\w-]+/g,""),o=s.getAttribute("data-customization-element-style"),a=l=>{document.querySelectorAll(i).forEach(p=>{p.style[this._cssPropToCamel(o)]=l});const c=t.sheet,u=Array.from(c?.cssRules??[]).findIndex(p=>p.selectorText===r);u>=0&&c.deleteRule(u),c.insertRule(`${r} { ${o}: ${l}; }`,c.cssRules.length)};s.value&&a(s.value),["input","change"].forEach(l=>s.addEventListener(l,()=>a(s.value)))})}initStyleInputs(e){const t=new Set(["font-size","line-height","border-width","width","height","margin-bottom","margin-right","margin-top","margin-left","letter-spacing","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"]),s=new Set(["top","bottom","left","right"]),r=(o,a)=>s.has(a)?"%":t.has(a)?o.closest(".unit-toggle-cont")?.querySelector(".unit-percent-toggle")?.checked?"%":"px":"",i=o=>{const a=o.dataset.customizationElement,l=o.getAttribute("data-customization-element-style"),c=o.value+r(o,l);document.querySelectorAll(a).forEach(d=>{d.style[this._cssPropToCamel(l)]=c})};e.querySelectorAll(".module-style-items input:not(.padding-setting-input):not(.margin-setting-input):not(.border-setting-input):not([data-style-target])").forEach(o=>{const a=o.dataset.customizationElement??"";a.includes(":hover")||a.includes(":focus")||o.addEventListener("input",()=>i(o))}),e.querySelectorAll(".unit-toggle-cont .unit-percent-toggle").forEach(o=>{o.addEventListener("change",()=>{o.closest(".unit-toggle-cont").querySelectorAll("input[data-customization-element-style]").forEach(i)})})}initStyleSelects(e){e.querySelectorAll(".module-style-items select:not(.border-setting-input)").forEach(t=>{t.addEventListener("change",()=>{const s=t.dataset.customizationElement,r=t.getAttribute("data-customization-element-style"),i=t.value;
1document.querySelectorAll(s).forEach(o=>{o.style[this._cssPropToCamel(r)]=i})})})}initLinearGradientControls(e){function t(r){const i=[];let o=0,a="";for(const l of r)l==="("?o++:l===")"&&o--,l===","&&o===1?(i.push(a.trim()),a=""):a+=l;return i.push(a.trim()),i}function s(r){const i=r.lastIndexOf(" ");return i===-1?[r,""]:[r.slice(0,i),r.slice(i+1)]}e.querySelectorAll(".linear-container").forEach(r=>{const i=r.dataset.styleValue??"",o=t(i),a=f=>(f??"").replace(/[%)]/g,"").trim(),l=o[0]?.split("(")?.[1]?.trim()??"",c=l.includes("deg");let d,u,p,v;c?(d=l.replace("deg","").trim(),u=o[1]??"",p=o[2]??"",v=o[3]??""):(d="",u=l,p=o[1]??"",v=o[2]??"");const h=s(p),S=s(v),y={gradientDegree:d,transparentPercentValue:a(s(u)[1])||"0",color1Value:h[0]||"#ffffff",color1PercentValue:a(h[1])||"0",color2Value:S[0]||"#000000",color2PercentValue:a(S[1])||"100"},g=f=>{const{gradientDegree:m,transparentPercentValue:b,color1Value:_,color1PercentValue:A,color2Value:E,color2PercentValue:x}=y,T=`linear-gradient(${m?`${m}deg, `:""}transparent ${b}%, ${_} ${A}%, ${E} ${x}%)`,k=f.dataset.customizationElement,O=f.getAttribute("data-customization-element-style");
1document.querySelectorAll(k).forEach(R=>{R.style[this._cssPropToCamel(O)]=T})};r.querySelectorAll("input[data-style-target]").forEach(f=>{switch(f.dataset.styleTarget){case"color-percent":f.value=y.gradientDegree,f.addEventListener("input",()=>{y.gradientDegree=f.value,g(f)});break;case"color-transparent-percent":f.value=y.transparentPercentValue,f.addEventListener("input",()=>{y.transparentPercentValue=f.value,g(f)});break;case"colorVal-1":f.value=y.color1Value,f.style.background=f.value,["input","change"].forEach(m=>{f.addEventListener(m,b=>{y.color1Value=f.value,g(f),f.style.background=f.value,f.style.color=this.generateContrastColor(f.value)})});break;case"color-1-intensity":f.value=y.color1PercentValue,f.addEventListener("input",()=>{y.color1PercentValue=f.value,g(f)});break;case"colorVal-2":f.value=y.color2Value,f.style.background=f.value,["input","change"].forEach(m=>{f.addEventListener(m,()=>{y.color2Value=f.value,g(f),f.style.background=f.value,f.style.color=this.generateContrastColor(f.value)})});break;case"color-2-intensity":f.value=y.color2PercentValue,f.addEventListener("input",()=>{y.color2PercentValue=f.value,g(f)});break}})})}initPaddingControls(e){e.querySelectorAll(".module-style-items .custom-padding-cont").forEach(t=>{const s=(t.dataset.paddingValues??"0 0 0 0").split(" ");t.querySelectorAll("input").forEach(r=>{switch(r.dataset.paddingWay){case"top":r.value=s[0];break;case"right":r.value=s[1];break;case"bottom":r.value=s[2];break;case"left":r.value=s[3];break}}),t.querySelectorAll("input").forEach(r=>{r.addEventListener("change",()=>{const i=t.dataset.customizationElement,o={top:"",right:"",bottom:"",left:""};t.querySelectorAll("input").forEach(l=>{const c=l.dataset.paddingWay;c in o&&(o[c]=`${l.value}px`)});const a=`${o.top} ${o.right} ${o.bottom} ${o.left}`;document.querySelectorAll(i).forEach(l=>{l.style.padding=a})})})})}initMarginControls(e){e.querySelectorAll(".module-style-items .custom-margin-cont").forEach(t=>{const s=(t.dataset.marginValues??"0 0 0 0").split(" ");t.querySelectorAll("input").forEach(r=>{switch(r.dataset.marginWay){case"top":r.value=s[0]??0;break;case"right":r.value=s[1]??0;break;case"bottom":r.value=s[2]??0;break;case"left":r.value=s[3]??0;break}}),t.querySelectorAll("input").forEach(r=>{r.addEventListener("change",()=>{const i=t.dataset.customizationElement,o={top:"0px",right:"0px",bottom:"0px",left:"0px"};t.querySelectorAll("input").forEach(l=>{const c=l.dataset.marginWay;c in o&&(o[c]=`${l.value}px`)});const a=`${o.top} ${o.right} ${o.bottom} ${o.left}`;document.querySelectorAll(i).forEach(l=>{l.style.margin=a})})})})}initBorderControls(e){e.querySelectorAll(".module-style-items .custom-border-cont").forEach(t=>{const r=(t.dataset.borderValues??"1px solid #000000").trim().split(/\s+/),i=(r[0]??"1px").replace("px",""),o=r[1]??"solid",a=r[2]??"#000000",l=t.querySelector('[data-border-part="width"]'),c=t.querySelector('[data-border-part="style"]'),d=t.querySelector('[data-border-part="color"]');l&&(l.value=i),c&&(c.value=o),d&&(d.value=a,d.style.background=a,a.startsWith("#")&&a.length>=7&&(d.style.color=this.generateContrastColor(a)));const u=()=>{const p=l?.value??"1",v=c?.value??"solid",h=d?.value??"#000000";d&&(d.style.background=h,h.startsWith("#")&&h.length>=7&&(d.style.color=this.generateContrastColor(h)));const S=t.dataset.customizationElement,y=this._cssPropToCamel(t.dataset.customizationElementStyle||"border");document.querySelectorAll(S).forEach(g=>{g.style[y]=`${p}px ${v} ${h}`})};l?.addEventListener("input",u),c?.addEventListener("change",u),["input","change"].forEach(p=>d?.addEventListener(p,u))})}initClipPathControls(e){e.querySelectorAll(".custom-clip-path-cont").forEach(t=>{this._initClipPathEditor(t)})}_initClipPathEditor(e){const t=e.dataset.customizationElement,s=e.querySelector(".clip-path-preview"),r=e.querySelector(".clip-path-value-input"),i=e.querySelector(".clip-path-add-point"),o=e.querySelector(".clip-path-reset");if(!s||!r)return;let a=[];const l=()=>"polygon("+a.map(v=>`${v.x.toFixed(2)}% ${v.y.toFixed(2)}%`).join(", ")+")",c=v=>{document.querySelectorAll(t).forEach(h=>{h.style.clipPath=v})},d=()=>{const v=l();s.style.clipPath=v,r.value=v,c(v)},u=(v,h)=>{v.addEventListener("mousedown",S=>{S.preventDefault();const y=f=>{const m=s.getBoundingClientRect(),b=Math.max(0,Math.min(f.clientX-m.left,m.width)),_=Math.max(0,Math.min(f.clientY-m.top,m.height)),A=b/m.width*100,E=_/m.height*100;
1v.style.left=`${A}%`,v.style.top=`${E}%`,a[h]={x:A,y:E},d()},g=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)}),v.addEventListener("dblclick",()=>{if(a.length<=3){alert("Bir Åeklin en az 3 noktası olmalıdır.");return}a.splice(h,1),p(l())})},p=v=>{s.innerHTML="",a=[],(!v||!v.startsWith("polygon")||v.split(",").length<3)&&(v="polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"),v.replace(/polygon\(|\)/g,"").split(",").forEach((S,y)=>{const g=S.trim().split(/\s+/),f=parseFloat(g[0]),m=parseFloat(g[1]);a.push({x:f,y:m});const b=document.createElement("div");b.className="clip-path-point",b.style.left=`${f}%`,b.style.top=`${m}%`,s.appendChild(b),u(b,y)}),d()};i?.addEventListener("click",()=>{a.push({x:50,y:50}),p(l())}),o?.addEventListener("click",()=>{p("polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)")}),p(r.value)}initBorderRadiusControls(e){e.querySelectorAll('.border-radius-control input[type="range"]').forEach(t=>{t.addEventListener("input",()=>{const s=t.dataset.customizationElement,r=t.getAttribute("data-customization-element-style"),i=t.value;t.closest(".border-radius-control")?.querySelector(".border-radius-value")?.replaceChildren(document.createTextNode(i)),document.querySelectorAll(s).forEach(o=>{o.style[this._cssPropToCamel(r)]=i+"px"})})})}initTooltips(e){e.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(t=>{new bootstrap.Tooltip(t)})}initTransformControls(e){e.querySelectorAll(".transform-control").forEach(t=>{const s=t.dataset.customizationElement,r=t.querySelector(".transform-value-input"),i=t.querySelector(".transform-input-x"),o=t.querySelector(".transform-input-y");if(!i||!o||!r)return;const a=()=>{const l=i.value||0,c=o.value||0,d=`translate(${l}%, ${c}%)`;document.querySelectorAll(s).forEach(u=>{u.style.transform=d}),r.value=d};i.addEventListener("input",a),o.addEventListener("input",a)})}initTextAlignControls(e){e.querySelectorAll(".text-align-control").forEach(t=>{const s=t.querySelector(".text-align-value-input");if(!s)return;const r=t.dataset.customizationElement;t.querySelectorAll(".flex-control-btn[data-value]").forEach(i=>{i.addEventListener("click",()=>{t.querySelectorAll(".flex-control-btn").forEach(o=>o.classList.remove("active")),i.classList.add("active"),s.value=i.dataset.value,r&&document.querySelectorAll(r).forEach(o=>{o.style.textAlign=i.dataset.value}),s.dispatchEvent(new Event("input",{bubbles:!0}))})})})}initFlexControls(e){e.querySelectorAll(".flex-controls-panel").forEach(t=>{const s=t.dataset.customizationElement,r={};t.querySelectorAll(".flex-value-input[data-style-property]").forEach(d=>{r[d.dataset.styleProperty]=d});const i=r.display;if(!i)return;const o=i.value&&i.value!=="flex"?i.value:"block",a=(d,u)=>{r[d]&&(r[d].value=u,r[d].dispatchEvent(new Event("input",{bubbles:!0})))},l=()=>{s&&document.querySelectorAll(s).forEach(d=>{Object.entries(r).forEach(([u,p])=>{d.style[this._cssPropToCamel(u)]=p.value})})};t.querySelectorAll(".flex-control-btn[data-property]").forEach(d=>{d.addEventListener("click",()=>{d.closest(".flex-controls-group")?.querySelectorAll(".flex-control-btn").forEach(u=>u.classList.remove("active")),d.classList.add("active"),a(d.dataset.property,d.dataset.value),l()})});const c=t.querySelector(".flex-disable-check");c?.addEventListener("change",()=>{a("display",c.checked?o:"flex"),l()})})}initPositioningControls(e){e.querySelectorAll(".positioning-control").forEach(t=>{const s=t.querySelector(".positioning-unset-check"),r=t.querySelector('input[type="number"]');if(!s||!r)return;const i=r.dataset.customizationElement,o=r.getAttribute("data-customization-element-style");let a=t.querySelector(".positioning-unset-input");a||(a=document.createElement("input"),a.type="hidden",a.className="positioning-unset-input",a.value="unset",t.appendChild(a));const l=()=>{r.disabled=s.checked,a.disabled=!s.checked,a.name=s.checked?r.name:""};s.addEventListener("change",()=>{if(l(),!i||!o)return;const c=s.checked?"unset":r.value===""?"":r.value+"%";
1document.querySelectorAll(i).forEach(d=>{d.style[this._cssPropToCamel(o)]=c})}),l()})}initHeightAutoControls(e){e.querySelectorAll(".height-auto-control").forEach(t=>{const s=t.querySelector(".height-auto-check"),r=t.querySelector('input[type="number"]');if(!s||!r)return;const i=r.dataset.customizationElement,o=r.getAttribute("data-customization-element-style");let a=t.querySelector(".height-auto-input");a||(a=document.createElement("input"),a.type="hidden",a.className="height-auto-input",a.value="auto",t.appendChild(a));const l=()=>{r.disabled=s.checked,a.disabled=!s.checked,a.name=s.checked?r.name:""};s.addEventListener("change",()=>{if(l(),!i||!o)return;const c=s.checked?"auto":r.value===""?"":r.value+"px";document.querySelectorAll(i).forEach(d=>{d.style[this._cssPropToCamel(o)]=c})}),l()})}_cssPropToCamel(e){return e.replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}_initStylePanel(e){this.initShadowControls(e),this.initStyleInputs(e),this.initStyleSelects(e),this.initLinearGradientControls(e),this.initPaddingControls(e),this.initMarginControls(e),this.initBorderControls(e),this.initTransformControls(e),this.initClipPathControls(e),this.initBorderRadiusControls(e),this.initTextAlignControls(e),this.initFlexControls(e),this.initPositioningControls(e),this.initHeightAutoControls(e),this.initHoverStyleInputs(e),this.initTooltips(e)}startListeners(){this.eventManager.on("initStylePanel",()=>{const t=document.querySelector("#moduleEditStylePanel .homepage-edit-panel");t&&this._initStylePanel(t)}),this.eventManager.subscribe("click",".openOptionsBar",async t=>{t.preventDefault();const s=t.target.closest(".openOptionsBar");this.clearSideMenuContainers(),this.setTabStartState();const r=s.getAttribute("data-homepage-module-form-filename"),i=s.getAttribute("data-homepage-module-id"),a=s.getAttribute("data-module-context")==="post-detail"?"post-detail":"homepage",l=Habersoft.routes.ajax[`${a}.renderform.module`],c=Habersoft.routes.ajax[`${a}.renderform.modulestyle`],[d,u]=await Promise.allSettled([L.customFetch(l,{method:"POST",body:JSON.stringify({homepageModuleFormFilename:r,homepageModuleId:i})}).then(p=>p.json()),L.customFetch(c,{method:"POST",body:JSON.stringify({homepageModuleId:i})}).then(p=>p.json())]);if(d.status==="fulfilled"){const p=document.querySelector("#moduleEditPanel .homepage-edit-panel"),v=L.parseHTMLWithScripts(d.value);p.innerHTML=v.html,L.executeScripts(v.scripts)}else console.error("İçerik paneli yüklenemedi:",d.reason);if(u.status==="fulfilled"){const p=document.querySelector("#moduleEditStylePanel .homepage-edit-panel"),v=L.parseHTMLWithScripts(u.value);p.innerHTML=v.html,L.executeScripts(v.scripts),this._initStylePanel(p),this.eventManager.emit("stylePanelLoaded")}else console.error("Stil paneli yüklenemedi:",u.reason)}),this.eventManager.subscribe("click",".close-modal-shadow",t=>{t.preventDefault();const s=t.target.closest(".close-modal-shadow"),r=document.querySelector(".offcanvas-backdrop");if(!r)return;const i='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',o='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>';r.classList.contains("show")?(r.classList.remove("show"),s.innerHTML=i+" Arka Plan"):(r.classList.add("show"),s.innerHTML=o+" Arka Plan")});let e=!0;this.eventManager.subscribe("click",".move-offcanvas",t=>{const s=t.target.closest(".move-offcanvas"),r=document.getElementById("moduleSidebarCont");e?(r.classList.remove("offcanvas-end"),r.classList.add("offcanvas-start"),s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg> SaÄa Yasla'):(r.classList.remove("offcanvas-start"),r.classList.add("offcanvas-end"),s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg> Sola Yasla'),e=!e})}init(){this.startListeners()}}const Qe={success:1,pending:3,failed:3},ae={processing:"İÅleniyorâ¦",success:()=>"BaÅarıyla iÅlendi. Sayfa yenileniyorâ¦",pending:n=>`DeÄiÅiklikleriniz kaydedildi. Sitede görünmesi birkaç dakika sürebilir. Sayfa ${n} sn içinde yenileniyorâ¦`,failed:(n,e)=>`İÅlem baÅarısız${e?`: ${e}`:""}. Sayfa ${n} sn içinde yenileniyorâ¦`};class H{static async run({save:e,scope:t=null,button:s=null}){if(s?.disabled)return;s&&(s.disabled=!0);const r=ee.loading(ae.processing);let i,o="";try{const a=await e();i=a?.status?await this._compile(t):"failed",a?.status||(o=a?.message??"")}catch(a){console.error("Kayıt isteÄi baÅarısız:",a),i="failed"}ee.dismiss(r),this._countdownAndReload(i,o)}static bindScope(e,t){e?.querySelectorAll("form").forEach(s=>{s.dataset.cssScope=t})}static scopeOf(e){return e?.dataset.cssScope??Habersoft.cssScope??null}static async _compile(e){if(!e)return"success";try{return(await(await L.customFetch(Habersoft.adminRoutes["css.compile"],{method:"POST",headers:{Accept:"application/json"},body:JSON.stringify({scope:e})})).json())?.status?"success":"pending"}catch(t){return console.error("CSS derleme isteÄi baÅarısız:",t),"pending"}}static _countdownAndReload(e,t=""){const s=e==="success"?"success":e==="pending"?"warning":"error";let r=Qe[e];const o=ee[s](ae[e](r,t),{duration:0}).querySelector(".hn-text"),a=setInterval(()=>{if(r-=1,r>0){o.textContent=ae[e](r,t);return}clearInterval(a),location.reload()},1e3)}}class et{constructor(e={}){this.moduleSettingUrl=Habersoft.adminRoutes["partial.module-setting"],this.styleSettingUrl=Habersoft.adminRoutes["partial.style-setting"],this.settingsIcon=Habersoft.adminRoutes.settings_icon,this.partialDesign=e.partialDesign??null}injectSettingsButtons(){document.querySelectorAll(".partial").forEach(e
1=>{const t=e.querySelector(".setting-buttons");t&&(t.classList.add("position-relative"),t.insertAdjacentHTML("beforeend",` 2 <div class="position-absolute top-0 start-0 end-0 d-flex align-items-center justify-content-between z-3"> 3 <div class="d-flex flex-row align-items-center"> 4 <div class="bg-white p-1 rounded-3 shadow ms-1 c-pointer partial-module-options d-none position-relative" data-bs-toggle="offcanvas" data-bs-target="#moduleSidebarCont" data-type="module"> 5 <img loading="lazy" width="23" height="23" src="${this.settingsIcon}" alt="ayarlar"> 6 </div> 7 </div> 8 </div> 9 `))})}initLinearContainers(e){e.querySelectorAll(".linear-container").forEach(t=>{const s=t.dataset.styleValue||"";function r(m){const b=[];let _=0,A="";for(const E of m)E==="("?_++:E===")"&&_--,E===","&&_===1?(b.push(A.trim()),A=""):A+=E;return b.push(A.trim()),b}function i(m){const b=m.lastIndexOf(" ");return b===-1?[m,""]:[m.slice(0,b),m.slice(b+1)]}const o=m=>(m??"").replace(/[%)]/g,"").trim(),a=r(s),l=a[0]?.split("(")?.[1]?.trim()??"",c=l.includes("deg");let d,u,p,v;c?(d=l.replace("deg","").trim(),u=a[1]??"",p=a[2]??"",v=a[3]??""):(d="",u=l,p=a[1]??"",v=a[2]??"");const h=i(p),S=i(v),y={gradientDegree:d,transparentPercentValue:o(i(u)[1])||"0",color1Value:h[0]||"#ffffff",color1PercentValue:o(h[1])||"0",color2Value:S[0]||"#000000",color2PercentValue:o(S[1])||"100"},g=m=>{const{gradientDegree:b,transparentPercentValue:_,color1Value:A,color1PercentValue:E,color2Value:x,color2PercentValue:w}=y,k=`linear-gradient(${b?`${b}deg, `:""}transparent ${_}%, ${A} ${E}%, ${x} ${w}%)`,O=m.dataset.customizationElement,R=m.getAttribute("data-customization-element-style");document.querySelectorAll(O).forEach(V=>{V.style[R.replace(/-([a-z])/g,(ve,oe)=>oe.toUpperCase())]=k})},f={"color-percent":{key:"gradientDegree",isColor:!1},"color-transparent-percent":{key:"transparentPercentValue",isColor:!1},"colorVal-1":{key:"color1Value",isColor:!0},"color-1-intensity":{key:"color1PercentValue",isColor:!1},"colorVal-2":{key:"color2Value",isColor:!0},"color-2-intensity":{key:"color2PercentValue",isColor:!1}};t.querySelectorAll("input[data-style-target]").forEach(m=>{const b=f[m.dataset.styleTarget];if(!b)return;m.value=y[b.key],b.isColor&&(m.style.background=m.value);const _=()=>{if(y[b.key]=m.value,g(m),b.isColor){m.style.background=m.value;const A=m.value;if(A.startsWith("#")&&A.length===7){const E=parseInt(A.substr(1,2),16),x=parseInt(A.substr(3,2),16),w=parseInt(A.substr(5,2),16);m.style.color=(.299*E+.587*x+.114*w)/255>.5?"#000":"#fff"}}};m.addEventListener("input",_),b.isColor&&m.addEventListener("change",_)})})}initCustomPadding(e){e.querySelectorAll(".module-style-items .custom-padding-cont").forEach(t=>{const s=["top","right","bottom","left"],r=(t.dataset.paddingValues||"").split(" ");t.querySelectorAll("input").forEach(i=>{const o=s.indexOf(i.dataset.paddingWay);o!==-1&&(i.value=r[o]||"")}),t.querySelectorAll("input").forEach(i=>{i.addEventListener("change",()=>{const o=t.dataset.customizationElement,a=s.map(l=>(t.querySelector(`input[data-padding-way='${l}']`)?.value||"0")+"px").join(" ");document.querySelectorAll(o).forEach(l=>l.style.padding=a)})})})}openPartialPanel(e){document.querySelectorAll("#moduleEditPanel .homepage-edit-panel, #moduleEditStylePanel .homepage-edit-panel").forEach(s=>s.innerHTML=""),document.getElementById("modules-content-tab")?.classList.add("show","active"),document.getElementById("modules-styles-pane")?.classList.remove("show","active"),document.getElementById("modules-content-tab-opener")?.classList.add("active"),document.getElementById("modules-styles-pane-tab-opener")?.classList.remove("active"),[{panelId:"moduleEditPanel",url:this.moduleSettingUrl},{panelId:"moduleEditStylePanel",url:this.styleSettingUrl}].forEach(({panelId:s,url:r})=>{const i=new URL(r,window.location.origin);i.searchParams.set("partial_id",e),fetch(i).then(o=>o.text()).then(o=>{const a=document.querySelector(`#${s} .homepage-edit-panel`);
9if(a&&(a.innerHTML=o),s==="moduleEditStylePanel"){const l=document.getElementById("moduleEditStylePanel");if(!l)return;this.partialDesign?this.partialDesign._initStylePanel(l):(this.initLinearContainers(l),this.initCustomPadding(l)),window.Coloris?.refresh?.()}}).catch(o=>{o&&console.error(o)})})}saveModuleSetting(e){const t=new FormData(document.getElementById("partial-setting-form"));H.run({save:async()=>(await L.customFetch(this.moduleSettingUrl,{method:"POST",body:t})).json(),scope:"partials",button:e})}saveStyleSetting(e){if(e.disabled)return;const t=new FormData(e.closest("form"));document.querySelectorAll(".shadow-control").forEach(l=>{t.append(l.dataset.elName,l.checked?"1px 1px 1px #000":"none")}),document.querySelectorAll("#moduleEditStylePanel .border-radius-control input[type='range']").forEach(l=>{l.name&&l.value&&t.set(l.name,l.value+"%")});const s={};let r="",i=!1;const o=[],a=l=>!o.some(c=>l===c.elementName);document.querySelectorAll(".module-style-items .linear-container input").forEach(l=>{switch(l.dataset.styleTarget){case"color-percent":s.gradientDegree=l.value,r=l.dataset.elementName,i=!1;break;case"color-transparent-percent":s.transparentPercentValue=l.value,r=l.dataset.elementName;break;case"colorVal-1":s.color1Value=l.value,r=l.dataset.elementName;break;case"color-1-intensity":s.color1PercentValue=l.value,r=l.dataset.elementName;break;case"colorVal-2":s.color2Value=l.value,r=l.dataset.elementName;break;case"color-2-intensity":s.color2PercentValue=l.value,r=l.dataset.elementName,i=!0;break}if(Object.keys(s).length===6&&a(r)&&i){const c=s.gradientDegree?`${s.gradientDegree}deg, `:"";o.push({elementName:r,elementValue:`linear-gradient(${c}transparent ${s.transparentPercentValue}%, ${s.color1Value} ${s.color1PercentValue}%, ${s.color2Value} ${s.color2PercentValue}%)`})}}),o.length>0&&o.forEach(l=>{l.elementName&&t.append(l.elementName,l.elementValue)}),document.querySelectorAll(".module-style-items .custom-padding-cont").forEach(l=>{const c=l.dataset.name;let d=":top :right :bottom :left";l.querySelectorAll("input").forEach(u=>{const p=u.dataset.paddingWay;p&&(d=d.replace(":"+p,u.value+"px"))}),d.includes(":")||t.append(c,d)}),H.run({save:async()=>(await L.customFetch(this.styleSettingUrl,{method:"POST",body:t})).json(),scope:"partials",button:e})}startListeners(){document.addEventListener("click",e=>{const t=e.target.closest(".partial-module-options");if(t){const i=t.closest(".partial")?.dataset.partialId;i&&this.openPartialPanel(i);return}const s=e.target.closest(".partial-setting-save");if(s){e.preventDefault(),this.saveModuleSetting(s);return}const r=e.target.closest(".partial-style-save");r&&(e.preventDefault(),this.saveStyleSetting(r))})}init(){this.injectSettingsButtons(),this.startListeners()}}class tt{constructor(){this.rendermoduleUrl=Habersoft.adminRoutes["sidebars.rendermodule"],this.renderFormUrl=Habersoft.adminRoutes["sidebars.render_form_module"],this.renderStyleFormUrl=Habersoft.adminRoutes["sidebars.render_style_form"],this.csrfToken=document.querySelector('meta[name="csrf-token"]')?.content}_emptyEditPanels(){document.querySelectorAll("#moduleEditPanel .homepage-edit-panel, #moduleEditStylePanel .homepage-edit-panel").forEach(e=>e.innerHTML="")}startListeners(){document.addEventListener("click",e=>{const t=e.target.closest(".sidebar-modules-list-item");if(t){const{sidebarModuleId:r,sidebarModuleFormFilename:i,sidebarModuleName:o,sidebarId:a,sidebarPostId:l}=t.dataset,c=t.dataset.sidebarModuleTime+Math.floor(Math.random()*1e5);fetch(this.rendermoduleUrl,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":this.csrfToken},body:JSON.stringify({sidebarModuleId:r,sidebarModuleName:o,sidebarModuleTime:c,sidebarModuleFormFilename:i,sidebarId:a,sidebarPostId:l})}).then(d=>d.text()).then(d=>{bootstrap.Modal.getInstance(document.getElementById("sidebar-modules-modal"))?.hide();const u=document.querySelector(".sticky-side-content .sidebar-module-add");u&&u.insertAdjacentHTML("beforebegin",` 10 <div class="col-12 sidebar-sort-item position-relative sorting" data-sidebar-module-id="${r}" data-sidebar-module-time="${c}"> 11 <div class="module-settings-container position-absolute top-0 start-0 end-0 bottom-0 d-flex flex-row align-items-center justify-content-center"> 12 <div class="sidebar-module-edit z-2 ms-2 mt-2 c-pointer" data-bs-toggle="offcanvas" data-bs-target="#moduleSidebarCont" data-sidebar-post-id="${l}" data-sidebar-module-form-filename="${i}" data-sidebar-module-id="${r}" data-sidebar-module-time="${c}"> 13 <svg width="35px" height="35px" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#ffffff"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill="#ffffff" d="m80.16 29.054-5.958-.709 5.958.71Zm31.68 0-5.958.71 5.958-.71Zm34.217 19.7
1356-2.365-5.515 2.365 5.514Zm10.081 3.352 5.196-3-5.196 3Zm7.896 13.676 5.196-3-5.196 3Zm-2.137 10.407-3.594-4.805 3.594 4.805Zm0 39.51 3.593-4.805-3.593 4.805Zm2.137 10.407 5.196 3-5.196-3Zm-7.896 13.676-5.196-3 5.196 3Zm-10.081 3.353 2.364-5.515-2.364 5.515Zm-34.217 19.755 5.958.709-5.958-.709Zm-31.68 0-5.958.709 5.958-.709Zm-34.217-19.755-2.364-5.515 2.364 5.515Zm-10.08-3.353-5.197 3 5.196-3Zm-7.897-13.676 5.196-3-5.196 3Zm2.137-10.407 3.594 4.805-3.594-4.805Zm0-39.51L26.51 81.05l3.593-4.805Zm-2.137-10.407 5.196 3-5.196-3Zm7.896-13.676-5.196-3 5.196 3Zm10.081-3.352-2.364 5.514 2.364-5.514Zm7.85 3.365-2.365 5.515 2.364-5.515Zm0 87.65 2.364 5.514-2.365-5.514ZM36.235 111.17l-3.594-4.805 3.594 4.805Zm76.823 41.535 5.958.71-5.958-.71Zm39.854-69.742-3.593-4.805 3.593 4.805Zm-16.369-30.074 2.364 5.514-2.364-5.514Zm-23.485-13.594-5.958.709 5.958-.71ZM88.104 16a14 14 0 0 0-13.902 12.345l11.916 1.419A2 2 0 0 1 88.104 28V16Zm15.792 0H88.104v12h15.792V16Zm13.902 12.345A14 14 0 0 0 103.896 16v12a2 2 0 0 1 1.986 1.764l11.916-1.419Zm1.219 10.24-1.219-10.24-11.916 1.419 1.219 10.24 11.916-1.419Zm24.675 4.71-9.513 4.08 4.729 11.028 9.513-4.08-4.729-11.028Zm17.642 5.867a14 14 0 0 0-17.642-5.867l4.729 11.029a2 2 0 0 1 2.521.838l10.392-6Zm7.896 13.676-7.896-13.676-10.392 6 7.896 13.676 10.392-6Zm-3.74 18.212a14 14 0 0 0 3.74-18.212l-10.392 6a2 2 0 0 1-.535 2.602l7.187 9.61Zm-8.984 6.718 8.984-6.718-7.187-9.61-8.983 6.718 7.186 9.61Zm8.984 23.182-8.984-6.718-7.186 9.61 8.983 6.718 7.187-9.61Zm3.74 18.212a14 14 0 0 0-3.74-18.212l-7.187 9.61a2 2 0 0 1 .535 2.602l10.392 6Zm-7.896 13.676 7.896-13.676-10.392-6-7.896 13.676 10.392 6Zm-17.642 5.867a14 14 0 0 0 17.642-5.867l-10.392-6a2.001 2.001 0 0 1-2.521.838l-4.729 11.029Zm-9.513-4.08 9.513 4.08 4.729-11.029-9.512-4.079-4.73 11.028Zm-16.381 19.03 1.219-10.24-11.916-1.419-1.219 10.24 11.916 1.419ZM103.896 176a14 14 0 0 0 13.902-12.345l-11.916-1.419a2 2 0 0 1-1.986 1.764v12Zm-15.792 0h15.792v-12H88.104v12Zm-13.902-12.345A14 14 0 0 0 88.104 176v-12a2 2 0 0 1-1.986-1.764l-11.916 1.419Zm-1.012-8.504 1.012 8.504 11.916-1.419-1.
13012-8.504-11.916 1.419ZM51.428 134.31l-7.85 3.366 4.73 11.029 7.849-3.366-4.73-11.029Zm-7.85 3.366a2 2 0 0 1-2.52-.838l-10.392 6a14 14 0 0 0 17.642 5.867l-4.73-11.029Zm-2.52-.838-7.896-13.676-10.392 6 7.896 13.676 10.392-6Zm-7.896-13.676a2 2 0 0 1 .535-2.602l-7.187-9.61a14 14 0 0 0-3.74 18.212l10.392-6Zm.535-2.602 6.132-4.585-7.187-9.61-6.132 4.585 7.187 9.61ZM26.51 81.05l6.132 4.586 7.187-9.61-6.132-4.586-7.187 9.61Zm-3.74-18.212a14 14 0 0 0 3.74 18.212l7.187-9.61a2 2 0 0 1-.535-2.602l-10.392-6Zm7.896-13.676L22.77 62.838l10.392 6 7.896-13.676-10.392-6Zm17.642-5.867a14 14 0 0 0-17.642 5.867l10.392 6a2 2 0 0 1 2.52-.838l4.73-11.029Zm7.849 3.366-7.85-3.366-4.729 11.029 7.85 3.366 4.729-11.029Zm18.045-18.316-1.012 8.504 11.916 1.419 1.012-8.504-11.916-1.419Zm-1.754 27.552c6.078-3.426 11.69-9.502 12.658-17.63L73.19 36.85c-.382 3.209-2.769 6.415-6.635 8.595l5.893 10.453Zm-21.02 1.793c7.284 3.124 15.055 1.57 21.02-1.793l-5.893-10.453c-3.704 2.088-7.481 2.468-10.398 1.217l-4.73 11.029ZM49 96c0-7.1-2.548-15.022-9.171-19.975l-7.187 9.61C35.36 87.668 37 91.438 37 96h12Zm23.448 40.103c-5.965-3.363-13.736-4.917-21.02-1.793l4.729 11.029c2.917-1.251 6.694-.871 10.398 1.218l5.893-10.454Zm-32.62-20.128C46.452 111.022 49 103.1 49 96H37c0 4.563-1.64 8.333-4.358 10.365l7.187 9.61Zm78.679 19.575c-5.536 3.298-10.517 8.982-11.406 16.446l11.916 1.419c.329-2.765 2.318-5.582 5.632-7.557l-6.142-10.308Zm20.402-1.953c-7.094-3.042-14.669-1.463-20.402 1.953l6.142 10.308c3.382-2.015 6.872-2.372 9.53-1.233l4.73-11.028Zm-53.803 20.135c-.968-8.127-6.58-14.202-12.658-17.629l-5.893 10.454c3.866 2.179 6.253 5.385 6.635 8.594l11.916-1.419ZM141 96c0 6.389 2.398 13.414 8.32 17.842l7.186-9.61C154.374 102.638 153 99.668 153 96h-12Zm8.32-17.842C143.398 82.586 141 89.61 141 96h12c0-3.668 1.374-6.638 3.506-8.232l-7.186-9.61ZM118.507 56.45c5.733 3.416 13.308 4.995 20.401 1.953l-4.729-11.029c-2.658 1.14-6.148.782-9.53-1.233l-6.142 10.31Zm-11.406-16.446c.889 7.464 5.87 13.148 11.406 16.446l6.142-10.309c-3.314-1.974-5.303-4.79-5.632-7.556l-11.916 1.419Z"></path><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="12" d="M96 120c13.255 0 24-10.745 24-24s-10.745-24-24-24-24 10.745-24 24 10.745 24 24 24Z"></path></g></svg> 14 </div> 15 <div class="sidebar-module-off z-2 ms-2 mt-2 c-pointer"> 16 <svg width="35px" height="35px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#ffffff"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill="#ffffff" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"></path></g></svg> 17 </div> 18 </div> 19 ${d} 20 </div> 21 `)}).catch(d=>console.error(d));return}const s=e.target.closest(".sidebar-module-edit");if(s){const{sidebarModuleFormFilename:r,sidebarModuleId:i,sidebarModuleTime:o,sidebarModelType:a,sidebarPostId:l}=s.dataset;this._emptyEditPanels(),fetch(this.renderFormUrl,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":this.csrfToken},body:JSON.stringify({sidebarModuleFormFilename:r,sidebarModuleId:i,sidebarModuleTime:o,sidebarModelType:a,sidebarPostId:l})}).then(c=>c.json()).then(c=>{const d=document.querySelector("#moduleEditPanel .homepage-edit-panel");d&&(d.innerHTML=c.status?c.html:""),H.bindScope(d,"sides")}).catch(c=>{const d=document.querySelector("#moduleEditPanel .homepage-edit-panel");d&&(d.innerHTML='<div class="text-danger fw-semibold fs-24 p-3">MODÃL AYARI BULUNAMADI!</div>'),console.error(c)}),this.renderStyleFormUrl&&fetch(this.renderStyleFormUrl,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":this.csrfToken},body:JSON.stringify({sidebarModuleTime:o})}).then(c=>c.json()).then(c=>{const d=document.querySelector("#moduleEditStylePanel .homepage-edit-panel");d&&(c.status?(d.innerHTML=c.html,H.bindScope(d,"sides"),window.eventManager?.emit("initStylePanel")):d.innerHTML="")}).catch(c=>console.error("Stil formu yüklenemedi:",c))}})}init(){this.startListeners()}}class st{constructor({eventManager:e}){this.eventManager=e,this.isActive=!1,this.styleEl=this._createStyleElement()}_createStyleElement(){const e=document.createElement("style");return e.id="module-highlighter-styles",document.head.appendChild(e),e}_getTargetsFromPanel(e){if(!e)return[];const t=new Set;return e.querySelectorAll("[data-customization-element]").forEach(s=>{const r=s.dataset.customizationElement;r&&t.add(r)}),[...t]}_applyHighlights(e=null){const t=e??document.querySelector("#moduleEditStylePanel .accordion-collapse.show"),s=this._getTargetsFromPanel(t);if(!this.isActive||s.length===0){this._removeHighlights();return}const r=` 22 @keyframes hs-highlighter-pulse { 23 0% { outline-color: rgba(99, 102, 241, 0.9); } 24 50% { outline-color: rgba(167, 139, 250, 0.4); } 25 100% { outline-color: rgba(99, 102, 241, 0.9); } 26 } 27 `,i=s.map(o=>` 28 ${o} { 29 outline: 2px solid rgba(99, 102, 241, 0.9) !important; 30 outline-offset: -2px !important; 31 animation: hs-highlighter-pulse 1.6s ease-in-out infinite !important; 32 } 33 `).join(` 34`);this.styleEl.textContent=r+i}_removeHighlights(){this.styleEl.textContent=""}init(){this.eventManager.on("stylePanelLoaded",()=>{const e=document.querySelector(".outline-trigger");this.isActive=e?.classList.contains("outline-active")??!1,this.isActive?this._applyHighlights():this._removeHighlights()}),this.eventManager.subscribe("click",".outline-trigger",e=>{requestAnimationFrame(()=>{const t=e.target.closest(".outline-trigger");this.isActive=t?.classList.contains("outline-active")??!1,this.isActive?this._applyHighlights():this._removeHighlights()})}),document.addEventListener("shown.bs.collapse",e=>{this.isActive&&e.target.closest("#moduleEditStylePanel")&&this._applyHighlights(e.target)}),document.addEventListener("hidden.bs.collapse",e=>{if(!this.isActive||!e.target.closest("#moduleEditStylePanel"))return;const t=document.querySelector("#moduleEditStylePanel .accordion-collapse.show");t?this._applyHighlights(t):this._removeHighlights()}),document.addEventListener("show.bs.offcanvas",()=>{this.isActive=!1,this._removeHighlights()})}}class nt{constructor({eventManager:e}){this.eventManager=e,this.startListeners()}startListeners(){this.eventManager.subscribe("click",".moduleupdate",async e=>{e.preventDefault();const t=e.target.closest("form"),s=t.action,r=t.method,i=new FormData(t);await H.run({save:async()=>(await L.customFetch(s,{method:r,body:i})).json(),scope:H.scopeOf(t),button:e.target.closest(".moduleupdate")})})}}class De{parse(){const e={};let t="",s=!1;const r=[],i=a=>!r.some(l=>l.elementName===a);return document.querySelectorAll(".module-style-items .linear-container input").forEach(a=>{const l=a.dataset.styleTarget,c=a.dataset.elementName;switch(l){case"color-percent":e.gradientDegree=a.value,t=c,s=!1;break;case"color-transparent-percent":e.transparentPercentValue=a.value,t=c;break;case"colorVal-1":e.color1Value=a.value,t=c;break;case"color-1-intensity":e.color1PercentValue=a.value,t=c;break;case"colorVal-2":e.color2Value=a.value,t=c;break;case"color-2-intensity":e.color2PercentValue=a.value,t=c,s=!0;break}Object.keys(e).length===6&&i(t)&&s&&r.push({elementName:t,elementValue:`linear-gradient(${e.gradientDegree}deg, transparent ${e.transparentPercentValue}%, ${e.color1Value} ${e.color1PercentValue}%, ${e.color2Value} ${e.color2PercentValue}%)`})}),r}}class Be{parse(e){document.querySelectorAll(".shadow-control").forEach(s=>{const r=s.dataset.elName;e.append(r,s.checked?"1px 1px 1px #000":"none")})}}class Re{parse(e){document.querySelectorAll(".module-style-items .custom-padding-cont").forEach(s=>{const r=s.dataset.name;let i=":top :right :bottom :left";s.querySelectorAll("input").forEach(o=>{switch(o.dataset.paddingWay){case"top":i=i.replace(":top",`${o.value}px`);break;case"right":i=i.replace(":right",`${o.value}px`);break;case"bottom":i=i.replace(":bottom",`${o.value}px`);break;case"left":i=i.replace(":left",`${o.value}px`);break}i.includes(":")||e.append(r,i)})})}}class Ve{parse(e){document.querySelectorAll(".module-style-items .custom-margin-cont").forEach(s=>{const r=s.dataset.name;let i=":top :right :bottom :left";s.querySelectorAll("input").forEach(o=>{switch(o.dataset.marginWay){case"top":i=i.replace(":top",`${o.value}px`);break;case"right":i=i.replace(":right",`${o.value}px`);break;case"bottom":i=i.replace(":bottom",`${o.value}px`);break;case"left":i=i.replace(":left",`${o.value}px`);break}i.includes(":")||e.append(r,i)})})}}class Ne{parse(e){document.querySelectorAll(".module-style-items .custom-border-cont").forEach(s=>{const r=s.dataset.name,i=s.querySelector('[data-border-part="width"]'),o=s.querySelector('[data-border-part="style"]'),a=s.querySelector('[data-border-part="color"]'),l=i?.value??"1",c=o?.value??"solid",d=a?.value??"#000000";e.append(r,`${l}px ${c} ${d}`)})}}class rt{constructor({eventManager:e}){this.eventManager=e,this.linearGradientParser=new De,this.shadowParser=new Be,this.paddingParser=new Re,this.marginParser=new Ve,this.borderParser=new Ne,this.startListeners()}startListeners(){this.eventManager.subscribe("click",".module-style-save",async e=>{e.preventDefault();const t=e.target.closest("form"),s=t.action,r=t.method,i=[];t.querySelectorAll(".unit-toggle-cont").forEach(l=>{l.querySelector(".unit-percent-toggle")?.checked&&l.querySelectorAll("input[data-customization-element-style]").forEach(d=>{i.push({input:d,value:d.value}),d.value=d.value+"%"})});const o=new FormData(t);
34i.forEach(({input:l,value:c})=>{l.value=c}),this.linearGradientParser.parse().forEach(l=>{l.elementName&&o.append(l.elementName,l.elementValue)}),this.shadowParser.parse(o),this.paddingParser.parse(o),this.marginParser.parse(o),this.borderParser.parse(o),await H.run({save:async()=>(await L.customFetch(s,{method:r,body:o})).json(),scope:H.scopeOf(t),button:e.target.closest(".module-style-save")})})}}class it{constructor({eventManager:e}){this.eventManager=e,this.moduleUpdate=new nt({eventManager:this.eventManager}),this.moduleStyleUpdate=new rt({eventManager:this.eventManager})}}class B{#r=!1;#e;#i;#a;#n=null;#s=null;#t={};static#o=new WeakMap;constructor(e,{items:t,placeholder:s="sortable-placeholder"}={}){this.#e=typeof e=="string"?document.querySelector(e):e,this.#i=t,this.#a=s,this.#e&&this.#c()}#c(){this.#t.dragstart=e=>this.#d(e),this.#t.dragover=e=>this.#u(e),this.#t.dragend=e=>this.#p(e),this.#t.drop=e=>e.preventDefault(),this.#e.addEventListener("dragstart",this.#t.dragstart),this.#e.addEventListener("dragover",this.#t.dragover),this.#e.addEventListener("dragend",this.#t.dragend),this.#e.addEventListener("drop",this.#t.drop)}destroy(){this.#e.removeEventListener("dragstart",this.#t.dragstart),this.#e.removeEventListener("dragover",this.#t.dragover),this.#e.removeEventListener("dragend",this.#t.dragend),this.#e.removeEventListener("drop",this.#t.drop),this.disable(),B.#o.delete(this.#e)}static init(e,t={}){const s=typeof e=="string"?document.querySelector(e):e;if(!s)return null;B.#o.has(s)&&B.#o.get(s).destroy();const r=new B(s,t);return r.enable(),B.#o.set(s,r),r}#l(e){return e?.closest(this.#i)}#d(e){if(!this.#r)return;const t=this.#l(e.target);t&&(this.#n=t,requestAnimationFrame(()=>t.classList.add("sortable-dragging")),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(new Image,0,0),this.#s=document.createElement("div"),this.#s.className=this.#a,this.#s.style.cssText="height:10px;background:#3b82f6;border-radius:4px;opacity:0.7;margin:2px 0;transition:opacity .15s;")}#u(e){if(!this.#r||!this.#n)return;e.preventDefault(),e.dataTransfer.dropEffect="move";const t=this.#l(e.target);if(!t||t===this.#n||t===this.#s)return;const s=t.getBoundingClientRect().top+t.offsetHeight/2;this.#e.insertBefore(this.#s,e.clientY<s?t:t.nextSibling)}#p(){this.#n&&(this.#n.classList.remove("sortable-dragging"),this.#s?.parentNode&&(this.#e.insertBefore(this.#n,this.#s),this.#s.remove()),this.#n=null,this.#s=null)}enable(){this.#r=!0,this.#e?.querySelectorAll(this.#i).forEach(e=>{e.draggable=!0})}disable(){this.#r=!1,this.#e?.querySelectorAll(this.#i).forEach(e=>{e.draggable=!1})}isDisabled(){return!this.#r}}class ot{constructor(){this._adminSortActive=!1,this._adminSortEnabled=!1,this._postDetailLayoutSortEnabled=!1,this._adminThemeOptionsActive=!1,this._originalOrder=[],this._sortables={}}_injectSettingButtons(){Habersoft?.adminRoutes?.settings_icon,document.querySelectorAll(".layout, .post-detail-layout").forEach(e=>{const t=e.querySelector(".setting-buttons");if(!t)return;t.classList.add("position-relative");const s=e.classList.contains("post-detail-layout"),r=s?"#postDetailLayoutEditModal":"#layoutEditModal",i=s?"post-detail.layout.edit_render":"layout.edit_render",o=s?"post-detail.layout.clone":"layout.clone",a=s?"post-detail.layout.moduleclose":"layout.moduleclose";t.insertAdjacentHTML("beforeend",` 35 <div class="position-absolute pe-none top-0 start-0 end-0 bottom-0 d-flex align-items-center justify-content-between z-3"> 36 <div class="d-flex flex-row align-items-center pe-auto"> 37 <div class="bg-white p-1 rounded-3 shadow ms-1 c-pointer element-theme-options-container position-relative d-none d-flex align-items-center justify-content-center" 38 data-bs-toggle="modal" data-bs-target="${r}" data-route-key="${i}" data-type="module" title="Katman Düzeni" style="width:35px;height:35px;"> 39 <i class="fa fa-cogs fs-20" aria-hidden="true"></i> 40 </div> 41 <div class="bg-white p-1 rounded-3 shadow ms-1 c-pointer clone-layout-btn d-none" data-route-key="${o}" title="Katmanı Klonla"> 42 <i class="fa fa-clone p-1" style="font-size:19px;vertical-align:middle;" aria-hidden="true"></i> 43 </div> 44 <div class="bg-white border rounded shadow d-flex flex-row pe-auto justify-content-center align-items-center module-activity-container px-1 ms-1 d-none" title="Katmanı Sil"> 45 <button class="btn bg-white p-1 border-0 bg-transparent fs-16 module-activity z-5" data-route-key="${a}">
46 <i class="fa fa-trash" aria-hidden="true"></i> 47 </button> 48 </div> 49 </div> 50 </div> 51 `)})}async _saveDetailSort(){const e=Habersoft?.adminRoutes;if(!e)return;const t=Array.from(document.querySelectorAll(".detail-sort-container")[0]?.querySelectorAll(".detail-sort-item")||[]).map(a=>({id:a.dataset.detailModuleId,module_time:a.dataset.detailModuleTime})),s=Array.from(document.querySelectorAll(".sticky-side-content")[0]?.querySelectorAll(".sidebar-sort-item")||[]).map(a=>({id:a.dataset.sidebarModuleId,module_time:a.dataset.sidebarModuleTime})),r=document.querySelector(".detail-sort-container")?.dataset.detailsideId,i=document.querySelector(".sticky-side-content")?.closest(".sticky-side-container")?.dataset.sidebarId;if(e.show_detailside_update){const a=new FormData;a.append("modules",JSON.stringify(t)),a.append("detailside_id",r),L.customFetch(e["detailsides.update"],{method:"POST",body:a}).then(l=>l.json()).then(l=>console.log("Detail Update:",l)).catch(l=>console.error("Detail Update Error:",l))}const o=new FormData;o.append("modules",JSON.stringify(s)),o.append("sidebar_id",i),L.customFetch(e["sidebars.update"],{method:"POST",body:o}).then(a=>a.json()).then(a=>console.log("Sidebar Update:",a)).catch(a=>console.error("Sidebar Update Error:",a))}_applyLayoutData(){const e=Habersoft?.adminLayouts||[],t=document.querySelectorAll(".admin-sort-item");let s=0;e.forEach(r=>{r.id&&t[s]&&(t[s].setAttribute("data-sort-id",r.id),t[s].setAttribute("data-module-id",r.id),t[s].setAttribute("data-module-title",r.title),s++)})}_initSortable(){const e={placeholder:"sortable-placeholder"};this._sortables.detailSort=new B(".detail-sort-container",{...e,items:".detail-sort-item"}),this._sortables.sideSort=new B(".sticky-side-content",{...e,items:".sidebar-sort-item"})}_initPointerSort(e,t,s){if(!e)return;let r=null,i=null,o=0;const a=.05,l=.1,c=40,d=12,u=1.2,p=()=>{const g=[];for(const f of e.querySelectorAll(t)){if(f===r.item)continue;const m=f.getBoundingClientRect();g.push({el:f,mid:m.top+m.height/2})}return g},v=()=>{const g=r.lastY;let f=r.rects.length;for(let m=0;m<r.rects.length;m++)if(g<r.rects[m].mid){f=m;break}f!==r.placeholderIdx&&(f>=r.rects.length?r.rects.at(-1)?.el.after(r.placeholder):r.rects[f].el.before(r.placeholder),r.placeholderIdx=f,r.rects=p())},h=()=>{if(!r){i=null;return}const g=window.innerHeight,f=r.lastY,m=g*a,b=g*l;let _=0,A=0;if(f<m?(_=-1,A=c):f<b?(_=-1,A=d):f>g-m?(_=1,A=c):f>g-b&&(_=1,A=d),_!==0){o=Math.min(o+u,A);const E=window.scrollY;window.scrollBy(0,_*Math.ceil(o)),window.scrollY!==E&&(r.rects=p(),v())}else o=0;i=requestAnimationFrame(h)},S=()=>{r&&(r.rafPending=!1,r.clone.style.transform=`translate3d(${r.lastX-r.startX}px, ${r.lastY-r.startY}px, 0)`,r.rects=p(),v())};e.addEventListener("pointerdown",g=>{if(!s()||g.button!==0)return;const f=g.target.closest(t);if(!f)return;g.preventDefault();const m=f.getBoundingClientRect(),b=document.createElement("div");b.className="admin-sort-placeholder",b.style.height="20px";const _=f.cloneNode(!0);_.classList.add("sort-clone"),_.style.position="fixed",_.style.left=`${m.left}px`,_.style.top=`${m.top}px`,_.style.width=`${m.width}px`,_.style.margin="0",_.style.zIndex="99999",_.style.pointerEvents="none",_.style.opacity="0.85",_.style.willChange="transform",document.body.appendChild(_),f.after(b),f.style.display="none",f.classList.add("sort-active"),r={item:f,placeholder:b,clone:_,pointerId:g.pointerId,startX:g.clientX,startY:g.clientY,lastX:g.clientX,lastY:g.clientY,rects:[],placeholderIdx:-1,rafPending:!1},document.body.style.userSelect="none",e.offsetHeight,r.rects=p();const A=b.nextElementSibling;r.placeholderIdx=A?r.rects.findIndex(E=>E.el===A):r.rects.length,o=0,i=requestAnimationFrame(h);try{e.setPointerCapture(g.pointerId)}catch{}}),e.addEventListener("pointermove",g=>{r&&(g.preventDefault(),r.lastX=g.clientX,r.lastY=g.clientY,!r.rafPending&&(r.rafPending=!0,requestAnimationFrame(S)))});const y=()=>{if(!r)return;try{e.releasePointerCapture(r.pointerId)}catch{}cancelAnimationFrame(i),i=null,o=0;const{item:g,placeholder:f,clone:m}=r;m.remove(),g.style.display="",g.classList.remove("sort-active"),f.replaceWith(g),document.body.style.userSelect="",r=null};e.addEventListener("pointerup",y),e.addEventListener("pointercancel",
51y)}_initAdminMouseSort(){const e=document.querySelector(".admin-sort");this._initPointerSort(e,".admin-sort-item",()=>this._adminSortEnabled)}_initPostDetailLayoutSort(){const e=document.querySelector(".post-detail-layouts-sortable");this._initPointerSort(e,".post-detail-layout",()=>this._postDetailLayoutSortEnabled)}async _savePostDetailLayoutSort(){const e=Habersoft?.adminRoutes?.["post-detail.layoutsort"];if(!e){console.error("[layout-sort] post-detail.layoutsort tanımsız");return}const s=[...document.querySelectorAll(".post-detail-layouts-sortable > .post-detail-layout")].map((r,i)=>{const o=r.dataset.layoutId;if(!o)return null;const a=new FormData;return a.append("itemID",o),a.append("itemIndex",i),L.customFetch(e,{method:"POST",body:a}).then(l=>l.json()).then(l=>({itemID:o,index:i,ok:l.success!==!1})).catch(l=>({itemID:o,index:i,ok:!1,error:l}))}).filter(Boolean);Promise.all(s).then(r=>{const i=r.filter(o=>!o.ok);i.length===0?window.NotificationManager?.success?.(`Haber detay katman sırası kaydedildi (${r.length} katman)`):window.NotificationManager?.error?.(`${i.length} katman kaydedilemedi`)})}_bindEvents(){document.addEventListener("click",e=>{e.target.closest(".sidebar-module-off")&&e.target.closest(".sidebar-sort-item, .detail-sort-item")?.remove()}),document.addEventListener("click",e=>{const t=e.target.closest(".element-theme-options-container");if(!t)return;const s=t.dataset.bsTarget||"#layoutEditModal",r=t.dataset.routeKey||"layout.edit_render",i=document.querySelector(`${s} .layout-edit-modal, ${s} .post-detail-layout-edit-modal`);if(!i)return;i.innerHTML="";const o=t.closest("section, .post-detail-layout")?.getAttribute("data-layout-id"),a=Habersoft?.adminRoutes?.[r];if(!o||!a)return;const l=new FormData;l.append("layoutid",o),L.customFetch(a,{method:"POST",body:l}).then(c=>c.json()).then(c=>{const{html:d,scripts:u}=L.parseHTMLWithScripts(c);i.innerHTML=d,i.querySelectorAll(".layout-item .layout-module-list").forEach(p=>{window.VanillaSortable?.init(p,{items:".module-item"})}),L.executeScripts(u)}).catch(c=>console.error(c))}),document.addEventListener("click",e=>{const t=e.target.closest(".module-activity");if(!t||!confirm("Katmanı silmek istediÄinizden emin misiniz?"))return;const s=t.closest("section.layout, .post-detail-layout"),r=s?.getAttribute("data-layout-id"),i=t.dataset.routeKey||"layout.moduleclose",o=Habersoft?.adminRoutes?.[i];if(!r||!o){console.error("Katman silme: layoutid veya route bulunamadı",{layoutid:r,route:o,routeKey:i}),window.NotificationManager?.error("Katman bilgisi bulunamadı, silinemedi.");return}const a=window.NotificationManager,l=a?.loading?.("Katman siliniyor..."),c=new FormData;c.append("moduleid",r),L.customFetch(o,{method:"POST",body:c}).then(d=>d.json()).then(d=>{a?.dismiss?.(l),d.success?(a?.success("Katman silindi."),s?.remove()):a?.error(d.message||"Katman silinemedi.")}).catch(d=>{console.error("Katman silme hatası:",d),a?.dismiss?.(l),a?.error("BaÄlantı hatası, katman silinemedi.")})}),document.addEventListener("click",e=>{const t=e.target.closest(".clone-layout-btn");if(!t)return;e.preventDefault(),e.stopPropagation();const s=t.closest("section, .post-detail-layout")?.getAttribute("data-layout-id"),r=t.dataset.routeKey||"layout.clone",i=Habersoft?.adminRoutes?.[r];if(!s||!i){alert("Klonlanacak katman kimliÄi bulunamadı.");return}if(!confirm(`Bu katmanı klonlamak istediÄinizden emin misiniz? 52Katman, hemen altına bir kopya olarak eklenecektir.`))return;t.disabled=!0,t.innerHTML='<i class="fa fa-spinner fa-spin p-1" style="font-size:19px;vertical-align:middle;"></i>';const o=Habersoft?.meta?.route??"",a=i.replace("__LAYOUT_ID__",s).replace("__ROUTE__",o);L.customFetch(a,{method:"POST",headers:{Accept:"application/json"}}).then(l=>l.json()).then(l=>{l.status?(alert(l.message||"Katman baÅarıyla klonlandı."),location.reload()):(alert(l.message||"Bilinmeyen bir hata oluÅtu."),t.disabled=!1,t.innerHTML='<i class="fa fa-clone p-1" style="font-size:19px;vertical-align:middle;" aria-hidden="true"></i>')}).catch(l=>{alert(l?.message||"Sunucuyla iletiÅim kurulamadı."),t.disabled=!1,t.innerHTML='<i class="fa fa-clone p-1" style="font-size:19px;vertical-align:middle;" aria-hidden="true"></i>'})}),document.querySelectorAll(".element-styling-container").forEach(e
52=>{e.addEventListener("click",t=>t.stopPropagation())}),document.querySelector(".detailpage-sort-activate")?.addEventListener("click",()=>{const e=document.querySelectorAll(".detail-sort-container")[0],t=document.querySelectorAll(".sticky-side-content")[0],s=document.querySelector(".post-detail-layouts-sortable"),r=".layout-module-item, .detail-sort-item, .sidebar-sort-item";this._adminSortActive?(e?.querySelectorAll(r).forEach(i=>i.classList.remove("sorting")),t?.querySelectorAll(r).forEach(i=>i.classList.remove("sorting")),this._sortables.detailSort?.disable(),this._sortables.sideSort?.disable(),s&&(this._postDetailLayoutSortEnabled=!1,s.querySelectorAll(".post-detail-layout").forEach(i=>i.classList.remove("sorting")),this._savePostDetailLayoutSort()),this._setStatusText(".admin-sort-status","Sıralamayı Düzenle","text-warning-emphasis","text-success"),document.querySelectorAll(".sort-svg").forEach(i=>i.classList.remove("active")),document.querySelectorAll(".admin-sort-dontsave, .sidebar-module-add").forEach(i=>i.classList.add("d-none")),this._saveDetailSort()):(e?.querySelectorAll(r).forEach(i=>i.classList.add("sorting")),t?.querySelectorAll(r).forEach(i=>i.classList.add("sorting")),this._sortables.detailSort?.enable(),this._sortables.sideSort?.enable(),s&&(this._postDetailLayoutSortEnabled=!0,s.querySelectorAll(".post-detail-layout").forEach(i=>i.classList.add("sorting"))),this._setStatusText(".admin-sort-status","Sıralamayı Kaydet","text-success","text-warning-emphasis"),document.querySelectorAll(".sort-svg").forEach(i=>i.classList.add("active")),document.querySelectorAll(".admin-sort-dontsave, .sidebar-module-add").forEach(i=>i.classList.remove("d-none"))),this._adminSortActive=!this._adminSortActive}),document.querySelector(".admin-sort-dontsave")?.addEventListener("click",()=>{this._adminSortActive=!1,this._adminSortEnabled=!1,this._postDetailLayoutSortEnabled=!1,document.querySelectorAll(".admin-sort > .admin-sort-item").forEach(t=>t.classList.remove("sorting","sort-active")),document.querySelectorAll(".layout-module-item, .detail-sort-item, .sidebar-sort-item").forEach(t=>t.classList.remove("sorting")),document.querySelectorAll(".post-detail-layout").forEach(t=>t.classList.remove("sorting"));const e=document.querySelector(".admin-sort");e&&this._originalOrder.forEach(t=>{const s=document.getElementById(t);s&&e.appendChild(s)}),this._sortables.detailSort?.disable(),this._sortables.sideSort?.disable(),this._setStatusText(".admin-sort-status","Sıralamayı Düzenle","text-warning-emphasis","text-success"),document.querySelectorAll(".sort-svg").forEach(t=>t.classList.remove("active")),document.querySelectorAll(".admin-sort-dontsave, #main_page_add_module, .sidebar-module-add").forEach(t=>t.classList.add("d-none")),document.querySelector(".fast-admin-control")?.classList.remove("opened")}),document.querySelector(".admin-sort-activate")?.addEventListener("click",()=>{document.querySelectorAll(".admin-sort > .admin-sort-item").forEach((e,t)=>{e.id=`admin-sort-item-${t}`}),this._adminSortEnabled?(document.getElementById("main_page_add_module")?.classList.add("d-none"),this._adminSortEnabled=!1,document.querySelectorAll(".admin-sort > .admin-sort-item").forEach(e=>e.classList.remove("sorting","sort-active")),this._setStatusText(".admin-sort-status","Sıralamayı Düzenle","text-warning-emphasis","text-success"),document.querySelectorAll(".sort-svg").forEach(e=>e.classList.remove("active")),document.querySelectorAll(".admin-sort-dontsave").forEach(e=>e.classList.add("d-none")),this._saveSortOrder(),document.querySelector(".fast-admin-control")?.classList.remove("opened")):(this._originalOrder=Array.from(document.querySelectorAll(".admin-sort > .admin-sort-item")).map(e=>e.id),this._adminSortEnabled=!0,document.querySelectorAll(".admin-sort > .admin-sort-item").forEach(e=>e.classList.add("sorting")),this._setStatusText(".admin-sort-status","Sıralamayı Kaydet","text-success","text-warning-emphasis"),document.querySelectorAll(".sort-svg").forEach(e=>e.classList.add("active")),document.querySelectorAll(".admin-sort-dontsave").forEach(e
52=>e.classList.remove("d-none")),document.getElementById("main_page_add_module")?.classList.remove("d-none"))}),document.querySelector(".theme-options-li .theme-options-activate")?.addEventListener("click",()=>{const e=".partial-module-options, .module-activity, .element-theme-options-container, .module-activity-container, .clone-layout-btn";this._adminThemeOptionsActive?(document.querySelectorAll(".layout-module-item, .detail-sort-item, .sidebar-sort-item").forEach(t=>t.classList.remove("theme-editing")),this._setStatusText(".theme-options-status","Tema ÃzelleÅtirmeyi Aç","text-success","text-danger"),document.querySelectorAll(e).forEach(t=>t.classList.add("d-none")),document.querySelectorAll(".theme-options-svg").forEach(t=>t.classList.remove("active"))):(document.querySelectorAll(".layout-module-item, .detail-sort-item, .sidebar-sort-item").forEach(t=>t.classList.add("theme-editing")),this._setStatusText(".theme-options-status","Tema ÃzelleÅtirmeyi Kapat","text-danger","text-success"),document.querySelectorAll(e).forEach(t=>t.classList.remove("d-none")),document.querySelectorAll(".theme-options-svg").forEach(t=>t.classList.add("active"))),this._adminThemeOptionsActive=!this._adminThemeOptionsActive})}_saveSortOrder(){const e=Habersoft?.adminRoutes;if(!e?.sortable){console.error("[layout-sort] routes.sortable tanımsız",e);return}const s=[...document.querySelectorAll(".admin-sort > .admin-sort-item")].map((r,i)=>{const o=r.dataset.sortId||r.dataset.layoutId;if(!o)return console.warn("[layout-sort] itemID bulunamadı, atlanıyor",r),null;const a=new FormData;return a.append("itemID",o),a.append("itemIndex",i),L.customFetch(e.sortable,{method:"POST",body:a}).then(l=>l.json()).then(l=>({itemID:o,index:i,ok:l.success!==!1,response:l})).catch(l=>({itemID:o,index:i,ok:!1,error:l}))}).filter(Boolean);Promise.all(s).then(r=>{const i=r.filter(o=>!o.ok);i.length===0?window.NotificationManager?.success?.(`Sıralama kaydedildi (${r.length} katman)`):(console.error("[layout-sort] baÅarısız kayıtlar",i),window.NotificationManager?.error?.(`${i.length} katman kaydedilemedi`))})}_setStatusText(e,t,s,r){document.querySelectorAll(e).forEach(i=>{i.textContent=t,i.classList.add(s),i.classList.remove(r)})}init(){return Habersoft?.agent?.isMobile?this:(window.VanillaSortable=B,window.HabersoftUtils=L,document.querySelector(".admin-sort")&&(document.querySelectorAll(".admin-sort-li").forEach(e=>e.classList.remove("d-none")),document.querySelectorAll(".admin-sort > section").forEach(e=>e.classList.add("admin-sort-item")),this._applyLayoutData()),this._injectSettingButtons(),this._initSortable(),this._initAdminMouseSort(),this._initPostDetailLayoutSort(),this._bindEvents(),this)}}class at{constructor(){this._isActive=!1}_bindEditableText(){document.querySelectorAll(".editable-module-text").forEach(e=>{e.addEventListener("click",()=>{if(!this._isActive||e.classList.contains("edit-activated"))return;const t=getComputedStyle(e),s=parseFloat(t.fontSize),r=parseFloat(t.fontWeight),i=parseFloat(t.lineHeight),o=parseFloat(t.webkitLineClamp)||3,a=Math.floor(s+i*(o-.7));e.style.fontSize="0px",e.style.lineHeight="0px";const l=document.createElement("textarea");l.className=`moduleTitleEditInput ${e.className}`,l.dataset.postId=e.dataset.postId,l.style.cssText=`height:${a}px;font-size:${s}px;line-height:${i}px;font-weight:${r};`,l.value=e.textContent.trim(),e.appendChild(l),e.classList.add("edit-activated")})})}_bindSaveButton(){document.querySelector(".open-news-title-edit")?.addEventListener("click",function(){const e=document.querySelectorAll("div:not(.fast-admin-control) a");if(this.classList.toggle("active"),this.classList.contains("active"))this.querySelector(".admin-toolbar-text").textContent="Düzenlemeyi Kaydet ve Kapat",document.querySelectorAll(".swiper").forEach(t=>{t.swiper&&t.swiper.autoplay.stop()}),e.forEach(t=>{t.setAttribute("data-link-href",t.getAttribute("href")),t.setAttribute("href","javascript:void(0)")});else{const t=Array.from(document.querySelectorAll(".moduleTitleEditInput")).map(i=>({id:i.dataset.postId,title:i.value})),s=new FormData;t.forEach((i,o)=>{s.append(`titles[${o}][id]`,i.id),s.append(`titles[${o}][title]`,i.title)});
52const r=Habersoft?.adminRoutes?.["post.update_multiple_titles"];r&&L.customFetch(r,{method:"POST",body:s}).then(i=>i.json()).then(i=>console.log("Title save:",i)).catch(i=>console.error("Title save error:",i)),this.querySelector(".admin-toolbar-text").textContent="Haber BaÅlıÄı Düzenle",document.querySelectorAll(".swiper").forEach(i=>{i.swiper&&i.swiper.autoplay.start()}),e.forEach(i=>{i.setAttribute("href",i.getAttribute("data-link-href")||""),i.removeAttribute("data-link-href")}),document.querySelectorAll(".edit-activated").forEach(i=>{i.textContent=i.querySelector("textarea")?.value||"",i.style.fontSize="",i.style.lineHeight="",i.classList.remove("edit-activated")})}})}init(){return this._bindEditableText(),this._bindSaveButton(),this}}const lt='<svg width="35px" height="35px" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#ffffff"><path fill="#ffffff" d="m80.16 29.054-5.958-.709 5.958.71Zm31.68 0-5.958.71 5.958-.71Zm34.217 19.756-2.365-5.515 2.365 5.514Zm10.081 3.352 5.196-3-5.196 3Zm7.896 13.676 5.196-3-5.196 3Zm-2.137 10.407-3.594-4.805 3.594 4.805Zm0 39.51 3.593-4.805-3.593 4.805Zm2.137 10.407 5.196 3-5.196-3Zm-7.896 13.676-5.196-3 5.196 3Zm-10.081 3.353 2.364-5.515-2.364 5.515Zm-34.217 19.755 5.958.709-5.958-.709Zm-31.68 0-5.958.709 5.958-.709Zm-34.217-19.755-2.364-5.515 2.364 5.515Zm-10.08-3.353-5.197 3 5.196-3Zm-7.897-13.676 5.196-3-5.196 3Zm2.137-10.407 3.594 4.805-3.594-4.805Zm0-39.51L26.51 81.05l3.593-4.805Zm-2.137-10.407 5.196 3-5.196-3Zm7.896-13.676-5.196-3 5.196 3Zm10.081-3.352-2.364 5.514 2.364-5.514Zm7.85 3.365-2.365 5.515 2.364-5.515Zm0 87.65 2.364 5.514-2.365-5.514ZM88.104 16a14 14 0 0 0-13.902 12.345l11.916 1.419A2 2 0 0 1 88.104 28V16Zm15.792 0H88.104v12h15.792V16Zm13.902 12.345A14 14 0 0 0 103.896 16v12a2 2 0 0 1 1.986 1.764l11.916-1.419ZM49 96c0-7.1-2.548-15.022-9.171-19.975l-7.187 9.61C35.36 87.668 37 91.438 37 96h12Zm94 0c0 6.389 2.398 13.414 8.32 17.842l7.186-9.61C154.374 102.638 153 99.668 153 96h-12Z"/><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="12" d="M96 120c13.255 0 24-10.745 24-24s-10.745-24-24-24-24 10.745-24 24 10.745 24 24 24Z"/></svg>',ct='<svg width="35px" height="35px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#ffffff"><path fill="#ffffff" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/></svg>';class dt{_buildSortItemHtml(e,t){return` 53 <div class="col-12 detail-sort-item sorting position-relative mb-2" 54 data-detail-module-id="${e.moduleId}" 55 data-detail-module-time="${e.moduleTime}"> 56 <div class="module-settings-container position-absolute top-0 start-0 end-0 bottom-0 d-flex flex-row align-items-center justify-content-center"> 57 <div class="detailside-module-edit z-2 ms-2 mt-2 c-pointer" 58 data-bs-toggle="offcanvas" data-bs-target="#moduleSidebarCont" 59 data-detail-model-type="${e.modelType}" 60 data-detail-module-form-filename="${e.filename}" 61 data-detail-module-id="${e.moduleId}" 62 data-detail-post-id="${e.postId}" 63 data-detail-module-time="${e.moduleTime}"> 64 ${lt} 65 </div> 66 <div class="sidebar-module-off z-2 ms-2 mt-2 c-pointer">${ct}</div> 67 </div> 68 ${t} 69 </div>`}_bindListItemClick(){const e=document.querySelector('meta[name="csrf-token"]')?.content;document.addEventListener("click",t=>{const s=t.target.closest(".detailside-modules-list-item");if(!s)return;const r={moduleId:s.dataset.detailModuleId,moduleName:s.dataset.detailModuleName,moduleTime:s.dataset.detailModuleTime+Math.floor(Math.random()*1e5),filename:s.dataset.detailModuleFormFilename,postId:s.dataset.detailPostId,modelType:s.dataset.detailModelType,klasorType:(s.dataset.detailModelKlasorType||"").trim()},i=Habersoft?.adminRoutes?.["detailsides.rendermodule"];i&&fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":e},body:JSON.stringify({detailsideModuleId:r.moduleId,detailsideModuleName:r.moduleName,detailsideModuleTime:r.moduleTime,detailsidePostId:r.postId,detailsideModelType:r.modelType,detailsideKlasorType:r.klasorType})}).then(o=>o.text()).then(o=>{document.querySelector(".detail-sort-container .sidebar-module-add")?.insertAdjacentHTML("beforebegin",this._buildSortItemHtml(r,o)),bootstrap.Modal.getInstance(document.getElementById("detailside-modules-modal"))?.hide()}).catch(o=>console.error("DetailSide rendermodule error:",o))})}_bindEditClick(){document.addEventListener("click",async e=>{const t=e.target.closest(".detailside-module-edit");if(!t)return;document.querySelectorAll("#moduleEditPanel .homepage-edit-panel, #moduleEditStylePanel .homepage-edit-panel").forEach(d=>{d.innerHTML=""});const s=new FormData,r=t.dataset.detailModuleTime,i={detailsideModuleFormFilename:t.dataset.detailModuleFormFilename,detailsideModuleId:t.dataset.detailModuleId,detailsideModuleTime:r,detailsidePostId:t.dataset.detailPostId,detailsideModelType:t.dataset.detailModelType};
69Object.entries(i).forEach(([d,u])=>s.append(d,u));const o=Habersoft?.adminRoutes?.["detailsides.render_form_module"],a=Habersoft?.adminRoutes?.["detailsides.render_style_form"],l=document.querySelector('meta[name="csrf-token"]')?.content;if(!o)return;const c=document.querySelector("#moduleEditPanel .homepage-edit-panel");try{const d=await(await L.customFetch(o,{method:"POST",body:s})).json();c&&(c.innerHTML=d.status?d.html:'<div class="text-danger fw-semibold fs-24 p-3">MODÃL AYARI BULUNMUYOR!</div>'),H.bindScope(c,"sides")}catch(d){c&&(c.innerHTML='<div class="text-danger fw-semibold fs-24 p-3">MODÃL AYARI BULUNMUYOR!</div>'),console.error("DetailSide render_form_module error:",d)}a&&r&&fetch(a,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":l},body:JSON.stringify({detailsideModuleTime:r})}).then(d=>d.json()).then(d=>{const u=document.querySelector("#moduleEditStylePanel .homepage-edit-panel");u&&(d.status?(u.innerHTML=d.html,H.bindScope(u,"sides"),window.eventManager?.emit("initStylePanel")):u.innerHTML="")}).catch(d=>console.error("DetailSide stil formu yüklenemedi:",d))})}init(){return this._bindListItemClick(),this._bindEditClick(),this}}function le(n,e){n.split(/\s+/).forEach(t=>{e(t)})}class ut{constructor(){this._events={}}on(e,t){le(e,s=>{const r=this._events[s]||[];r.push(t),this._events[s]=r})}off(e,t){var s=arguments.length;if(s===0){this._events={};return}le(e,r=>{if(s===1){delete this._events[r];return}const i=this._events[r];i!==void 0&&(i.splice(i.indexOf(t),1),this._events[r]=i)})}trigger(e,...t){var s=this;le(e,r=>{const i=s._events[r];i!==void 0&&i.forEach(o=>{o.apply(s,t)})})}}function pt(n){return n.plugins={},class extends n{constructor(){super(...arguments),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(e,t){n.plugins[e]={name:e,fn:t}}initializePlugins(e){var t,s;const r=this,i=[];if(Array.isArray(e))e.forEach(o=>{typeof o=="string"?i.push(o):(r.plugins.settings[o.name]=o.options,i.push(o.name))});else if(e)for(t in e)e.hasOwnProperty(t)&&(r.plugins.settings[t]=e[t],i.push(t));for(;s=i.shift();)r.require(s)}loadPlugin(e){var t=this,s=t.plugins,r=n.plugins[e];if(!n.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');s.requested[e]=!0,s.loaded[e]=r.fn.apply(t,[t.plugins.settings[e]||{}]),s.names.push(e)}require(e){var t=this,s=t.plugins;if(!t.plugins.loaded.hasOwnProperty(e)){if(s.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');t.loadPlugin(e)}return s.loaded[e]}}}const ie=n=>(n=n.filter(Boolean),n.length<2?n[0]||"":mt(n)==1?"["+n.join("")+"]":"(?:"+n.join("|")+")"),ze=n=>{if(!ft(n))return n.join("");let e="",t=0;const s=()=>{t>1&&(e+="{"+t+"}")};return n.forEach((r,i)=>{if(r===n[i-1]){t++;return}s(),e+=r,t=1}),s(),e},je=n=>{let e=Array.from(n);return ie(e)},ft=n=>new Set(n).size!==n.length,Y=n=>(n+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),mt=n=>n.reduce((e,t)=>Math.max(e,ht(t)),0),ht=n=>Array.from(n).length,Ze=n=>{if(n.length===1)return[[n]];let e=[];const t=n.substring(1);return Ze(t).forEach(function(r){let i=r.slice(0);i[0]=n.charAt(0)+i[0],e.push(i),i=r.slice(0),i.unshift(n.charAt(0)),e.push(i)}),e},gt=[[0,65535]],yt="[Ì-ͯ·ʾʼ]";let se,Ue;const vt=3,ye={},be={"/":"ââ",0:"ß",a:"â±¥ÉÉ",aa:"ê³",ae:"æǽǣ",ao:"êµ",au:"ê·",av:"ê¹ê»",ay:"ê½",b:"ÆÉÆ",c:"ê¿ÆÈ¼â",d:"ÄÉÉá´
Æê®·Ôɦ",e:"ÉÇá´É",f:"ê¼Æ",g:"Ç¥É ê¡áµ¹ê¿É¢",h:"ħⱨⱶɥ",i:"ɨı",j:"ÉÈ·",k:"Æâ±ªêêê
ê£",l:"ÅÆÉ«â±¡êêêÉ",m:"ɱɯϻ",n:"ê¥ÆÉ²êá´Ð»Ô",o:"øǿÉɵêêá´",oe:"Å",oi:"Æ£",oo:"ê",ou:"È£",p:"ƥᵽêêêÏ",q:"êêÉ",r:"Éɽêê§ê",s:"ÃÈ¿ê©ê
Ê",t:"ŧÆÊⱦê",th:"þ",tz:"ê©",u:"Ê",v:"ÊêÊ",vy:"ê¡",w:"â±³",y:"Æ´Éỿ",z:"ƶȥÉⱬê£",hv:"Æ"};for(let n in be){let e=be[n]||"";for(let t=0;t<e.length;t++){let s=e.substring(t,t+1);ye[s]=n}}const bt=new RegExp(Object.keys(ye).join("|")+"|"+yt,"gu"),St=n=>{se===void 0&&(se=xt(gt))},Se=(n,e="NFKD")=>n.normalize(e),ne=n=>Array.from(n).reduce((e,t)=>e+_t(t),""),_t=n=>(n=Se(n).toLowerCase().replace(bt,e=>ye[e]||""),Se(n,"NFC"));function*wt(n){for(const[e,t]of n)for(let s=e;s<=t;s++){let r=String.fromCharCode(s),i=ne(r);i!=r.toLowerCase()&&(i.length>vt||i.length!=0&&(yield{folded:i,composed:r,code_point:s}))}}const Et=n=>{const e={},t=(s,r)=>{const i=e[s]||new Set,o=new RegExp("^"+je(i)+"$","iu");r.match(o)||(i.add(Y(r)),e[s]=i)};for(let s of wt(n))t(s.folded,s.folded),t(s.folded,s.composed);return e},xt=n=>{const e=Et(n),t={};let s=[];for(let i in e){let o=e[i];o&&(t[i]=je(o)),i.length>1&&s.push(Y(i))}s.sort((i,o)=>o.length-i.length);const r=ie(s);return Ue=new RegExp("^"+r,"u"),t},At=(n,e=1)=>{let t=0;return n=n.map(s=>(se[s]&&(t+=s.length),se[s]||s)),t>=e?ze(n):""},Lt=(n,e=1)=>(e=Math.max(e,n.length-1),ie(Ze(n).map(t=>At(t,e)))),_e=(n,e=!0)=>{let t=n.length>1?1:0;return ie(n.map(s=>{let r=[];const i=e?s.length():s.length()-1;for(let o=0;o<i;o++)r.push(Lt(s.substrs[o]||"",t));return ze(r)}))},kt=(n,e)=>{for(const t of e){if(t.start!=n.start||t.end!=n.end||t.substrs.join("")!==n.substrs.join(""))continue;let s=n.parts;const r=o=>{for(const a of s){if(a.start===o.start&&a.substr===o.substr)return!1;if(!(o.length==1||a.length==1)&&(o.start<a.start&&o.end>a.start||a.start<o.start&&a.end>o.start))return!0}return!1};if(!(t.parts.filter(r).length>0))return!0}return!1};class re{parts;substrs;start;end;constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let s=new re,r=JSON.parse(JSON.stringify(this.parts)),i=r.pop();for(const l of r)s.add(l);let o=t.substr.substring(0,e-i.start),a=o.length;return s.add({start:i.start,end:i.start+a,length:a,substr:o}),s}}const Ct=n=>{St(),n=ne(n);let e="",t=[new re];for(let s=0;s<n.length;s++){let i=n.substring(s).match(Ue);const o=n.substring(s,s+1),a=i?i[0]:null;let l=[],c=new Set;for(const d of t){const u=d.last();if(!u||u.length==1||u.end<=s)if(a){const p=a.length;d.add({start:s,end:s+p,length:p,substr:a}),c.add("1")}else d.add({start:s,end:s+1,length:1,substr:o}),c.add("2");else if(a){let p=d.clone(s,u);const v=a.length;p.add({start:s,end:s+v,length:v,substr:a}),l.push(p)}else c.add("3")}if(l.length>0){l=l.sort((d,u)=>d.length()-u.length());for(let d of l)kt(d,t)||t.push(d);continue}if(s>0&&c.size==1&&!c.has("3")){e+=_e(t,!1);let d=new re;const u=t[0];u&&d.add(u.last()),t=[d]}}return e+=_e(t,!0),e},Tt=(n,e)=>{if(n)return n[e]},It=(n,e)=>{if(n){for(var t,s=e.split(".");(t=s.shift())&&(n=n[t]););return n}},ce=(n,e,t)=>{var s,r;return!n||(n=n+"",e.regex==null)||(r=n.search(e.regex),r===-1)?0:(s=e.string.length/n.length,r===0&&(s+=.5),s*t)},de=(n,e)=>{var t=n[e];if(typeof t=="function")return t;t&&!Array.isArray(t)&&(n[e]=[t])},W=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},Ot=(n,e)=>typeof n=="number"&&typeof e=="number"?n>e?1:n<e?-1:0:(n=ne(n+"").toLowerCase(),e=ne(e+"").toLowerCase(),n>e?1:e>n?-1:0);class Pt{items;settings;constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}
69tokenize(e,t,s){if(!e||!e.length)return[];const r=[],i=e.split(/\s+/);var o;return s&&(o=new RegExp("^("+Object.keys(s).map(Y).join("|")+"):(.*)$")),i.forEach(a=>{let l,c=null,d=null;o&&(l=a.match(o))&&(c=l[1],a=l[2]),a.length>0&&(this.settings.diacritics?d=Ct(a)||null:d=Y(a),d&&t&&(d="\\b"+d)),r.push({string:a,regex:d?new RegExp(d,"iu"):null,field:c})}),r}getScoreFunction(e,t){var s=this.prepareSearch(e,t);return this._getScoreFunction(s)}_getScoreFunction(e){const t=e.tokens,s=t.length;if(!s)return function(){return 0};const r=e.options.fields,i=e.weights,o=r.length,a=e.getAttrFn;if(!o)return function(){return 1};const l=function(){return o===1?function(c,d){const u=r[0].field;return ce(a(d,u),c,i[u]||1)}:function(c,d){var u=0;if(c.field){const p=a(d,c.field);!c.regex&&p?u+=1/o:u+=ce(p,c,1)}else W(i,(p,v)=>{u+=ce(a(d,v),c,p)});return u/o}}();return s===1?function(c){return l(t[0],c)}:e.options.conjunction==="and"?function(c){var d,u=0;for(let p of t){if(d=l(p,c),d<=0)return 0;u+=d}return u/s}:function(c){var d=0;return W(t,u=>{d+=l(u,c)}),d/s}}getSortFunction(e,t){var s=this.prepareSearch(e,t);return this._getSortFunction(s)}_getSortFunction(e){var t,s=[];const r=this,i=e.options,o=!e.query&&i.sort_empty?i.sort_empty:i.sort;if(typeof o=="function")return o.bind(this);const a=function(c,d){return c==="$score"?d.score:e.getAttrFn(r.items[d.id],c)};if(o)for(let c of o)(e.query||c.field!=="$score")&&s.push(c);if(e.query){t=!0;for(let c of s)if(c.field==="$score"){t=!1;break}t&&s.unshift({field:"$score",direction:"desc"})}else s=s.filter(c=>c.field!=="$score");return s.length?function(c,d){var u,p;for(let v of s)if(p=v.field,u=(v.direction==="desc"?-1:1)*Ot(a(p,c),a(p,d)),u)return u;return 0}:null}prepareSearch(e,t){const s={};var r=Object.assign({},t);if(de(r,"sort"),de(r,"sort_empty"),r.fields){de(r,"fields");const i=[];r.fields.forEach(o=>{typeof o=="string"&&(o={field:o,weight:1}),i.push(o),s[o.field]="weight"in o?o.weight:1}),r.fields=i}return{options:r,query:e.toLowerCase().trim(),tokens:this.tokenize(e,r.respect_word_boundaries,s),total:0,items:[],weights:s,getAttrFn:r.nesting?It:Tt}}search(e,t){var s=this,r,i;i=this.prepareSearch(e,t),t=i.options,e=i.query;const o=t.score||s._getScoreFunction(i);e.length?W(s.items,(l,c)=>{r=o(l),(t.filter===!1||r>0)&&i.items.push({score:r,id:c})}):W(s.items,(l,c)=>{i.items.push({score:1,id:c})});const a=s._getSortFunction(i);return a&&i.items.sort(a),i.total=i.items.length,typeof t.limit=="number"&&(i.items=i.items.slice(0,t.limit)),i}}const F=n=>typeof n>"u"||n===null?null:te(n),te=n=>typeof n=="boolean"?n?"1":"0":n+"",ue=n=>(n+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),qt=(n,e)=>e>0?window.setTimeout(n,e):(n.call(null),null),Mt=(n,e)=>{var t;return function(s,r){var i=this;t&&(i.loading=Math.max(i.loading-1,0),clearTimeout(t)),t=setTimeout(function(){t=null,i.loadedSearches[s]=!0,n.call(i,s,r)},e)}},we=(n,e,t)=>{var s,r=n.trigger,i={};n.trigger=function(){var o=arguments[0];if(e.indexOf(o)!==-1)i[o]=arguments;else return r.apply(n,arguments)},t.apply(n,[]),n.trigger=r;for(s of e)s in i&&r.apply(n,i[s])},$t=n=>({start:n.selectionStart||0,length:(n.selectionEnd||0)-(n.selectionStart||0)}),I=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},q=(n,e,t,s)=>{n.addEventListener(e,t,s)},z=(n,e)=>{if(!e||!e[n])return!1;var t=(e.altKey?1:0)+(e.ctrlKey?1:0)+(e.shiftKey?1:0)+(e.metaKey?1:0);return t===1},pe=(n,e)=>{const t=n.getAttribute("id");return t||(n.setAttribute("id",e),e)},Ee=n=>n.replace(/[\\"']/g,"\\$&"),j=(n,e)=>{e&&n.append(e)},P=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},D=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(Ke(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},Ke=n=>typeof n=="string"&&n.indexOf("<")>-1,Ft=n=>n.replace(/['"\\]/g,"\\$&"),fe=(n,e)=>{var t=document.createEvent("HTMLEvents");t.initEvent(e,!0,!1),n.dispatchEvent(t)},X=(n,e)=>{Object.assign(n.style,e)},$=(n,...e)=>{var t=Ye(e);n=We(n),n.map(s=>{t.map(r=>{s.classList.add(r)})})},N=(n,...e)=>{var t=Ye(e);n=We(n),n.map(s=>{t.map(r=>{s.classList.remove(r)})})},Ye=n=>{var e=[];return P(n,t=>{typeof t=="string"&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},We=n=>(Array.isArray(n)||(n=[n]),n),me=(n,e,t)=>{if(!(t&&!t.contains(n)))for(;n&&n.matches;){if(n.matches(e))return n;n=n.parentNode}},xe=(n,e=0)=>e>0?n[n.length-1]:n[0],Ht=n=>Object.keys(n).length===0,Ae=(n,e)=>{if(!n)return-1;e=e||n.nodeName;for(var t=0;n=n.previousElementSibling;)n.matches(e)&&t++;return t},C=(n,e)=>{P(e,(t,s)=>{t==null?n.removeAttribute(s):n.setAttribute(s,""+t)})},ge=(n,e)=>{n.parentNode&&n.parentNode.replaceChild(e,n)},Dt=(n,e)=>{if(e===null)return;if(typeof e=="string"){if(!e.length)return;e=new RegExp(e,"i")}const t=i=>{var o=i.data.match(e);if(o&&i.data.length>0){var a=document.createElement("span");a.className="highlight";var l=i.splitText(o.index);l.splitText(o[0].length);var c=l.cloneNode(!0);return a.appendChild(c),ge(l,a),1}return 0},s=i=>{i.nodeType===1&&i.childNodes&&!/(script|style)/i.test(i.tagName)&&(i.className!=="highlight"||i.tagName!=="SPAN")&&Array.from(i.childNodes).forEac
69h(o=>{r(o)})},r=i=>i.nodeType===3?t(i):(s(i),0);r(n)},Bt=n=>{var e=n.querySelectorAll("span.highlight");Array.prototype.forEach.call(e,function(t){var s=t.parentNode;s.replaceChild(t.firstChild,t),s.normalize()})},Rt=65,Vt=13,Nt=27,zt=37,jt=38,Zt=39,Ut=40,Le=8,Kt=46,ke=9,Yt=typeof navigator>"u"?!1:/Mac/.test(navigator.userAgent),G=Yt?"metaKey":"ctrlKey",Ce={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,clearAfterSelect:!1,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,refreshThrottle:300,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(n){return n.length>0},render:{}};function Te(n,e){var t=Object.assign({},Ce,e),s=t.dataAttr,r=t.labelField,i=t.valueField,o=t.disabledField,a=t.optgroupField,l=t.optgroupLabelField,c=t.optgroupValueField,d=n.tagName.toLowerCase(),u=n.getAttribute("placeholder")||n.getAttribute("data-placeholder");if(!u&&!t.allowEmptyOption){let S=n.querySelector('option[value=""]');S&&(u=S.textContent)}var p={placeholder:u,options:[],optgroups:[],items:[],maxItems:null},v=()=>{var S,y=p.options,g={},f=1;let m=0;var b=E=>{var x=Object.assign({},E.dataset),w=s&&x[s];return typeof w=="string"&&w.length&&(x=Object.assign(x,JSON.parse(w))),x},_=(E,x)=>{var w=F(E.value);if(w!=null&&!(!w&&!t.allowEmptyOption)){if(g.hasOwnProperty(w)){if(x){var T=g[w][a];T?Array.isArray(T)?T.push(x):g[w][a]=[T,x]:g[w][a]=x}}else{var k=b(E);k[r]=k[r]||E.textContent,k[i]=k[i]||w,k[o]=k[o]||E.disabled,k[a]=k[a]||x,k.$option=E,k.$order=k.$order||++m,g[w]=k,y.push(k)}E.selected&&p.items.push(w)}},A=E=>{var x,w;w=b(E),w[l]=w[l]||E.getAttribute("label")||"",w[c]=w[c]||f++,w[o]=w[o]||E.disabled,w.$order=w.$order||++m,p.optgroups.push(w),x=w[c],P(E.children,T=>{_(T,x)})};p.maxItems=n.hasAttribute("multiple")?null:1,P(n.children,E=>{S=E.tagName.toLowerCase(),S==="optgroup"?A(E):S==="option"&&_(E)})},h=()=>{const S=n.getAttribute(s);if(S)p.options=JSON.parse(S),P(p.options,g=>{p.items.push(g[i])});else{var y=n.value.trim()||"";if(!t.allowEmptyOption&&!y.length)return;const g=y.split(t.delimiter);P(g,f=>{const m={};m[r]=f,m[i]=f,p.options.push(m)}),p.items=g}};return d==="select"?v():h(),Object.assign({},Ce,p,e)}var Ie=0;class M extends pt(ut){constructor(e,t){super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isReadOnly=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.refreshTimeout=null,Ie++;var s,r=D(e);if(r.tomselect)throw new Error("Tom Select already initialized on this element");r.tomselect=this;var i=window.getComputedStyle&&window.getComputedStyle(r,null);s=i.getPropertyValue("direction");const o=Te(r,t);this.settings=o,this.input=r,this.tabIndex=r.tabIndex||0,this.is_select_tag=r.tagName.toLowerCase()==="select",this.rtl=/rtl/i.test(s),this.inputId=pe(r,"tomselect-"+Ie),this.isRequired=r.required,this.sifter=new Pt(this.options,{diacritics:o.diacritics}),o.mode=o.mode||(o.maxItems===1?"single":"multi"),typeof o.hideSelected!="boolean"&&(o.hideSelected=o.mode==="multi"),typeof o.hidePlaceholder!="boolean"&&(o.hidePlaceholder=o.mode!=="multi");var a=o.createFilter;
69typeof a!="function"&&(typeof a=="string"&&(a=new RegExp(a)),a instanceof RegExp?o.createFilter=y=>a.test(y):o.createFilter=y=>this.settings.duplicates||!this.options[y]),this.initializePlugins(o.plugins),this.setupCallbacks(),this.setupTemplates();const l=D("<div>"),c=D("<div>"),d=this._render("dropdown"),u=D('<div role="listbox" tabindex="-1">'),p=this.input.getAttribute("class")||"",v=o.mode;var h;if($(l,o.wrapperClass,p,v),$(c,o.controlClass),j(l,c),$(d,o.dropdownClass,v),o.copyClassesToDropdown&&$(d,p),$(u,o.dropdownContentClass),j(d,u),D(o.dropdownParent||l).appendChild(d),Ke(o.controlInput)){h=D(o.controlInput);var S=["autocorrect","autocapitalize","autocomplete","spellcheck","aria-label"];P(S,y=>{r.getAttribute(y)&&C(h,{[y]:r.getAttribute(y)})}),h.tabIndex=-1,c.appendChild(h),this.focus_node=h}else o.controlInput?(h=D(o.controlInput),this.focus_node=h):(h=D("<input/>"),this.focus_node=c);this.wrapper=l,this.dropdown=d,this.dropdown_content=u,this.control=c,this.control_input=h,this.setup()}setup(){const e=this,t=e.settings,s=e.control_input,r=e.dropdown,i=e.dropdown_content,o=e.wrapper,a=e.control,l=e.input,c=e.focus_node,d={passive:!0},u=e.inputId+"-ts-dropdown";C(i,{id:u}),C(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u});const p=pe(c,e.inputId+"-ts-control"),v="label[for='"+Ft(e.inputId)+"']",h=document.querySelector(v),S=e.focus.bind(e);if(h){q(h,"click",S),C(h,{for:p});const m=pe(h,e.inputId+"-ts-label");C(c,{"aria-labelledby":m}),C(i,{"aria-labelledby":m})}if(o.style.width=l.style.width,o.style.minWidth=l.style.minWidth,o.style.maxWidth=l.style.maxWidth,e.plugins.names.length){const m="plugin-"+e.plugins.names.join(" plugin-");$([o,r],m)}(t.maxItems===null||t.maxItems>1)&&e.is_select_tag&&C(l,{multiple:"multiple"}),t.placeholder&&C(s,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+Y(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=Mt(t.load,t.loadThrottle)),q(r,"mousemove",()=>{e.ignoreHover=!1}),q(r,"mouseenter",m=>{var b=me(m.target,"[data-selectable]",r);b&&e.onOptionHover(m,b)},{capture:!0}),q(r,"click",m=>{const b=me(m.target,"[data-selectable]");b&&(e.onOptionSelect(m,b),I(m,!0))}),q(a,"click",m=>{var b=me(m.target,"[data-ts-item]",a);if(b&&e.onItemSelect(m,b)){I(m,!0);return}s.value==""&&(e.onClick(),I(m,!0))}),q(c,"keydown",m=>e.onKeyDown(m)),q(s,"keypress",m=>e.onKeyPress(m)),q(s,"input",m=>e.onInput(m)),q(c,"blur",m=>e.onBlur(m)),q(c,"focus",m=>e.onFocus(m)),q(s,"paste",m=>e.onPaste(m));const y=m=>{const b=m.composedPath()[0];if(!o.contains(b)&&!r.contains(b)){e.isFocused&&e.blur(),e.inputState();return}b==s&&e.isOpen?m.stopPropagation():I(m,!0)},g=()=>{e.isOpen&&e.positionDropdown()},f=()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())};q(l,"invalid",f),q(document,"mousedown",y),q(window,"scroll",g,d),q(window,"resize",g,d),this._destroy=()=>{l.removeEventListener("invalid",f),document.removeEventListener("mousedown",y),window.removeEventListener("scroll",g),window.removeEventListener("resize",g),h&&h.removeEventListener("click",S)},this.revertSettings={innerHTML:l.innerHTML,tabIndex:l.tabIndex},l.tabIndex=-1,l.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,l.disabled?e.disable():l.readOnly?e.setReadOnly(!0):e.enable(),e.on("change",this.onChange),$(l,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),t.preload===!0&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),P(t,s=>{this.registerOptionGroup(s)})}setupTemplates(){var e=this,t=e.settings.labelField,s=e.settings.optgroupLabelField,r={optgroup:i=>{let o=document.createElement("div");return o.className="optgroup",o.appendChild(i.options),o},optgroup_header:(i,o)=>'<div class="optgroup-header">'+o(i[s])+"</div>",option:(i,o)=>"<div>"+o(i[t])+"</div>",item:(i,o)=>"<div>"+o(i[t])+"</div>",option_create:(i,o)=>'<div class="create">Add <strong>'+o(i.input)+"</strong>…</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"};e.settings.render=Object.assign({},r,e.settings.render)}setupCallbacks(){var e,t,s={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in s)t=this.settings[s[e]],t&&this.on(e,t)}sync(e=!0){const t=this,s=e?Te(t.input,{delimiter:t.settings.delimiter,allowEmptyOption:t.settings.allowEmptyOption}):t.settings;t.setupOptions(s.options,s.optgroups),t.setValue(s.items||[],!0),t.lastQuery=null}
69onClick(){var e=this;if(e.activeItems.length>0){e.clearActiveItems(),e.focus();return}e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){fe(this.input,"input"),fe(this.input,"change")}onPaste(e){var t=this;if(t.isInputHidden||t.isLocked){I(e);return}t.settings.splitOn&&setTimeout(()=>{var s=t.inputValue();if(s.match(t.settings.splitOn)){var r=s.trim().split(t.settings.splitOn);P(r,i=>{F(i)&&(this.options[i]?t.addItem(i):t.createItem(i))})}},0)}onKeyPress(e){var t=this;if(t.isLocked){I(e);return}var s=String.fromCharCode(e.keyCode||e.which);if(t.settings.create&&t.settings.mode==="multi"&&s===t.settings.delimiter){t.createItem(),I(e);return}}onKeyDown(e){var t=this;if(t.ignoreHover=!0,t.isLocked){e.keyCode!==ke&&I(e);return}switch(e.keyCode){case Rt:if(z(G,e)&&t.control_input.value==""){I(e),t.selectAll();return}break;case Nt:t.isOpen&&(I(e,!0),t.close()),t.clearActiveItems();return;case Ut:if(!t.isOpen&&t.hasOptions)t.open();else if(t.activeOption){let s=t.getAdjacent(t.activeOption,1);s&&t.setActiveOption(s)}I(e);return;case jt:if(t.activeOption){let s=t.getAdjacent(t.activeOption,-1);s&&t.setActiveOption(s)}I(e);return;case Vt:t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),I(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&I(e);return;case zt:t.advanceSelection(-1,e);return;case Zt:t.advanceSelection(1,e);return;case ke:t.settings.selectOnTab&&(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),I(e)):t.settings.create&&t.createItem()&&I(e));return;case Le:case Kt:t.deleteSelection(e);return}t.isInputHidden&&!z(G,e)&&I(e)}onInput(e){if(this.isLocked)return;const t=this.inputValue();if(this.lastValue!==t){if(this.lastValue=t,t==""){this._onInput();return}this.refreshTimeout&&window.clearTimeout(this.refreshTimeout),this.refreshTimeout=qt(()=>{this.refreshTimeout=null,this._onInput()},this.settings.refreshThrottle)}}_onInput(){const e=this.lastValue;this.settings.shouldLoad.call(this,e)&&this.load(e),this.refreshOptions(),this.trigger("type",e)}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,s=t.isFocused;if(t.isDisabled||t.isReadOnly){t.blur(),I(e);return}t.ignoreFocus||(t.isFocused=!0,t.settings.preload==="focus"&&t.preload(),s||t.trigger("focus"),t.activeItems.length||(t.inputState(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(document.hasFocus()!==!1){var t=this;if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1;var s=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")};t.settings.create&&t.settings.createOnBlur?t.createItem(null,s):s()}}}onOptionSelect(e,t){var s,r=this;t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?r.createItem(null,()=>{r.settings.closeAfterSelect?r.close():r.settings.clearAfterSelect&&r.setTextboxValue()}):(s=t.dataset.value,typeof s<"u"&&(r.lastQuery=null,r.addItem(s),r.settings.closeAfterSelect?r.close():r.settings.clearAfterSelect&&r.setTextboxValue(),!r.settings.hideSelected&&e.type&&/click/.test(e.type)&&r.setActiveOption(t))))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var s=this;return!s.isLocked&&s.settings.mode==="multi"?(I(e),s.setActiveItem(t,e),!0):!1}canLoad(e){return!(!this.settings.load||this.loadedSearches.hasOwnProperty(e))}load(e){const t=this;if(!t.canLoad(e))return;$(t.wrapper,t.settings.loadingClass),t.loading++;const s=t.loadCallback.bind(t);t.settings.load.call(t,e,s)}loadCallback(e,t){const s=this;s.loading=Math.max(s.loading-1,0),s.lastQuery=null,s.clearActiveOption(),s.setupOptions(e,t),s.refreshOptions(s.isFocused&&!s.isInputHidden),s.loading||N(s.wrapper,s.settings.loadingClass),s.trigger("load",e,t)}preload(){var e=this.wrapper.classList;e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input,s=t.value!==e;s&&(t.value=e,fe(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){var s=t?[]:["change"];we(this,s,()=>{this.clear(t),this.addItems(e,t)})}setMaxItems(e){e===0&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var s=this,r,i,o,a,l,c;if(s.settings.mode!=="single"){if(!e){s.clearActiveItems(),s.isFocused&&s.inputState();return}if(r=t&&t.type.toLowerCase(),r==="click"&&z("shiftKey",t)&&s.activeItems.length){for(c=s.getLastActive(),o=Array.prototype.indexOf.call(s.control.children,c),a=Array.prototype.indexOf.call(s.control.children,e),o>a&&(l=o,o=a,a=l),i=o;i<=a;i++)e=s.control.children[i],s.activeItems.indexOf(e)===-1&&s.setActiveItem
69Class(e);I(t)}else r==="click"&&z(G,t)||r==="keydown"&&z("shiftKey",t)?e.classList.contains("active")?s.removeActiveItem(e):s.setActiveItemClass(e):(s.clearActiveItems(),s.setActiveItemClass(e));s.inputState(),s.isFocused||s.focus()}}setActiveItemClass(e){const t=this,s=t.control.querySelector(".last-active");s&&N(s,"last-active"),$(e,"active last-active"),t.trigger("item_select",e),t.activeItems.indexOf(e)==-1&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),N(e,"active")}clearActiveItems(){N(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,C(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),C(e,{"aria-selected":"true"}),$(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return;const s=this.dropdown_content,r=s.clientHeight,i=s.scrollTop||0,o=e.offsetHeight,a=e.getBoundingClientRect().top-s.getBoundingClientRect().top+i;a+o>r+i?this.scroll(a-r+o,t):a<i&&this.scroll(a,t)}scroll(e,t){const s=this.dropdown_content;t&&(s.style.scrollBehavior=t),s.scrollTop=e,s.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(N(this.activeOption,"active"),C(this.activeOption,{"aria-selected":null})),this.activeOption=null,C(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this;if(e.settings.mode==="single")return;const t=e.controlChildren();t.length&&(e.inputState(),e.close(),e.activeItems=t,P(t,s=>{e.setActiveItemClass(s)}))}inputState(){var e=this;e.control.contains(e.control_input)&&(C(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&C(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var e=this;e.isDisabled||e.isReadOnly||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout(()=>{e.ignoreFocus=!1,e.onFocus()},0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField;return typeof e.sortField=="string"&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,s,r=this,i=this.getSearchOptions();if(r.settings.score&&(s=r.settings.score.call(r,e),typeof s!="function"))throw new Error('Tom Select "score" setting must be a function that returns a function');return e!==r.lastQuery?(r.lastQuery=e,/(.)\1{15,}/.test(e)&&(e=""),t=r.sifter.search(e,Object.assign(i,{score:s})),r.currentResults=t):t=Object.assign({},r.currentResults),r.settings.hideSelected&&(t.items=t.items.filter(o=>{let a=F(o.id);return!(a!==null&&r.items.indexOf(a)!==-1)})),t}refreshOptions(e=!0){var t,s,r,i,o,a,l,c,d,u;const p={},v=[];var h=this,S=h.inputValue();const y=S===h.lastQuery||S==""&&h.lastQuery==null;var g=h.search(S),f=null,m=h.settings.shouldOpen||!1,b=h.dropdown_content;y&&(f=h.activeOption,f&&(d=f.closest("[data-group]"))),i=g.items.length,typeof h.settings.maxOptions=="number"&&(i=Math.min(i,h.settings.maxOptions)),i>0&&(m=!0);const _=(x,w)=>{let T=p[x];if(T!==void 0){let O=v[T];if(O!==void 0)return[T,O.fragment]}let k=document.createDocumentFragment();return T=v.length,v.push({fragment:k,order:w,optgroup:x}),[T,k]};for(t=0;t<i;t++){let x=g.items[t];if(!x)continue;let w=x.id,T=h.options[w];if(T===void 0)continue;let k=te(w),O=h.getOption(k,!0);for(h.settings.hideSelected||O.classList.toggle("selected",h.items.includes(k)),o=T[h.settings.optgroupField]||"",a=Array.isArray(o)?o:[o],s=0,r=a&&a.length;s<r;s++){o=a[s];let R=T.$order,V=h.optgroups[o];if(V===void 0&&typeof h.settings.optionGroupRegister=="function"){var A;(A=h.settings.optionGroupRegister.apply(h,[o]))&&h.registerOptionGroup(A)}V=h.optgroups[o],V===void 0?o="":R=V.$order;
69const[ve,oe]=_(o,R);s>0&&(O=O.cloneNode(!0),C(O,{id:T.$id+"-clone-"+s,"aria-selected":null}),O.classList.add("ts-cloned"),N(O,"active"),h.activeOption&&h.activeOption.dataset.value==w&&d&&d.dataset.group===o.toString()&&(f=O)),oe.appendChild(O),o!=""&&(p[o]=ve)}}h.settings.lockOptgroupOrder&&v.sort((x,w)=>x.order-w.order),l=document.createDocumentFragment(),P(v,x=>{let w=x.fragment,T=x.optgroup;if(!w||!w.children.length)return;let k=h.optgroups[T];if(k!==void 0){let O=document.createDocumentFragment(),R=h.render("optgroup_header",k);j(O,R),j(O,w);let V=h.render("optgroup",{group:k,options:O});j(l,V)}else j(l,w)}),b.innerHTML="",j(b,l),h.settings.highlight&&(Bt(b),g.query.length&&g.tokens.length&&P(g.tokens,x=>{Dt(b,x.regex)}));var E=x=>{let w=h.render(x,{input:S});return w&&(m=!0,b.insertBefore(w,b.firstChild)),w};if(h.loading?E("loading"):h.settings.shouldLoad.call(h,S)?g.items.length===0&&E("no_results"):E("not_loading"),c=h.canCreate(S),c&&(u=E("option_create")),h.hasOptions=g.items.length>0||c,m){if(g.items.length>0){if(!f&&h.settings.mode==="single"&&h.items[0]!=null&&(f=h.getOption(h.items[0])),!b.contains(f)){let x=0;u&&!h.settings.addPrecedence&&(x=1),f=h.selectable()[x]}}else u&&(f=u);e&&!h.isOpen&&(h.open(),h.scrollToOption(f,"auto")),h.setActiveOption(f)}else h.clearActiveOption(),e&&h.isOpen&&h.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const s=this;if(Array.isArray(e))return s.addOptions(e,t),!1;const r=F(e[s.settings.valueField]);return r===null||s.options.hasOwnProperty(r)?!1:(e.$order=e.$order||++s.order,e.$id=s.inputId+"-opt-"+e.$order,s.options[r]=e,s.lastQuery=null,t&&(s.userOptions[r]=t,s.trigger("option_add",r,e)),r)}addOptions(e,t=!1){P(e,s=>{this.addOption(s,t)})}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=F(e[this.settings.optgroupValueField]);return t===null?!1:(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var s;t[this.settings.optgroupValueField]=e,(s=this.registerOptionGroup(t))&&this.trigger("optgroup_add",s,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const s=this;var r,i;const o=F(e),a=F(t[s.settings.valueField]);if(o===null)return;const l=s.options[o];if(l==null)return;if(typeof a!="string")throw new Error("Value must be set in option data");const c=s.getOption(o),d=s.getItem(o);if(t.$order=t.$order||l.$order,delete s.options[o],s.uncacheValue(a),s.options[a]=t,c){if(s.dropdown_content.contains(c)){const u=s._render("option",t);ge(c,u),s.activeOption===c&&s.setActiveOption(u)}c.remove()}d&&(i=s.items.indexOf(o),i!==-1&&s.items.splice(i,1,a),r=s._render("item",t),d.classList.contains("active")&&$(r,"active"),ge(d,r)),s.lastQuery=null}removeOption(e,t){const s=this;e=te(e),s.uncacheValue(e),delete s.userOptions[e],delete s.options[e],s.lastQuery=null,s.trigger("option_remove",e),s.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const s={};P(this.options,(r,i)=>{t(r,i)&&(s[i]=r)}),this.options=this.sifter.items=s,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const s=F(e);if(s===null)return null;const r=this.options[s];if(r!=null){if(r.$div)return r.$div;if(t)return this._render("option",r)}return null}getAdjacent(e,t,s="option"){var r=this,i;if(!e)return null;s=="item"?i=r.controlChildren():i=r.dropdown_content.querySelectorAll("[data-selectable]");for(let o=0;o<i.length;o++)if(i[o]==e)return t>0?i[o+1]:i[o-1];return null}getItem(e){if(typeof e=="object")return e;var t=F(e);return t!==null?this.control.querySelector(`[data-value="${Ee(t)}"]`):null}addItems(e,t){var s=this,r=Array.isArray(e)?e:[e];r=r.filter(o=>s.items.indexOf(o)===-1);const i=r[r.length-1];r.forEach(o=>{s.isPending=o!==i,s.addItem(o,t)})}addItem(e,t){var s=t?[]:["change","dropdown_close"];we(this,s,()=>{var r,i;const o=this,a=o.settings.mode,l=F(e);if(!(l&&o.items.indexOf(l)!==-1&&(a==="single"&&o.close(),a==="single"||!o.settings.duplicates))&&!(l===null||!o.options.hasOwnProperty(l))&&(a==="single"&&o.clear(t),!(a==="multi"&&o.isFull()))){if(r=o._render("item",o.options[l]),o.control.contains(r)&&(r=r.cloneNode(!0)),i=o.isFull(),o.items.splice(o.caretPos,0,l),o.insertAtCaret(r),o.isSetup){if(!o.isPending&&o.settings.hideSelected){let c=o.getOption(l),d=o.getAdjacent(c,1);d&&o.setActiveOption(d)}o.settings.clearAfterSelect&&o.setTextboxValue(),!o.isPending&&!o.settings.closeAfterSelect&&o.refreshOptions(o.isFocused&&a!=="single"),o.settings.closeAfterSelect!=!1&&o.isFull()?o.close():o.isPending||o.positionDropdown(),o.trigger("item_add",l,r),o.isPending||o.updateOriginalInput({silent:t})}
69(!o.isPending||!i&&o.isFull())&&(o.inputState(),o.refreshState())}})}removeItem(e=null,t){const s=this;if(e=s.getItem(e),!e)return;var r,i;const o=e.dataset.value;r=Ae(e),e.remove(),e.classList.contains("active")&&(i=s.activeItems.indexOf(e),s.activeItems.splice(i,1),N(e,"active")),s.items.splice(r,1),s.lastQuery=null,!s.settings.persist&&s.userOptions.hasOwnProperty(o)&&s.removeOption(o,t),r<s.caretPos&&s.setCaret(s.caretPos-1),s.updateOriginalInput({silent:t}),s.refreshState(),s.positionDropdown(),s.trigger("item_remove",o,e)}createItem(e=null,t=()=>{}){arguments.length===3&&(t=arguments[2]),typeof t!="function"&&(t=()=>{});var s=this,r=s.caretPos,i;if(e=e||s.inputValue(),!s.canCreate(e))return F(e)&&this.options[e]&&s.addItem(e),t(),!1;s.lock();var o=!1,a=l=>{if(s.unlock(),!l||typeof l!="object")return t();var c=F(l[s.settings.valueField]);if(typeof c!="string")return t();s.setTextboxValue(),s.addOption(l,!0),s.setCaret(r),s.addItem(c),t(l),o=!0};return typeof s.settings.create=="function"?i=s.settings.create.call(this,e,a):i={[s.settings.labelField]:e,[s.settings.valueField]:e},o||a(i),!0}refreshItems(){var e=this;e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this;e.refreshValidityState();const t=e.isFull(),s=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);const r=e.wrapper.classList;r.toggle("focus",e.isFocused),r.toggle("disabled",e.isDisabled),r.toggle("readonly",e.isReadOnly),r.toggle("required",e.isRequired),r.toggle("invalid",!e.isValid),r.toggle("locked",s),r.toggle("full",t),r.toggle("input-active",e.isFocused&&!e.isInputHidden),r.toggle("dropdown-active",e.isOpen),r.toggle("has-options",Ht(e.options)),r.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this;e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return this.settings.maxItems!==null&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this;var s,r;const i=t.input.querySelector('option[value=""]');if(t.is_select_tag){let l=function(c,d,u){return c||(c=D('<option value="'+ue(d)+'">'+ue(u)+"</option>")),c!=i&&t.input.append(c),o.push(c),(c!=i||a>0)&&(c.selected=!0),c};const o=[],a=t.input.querySelectorAll("option:checked").length;t.input.querySelectorAll("option:checked").forEach(c=>{c.selected=!1}),t.items.length==0&&t.settings.mode=="single"?l(i,"",""):t.items.forEach(c=>{if(s=t.options[c],r=s[t.settings.labelField]||"",o.includes(s.$option)){const d=t.input.querySelector(`option[value="${Ee(c)}"]:not(:checked)`);l(d,c,r)}else s.$option=l(s.$option,c,r)})}else t.input.value=t.getValue();t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this;e.isLocked||e.isOpen||e.settings.mode==="multi"&&e.isFull()||(e.isOpen=!0,C(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),X(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),X(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,s=t.isOpen;e&&(t.setTextboxValue(),t.settings.mode==="single"&&t.items.length&&t.inputState()),t.isOpen=!1,C(t.focus_node,{"aria-expanded":"false"}),X(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),s&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if(this.settings.dropdownParent==="body"){var e=this.control,t=e.getBoundingClientRect(),s=e.offsetHeight+t.top+window.scrollY,r=t.left+window.scrollX;X(this.dropdown,{width:t.width+"px",top:s+"px",left:r+"px"})}}clear(e){var t=this;if(t.items.length){var s=t.controlChildren();P(s,r=>{t.removeItem(r,!0)}),t.inputState(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,s=t.caretPos,r=t.control;r.insertBefore(e,r.children[s]||null),t.setCaret(s+1)}deleteSelection(e){var t,s,r,i,o=this;t=e&&e.keyCode===Le?-1:1,s=$t(o.control_input);const a=[];if(o.activeItems.length)i=xe(o.activeItems,t),r=Ae(i),t>0&&r++,P(o.activeItems,l=>a.push(l));else if((o.isFocused||o.settings.mode==="single")&&o.items.length){const l=o.controlChildren();let c;t<0&&s.start===0&&s.length===0?c=l[o.caretPos-1]:t>0&&s.start===o.inputValue().length&&(c=l[o.caretPos]),c!==void 0&&a.push(c)}if(!o.shouldDelete(a,e))return!1;for(I(e,!0),typeof r<"u"&&o.setCaret(r);a.length;)o.removeItem(a.pop());return o.inputState(),o.positionDropdown(),o.refreshOptions(!1),!0}shouldDelete(e,t){const s=e.map(r=>r.dataset.value);return!(!s.length||typeof this.settings.onDelete=="function"&&this.settings.onDelete.call(this,s,t)===!1)}advanceSelection(e,t){var s,r,i=this;i.rtl&&(e*=-1),!i.inputValue().length&&(z(G,t)||z("shiftKey",t)?(s=i.getLastActive(e),s?s.classList.contains("active")?r=i.getAdjacent(s,e,"item"):r=s:e>0?r=i.control_input.nextElementSibling:r=i.control_input.previousElementSibling,r&&(r.classList.contains("active")&&i.removeActiveItem(s),i.setActiveItem
69Class(r))):i.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active");if(t)return t;var s=this.control.querySelectorAll(".active");if(s)return xe(s,e)}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(e=this.isReadOnly||this.isDisabled){this.isLocked=e,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(e){this.focus_node.tabIndex=e?-1:this.tabIndex,this.isDisabled=e,this.input.disabled=e,this.control_input.disabled=e,this.setLocked()}setReadOnly(e){this.isReadOnly=e,this.input.readOnly=e,this.control_input.readOnly=e,this.setLocked()}destroy(){var e=this,t=e.revertSettings;e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,N(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var s,r;const i=this;if(typeof this.settings.render[e]!="function"||(r=i.settings.render[e].call(this,t,ue),!r))return null;if(r=D(r),e==="option"||e==="option_create"?t[i.settings.disabledField]?C(r,{"aria-disabled":"true"}):C(r,{"data-selectable":""}):e==="optgroup"&&(s=t.group[i.settings.optgroupValueField],C(r,{"data-group":s}),t.group[i.settings.disabledField]&&C(r,{"data-disabled":""})),e==="option"||e==="item"){const o=te(t[i.settings.valueField]);C(r,{"data-value":o}),e==="item"?($(r,i.settings.itemClass),C(r,{"data-ts-item":""})):($(r,i.settings.optionClass),C(r,{role:"option",id:t.$id}),t.$div=r,i.options[o]=t)}return r}_render(e,t){const s=this.render(e,t);if(s==null)throw"HTMLElement expected";return s}clearCache(){P(this.options,e=>{e.$div&&(e.$div.remove(),delete e.$div)})}uncacheValue(e){const t=this.getOption(e);t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,s){var r=this,i=r[t];r[t]=function(){var o,a;return e==="after"&&(o=i.apply(r,arguments)),a=s.apply(r,arguments),e==="instead"?a:(e==="before"&&(o=i.apply(r,arguments)),o)}}}const Wt=(n,e,t,s)=>{n.addEventListener(e,t,s)};function Xt(){Wt(this.input,"change",()=>{this.sync()})}const Gt=n=>typeof n>"u"||n===null?null:Jt(n),Jt=n=>typeof n=="boolean"?n?"1":"0":n+"",Oe=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},Qt=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(es(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},es=n=>typeof n=="string"&&n.indexOf("<")>-1;function ts(n){var e=this,t=e.onOptionSelect;e.settings.hideSelected=!1;const s=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},n);
69var r=function(a,l){l?(a.checked=!0,s.uncheckedClassNames&&a.classList.remove(...s.uncheckedClassNames),s.checkedClassNames&&a.classList.add(...s.checkedClassNames)):(a.checked=!1,s.checkedClassNames&&a.classList.remove(...s.checkedClassNames),s.uncheckedClassNames&&a.classList.add(...s.uncheckedClassNames))},i=function(a){setTimeout(()=>{var l=a.querySelector("input."+s.className);l instanceof HTMLInputElement&&r(l,a.classList.contains("selected"))},1)};e.hook("after","setupTemplates",()=>{var o=e.settings.render.option;e.settings.render.option=(a,l)=>{var c=Qt(o.call(e,a,l)),d=document.createElement("input");s.className&&d.classList.add(s.className),d.addEventListener("click",function(p){Oe(p)}),d.type="checkbox";const u=Gt(a[e.settings.valueField]);return r(d,!!(u&&e.items.indexOf(u)>-1)),c.prepend(d),c}}),e.on("item_remove",o=>{var a=e.getOption(o);a&&(a.classList.remove("selected"),i(a))}),e.on("item_add",o=>{var a=e.getOption(o);a&&i(a)}),e.hook("instead","onOptionSelect",(o,a)=>{if(a.classList.contains("selected")){a.classList.remove("selected"),e.removeItem(a.dataset.value),e.refreshOptions(),Oe(o,!0);return}t.call(e,o,a),i(a)})}const ss=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(ns(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},ns=n=>typeof n=="string"&&n.indexOf("<")>-1;function rs(n){const e=this,t=Object.assign({className:"clear-button",title:"Clear All",role:"button",tabindex:0,html:s=>`<div class="${s.className}" title="${s.title}" role="${s.role}" tabindex="${s.tabindex}">×</div>`},n);e.on("initialize",()=>{var s=ss(t.html(t));s.addEventListener("click",r=>{e.isLocked||(e.clear(),e.settings.mode==="single"&&e.settings.allowEmptyOption&&e.addItem(""),e.refreshOptions(!1),r.preventDefault(),r.stopPropagation())}),e.control.appendChild(s)})}const is=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},Z=(n,e,t,s)=>{n.addEventListener(e,t,s)},os=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},as=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(ls(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},ls=n=>typeof n=="string"&&n.indexOf("<")>-1,cs=(n,e)=>{os(e,(t,s)=>{t==null?n.removeAttribute(s):n.setAttribute(s,""+t)})},ds=(n,e)=>{var t;(t=n.parentNode)==null||t.insertBefore(e,n.nextSibling)},us=(n,e)=>{var t;(t=n.parentNode)==null||t.insertBefore(e,n)},ps=(n,e)=>{do{var t;if(e=(t=e)==null?void 0:t.previousElementSibling,n==e)return!0}while(e&&e.previousElementSibling);return!1};function fs(){var n=this;if(n.settings.mode!=="multi")return;var e=n.lock,t=n.unlock;let s=!0,r;n.hook("after","setupTemplates",()=>{var i=n.settings.render.item;n.settings.render.item=(o,a)=>{const l=as(i.call(n,o,a));cs(l,{draggable:"true"});const c=S=>{s||is(S),S.stopPropagation()},d=S=>{r=l,setTimeout(()=>{l.classList.add("ts-dragging")},0)},u=S=>{S.preventDefault(),l.classList.add("ts-drag-over"),v(l,r)},p=()=>{l.classList.remove("ts-drag-over")},v=(S,y)=>{y!==void 0&&(ps(y,l)?ds(S,y):us(S,y))},h=()=>{var S;document.querySelectorAll(".ts-drag-over").forEach(g=>g.classList.remove("ts-drag-over")),(S=r)==null||S.classList.remove("ts-dragging"),r=void 0;var y=[];n.control.querySelectorAll("[data-value]").forEach(g=>{if(g.dataset.value){let f=g.dataset.value;f&&y.push(f)}}),n.setValue(y)};return Z(l,"mousedown",c),Z(l,"dragstart",d),Z(l,"dragenter",u),Z(l,"dragover",u),Z(l,"dragleave",p),Z(l,"dragend",h),l}}),n.hook("instead","lock",()=>(s=!1,e.call(n))),n.hook("instead","unlock",()=>(s=!0,t.call(n)))}const ms=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},hs=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(gs(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},gs=n=>typeof n=="string"&&n.indexOf("<")>-1;function ys(n){const e=this,t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:s=>'<div class="'+s.headerClass+'"><div class="'+s.titleRowClass+'"><span class="'+s.labelClass+'">'+s.title+'</span><a class="'+s.closeClass+'">×</a></div></div>'},n);e.on("initialize",()=>{var s=hs(t.html(t)),r=s.querySelector("."+t.closeClass);r&&r.addEventListener("click",i=>{ms(i,!0),e.close()}),e.dropdown.insertBefore(s,e.dropdown.firstChild)})}const vs=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},bs=(n,...e)=>{var t=Ss(e);n=_s(n),n.map(s=>{t.map(r=>{s.classList.remove(r)})})},Ss=n=>{var e=[];return vs(n,t=>{typeof t=="string"&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},_s=n=>(Array.isArray(n)||(n=[n]),n),ws=(n,e)=>{if(!n)return-1;e=e||n.nodeName;for(var t=0;n=n.previousElementSibling;)n.matches(e)&&t++;return t};function Es(){var n=this;n.hook("instead","setCaret",e=>{n.settings.mode==="single"||!n.control.contains(n.control_input)?e=n.items.length:(e=Math.max(0,Math.min(n.items.length,e)),e!=n.caretPos&&!n.isPending&&n.controlChildren().forEac
69h((t,s)=>{s<e?n.control_input.insertAdjacentElement("beforebegin",t):n.control.appendChild(t)})),n.caretPos=e}),n.hook("instead","moveCaret",e=>{if(!n.isFocused)return;const t=n.getLastActive(e);if(t){const s=ws(t);n.setCaret(e>0?s+1:s),n.setActiveItem(),bs(t,"last-active")}else n.setCaret(n.caretPos+e)})}const xs=27,As=9,Ls=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},ks=(n,e,t,s)=>{n.addEventListener(e,t,s)},Cs=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},Pe=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(Ts(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},Ts=n=>typeof n=="string"&&n.indexOf("<")>-1,Is=(n,...e)=>{var t=Os(e);n=Ps(n),n.map(s=>{t.map(r=>{s.classList.add(r)})})},Os=n=>{var e=[];return Cs(n,t=>{typeof t=="string"&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Ps=n=>(Array.isArray(n)||(n=[n]),n);function qs(){const n=this;n.settings.shouldOpen=!0,n.hook("before","setup",()=>{var e;n.focus_node=n.control,Is(n.control_input,"dropdown-input");const t=Pe('<div class="dropdown-input-wrap">');t.append(n.control_input),n.dropdown.insertBefore(t,n.dropdown.firstChild);const s=Pe('<input class="items-placeholder" tabindex="-1" />');s.placeholder=n.settings.placeholder||"",n.control.append(s);const r=(e=n.input)==null?void 0:e.getAttribute("aria-label");r&&s.setAttribute("aria-label",r)}),n.on("initialize",()=>{n.control_input.addEventListener("keydown",t=>{switch(t.keyCode){case xs:n.isOpen&&(Ls(t,!0),n.close()),n.clearActiveItems();return;case As:n.focus_node.tabIndex=-1;break}return n.onKeyDown.call(n,t)}),n.on("blur",()=>{n.focus_node.tabIndex=n.isDisabled?-1:n.tabIndex}),n.on("dropdown_open",()=>{n.control_input.focus()});const e=n.onBlur;n.hook("instead","onBlur",t=>{if(!(t&&t.relatedTarget==n.control_input))return e.call(n)}),ks(n.control_input,"blur",()=>n.onBlur()),n.hook("before","close",()=>{n.isOpen&&n.focus_node.focus({preventScroll:!0})})})}const J=(n,e,t,s)=>{n.addEventListener(e,t,s)};function Ms(){var n=this;n.on("initialize",()=>{var e=document.createElement("span"),t=n.control_input;e.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",n.wrapper.appendChild(e);var s=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"];for(const i of s)e.style[i]=t.style[i];var r=()=>{e.textContent=t.value,t.style.width=e.clientWidth+"px"};r(),n.on("update item_add item_remove",r),J(t,"input",r),J(t,"keyup",r),J(t,"blur",r),J(t,"update",r)})}function $s(){var n=this,e=n.deleteSelection;this.hook("instead","deleteSelection",t=>n.activeItems.length?e.call(n,t):!1)}function Fs(){this.hook("instead","setActiveItem",()=>{}),this.hook("instead","selectAll",()=>{})}const qe=37,Hs=39,Ds=(n,e,t)=>{for(;n&&n.matches;){if(n.matches(e))return n;n=n.parentNode}},Bs=(n,e)=>{if(!n)return-1;e=e||n.nodeName;for(var t=0;n=n.previousElementSibling;)n.matches(e)&&t++;return t};function Rs(){var n=this,e=n.onKeyDown;n.hook("instead","onKeyDown",t=>{var s,r,i,o;if(!n.isOpen||!(t.keyCode===qe||t.keyCode===Hs))return e.call(n,t);n.ignoreHover=!0,o=Ds(n.activeOption,"[data-group]"),s=Bs(n.activeOption,"[data-selectable]"),o&&(t.keyCode===qe?o=o.previousSibling:o=o.nextSibling,o&&(i=o.querySelectorAll("[data-selectable]"),r=i[Math.min(i.length-1,s)],r&&n.setActiveOption(r)))})}const Vs=n=>(n+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Me=(n,e=!1)=>{n&&(n.preventDefault(),e&&n.stopPropagation())},$e=(n,e,t,s)=>{n.addEventListener(e,t,s)},Fe=n=>{if(n.jquery)return n[0];if(n instanceof HTMLElement)return n;if(Ns(n)){var e=document.createElement("template");return e.innerHTML=n.trim(),e.content.firstChild}return document.querySelector(n)},Ns=n=>typeof n=="string"&&n.indexOf("<")>-1;function zs(n){const e=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},n);var t=this;if(e.append){var s='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+Vs(e.title)+'">'+e.label+"</a>";t.hook("after","setupTemplates",()=>{var r=t.settings.render.item;t.settings.render.item=(i,o)=>{var a=Fe(r.call(t,i,o)),l=Fe(s);return a.appendChild(l),$e(l,"mousedown",c=>{Me(c,!0)}),$e(l,"click",c=>{t.isLocked||(Me(c,!0),!t.isLocked&&t.shouldDelete([a],c)&&(t.removeItem(a),t.refreshOptions(!1),t.inputState()))}),a}})}}function js(n){const e=this,t=Object.assign({text:s=>s[e.settings.labelField]},n);e.on("item_remove",function(s){if(e.isFocused&&e.control_input.value.trim()===""){var r=e.options[s];r&&e.setTextboxValue(t.text.call(e,r))}})}const Zs=(n,e)=>{if(Array.isArray(n))n.forEach(e);else for(var t in n)n.hasOwnProperty(t)&&e(n[t],t)},Us=(n,...e)=>{var t=Ks(e);n=Ys(n),n.map(s=>{t.map(r=>{s.classList.add(r)})})},Ks=n=>{var e=[];return Zs(n,t=>{typeof t=="string"&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Ys=n=>(Array.isArray(n)||(n=[n]),n);function Ws(){const n=this,e=n.canLoad,t=n.clearActiveOption,s=n.loadCallback;var r={},i,o=!1,a,l=[];
69if(n.settings.shouldLoadMore||(n.settings.shouldLoadMore=()=>{if(i.clientHeight/(i.scrollHeight-i.scrollTop)>.9)return!0;if(n.activeOption){var p=n.selectable(),v=Array.from(p).indexOf(n.activeOption);if(v>=p.length-2)return!0}return!1}),!n.settings.firstUrl)throw"virtual_scroll plugin requires a firstUrl() method";n.settings.sortField=[{field:"$order"},{field:"$score"}];const c=u=>typeof n.settings.maxOptions=="number"&&i.children.length>=n.settings.maxOptions?!1:!!(u in r&&r[u]),d=(u,p)=>n.items.indexOf(p)>=0||l.indexOf(p)>=0;n.setNextUrl=(u,p)=>{r[u]=p},n.getUrl=u=>{if(u in r){const p=r[u];return r[u]=!1,p}return n.clearPagination(),n.settings.firstUrl.call(n,u)},n.clearPagination=()=>{r={}},n.hook("instead","clearActiveOption",()=>{if(!o)return t.call(n)}),n.hook("instead","canLoad",u=>u in r?c(u):e.call(n,u)),n.hook("instead","loadCallback",(u,p)=>{if(!o)n.clearOptions(d);else if(a){const v=u[0];v!==void 0&&(a.dataset.value=v[n.settings.valueField])}s.call(n,u,p),o=!1}),n.hook("after","refreshOptions",()=>{const u=n.lastValue;var p;c(u)?(p=n.render("loading_more",{query:u}),p&&(p.setAttribute("data-selectable",""),a=p)):u in r&&!i.querySelector(".no-results")&&(p=n.render("no_more_results",{query:u})),p&&(Us(p,n.settings.optionClass),i.append(p))}),n.on("initialize",()=>{l=Object.keys(n.options),i=n.dropdown_content,n.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},n.settings.render),i.addEventListener("scroll",()=>{n.settings.shouldLoadMore.call(n)&&c(n.lastValue)&&(o||(o=!0,n.load.call(n,n.lastValue)))})})}M.define("change_listener",Xt);M.define("checkbox_options",ts);M.define("clear_button",rs);M.define("drag_drop",fs);M.define("dropdown_header",ys);M.define("caret_position",Es);M.define("dropdown_input",qs);M.define("input_autogrow",Ms);M.define("no_backspace_delete",$s);M.define("no_active_items",Fs);M.define("optgroup_columns",Rs);M.define("remove_button",zs);M.define("restore_on_backspace",js);M.define("virtual_scroll",Ws);const He="data-ts-initialized";class K{static DEFAULTS={selector:".select2",placeholder:"Seçiniz",maxOptions:null};init(){this._initIn(document),U.on("admin:selectEnhance",e=>{this._initIn(e?.container??document)})}_initIn(e){e.querySelectorAll(`${K.DEFAULTS.selector}:not([${He}])`).forEach(t=>this._createInstance(t))}_createInstance(e){e.setAttribute(He,"1"),new M(e,{placeholder:e.dataset.placeholder||K.DEFAULTS.placeholder,maxOptions:K.DEFAULTS.maxOptions,plugins:["dropdown_input"],render:{no_results:()=>'<div class="no-results">Sonuç bulunamadı</div>'}})}}const Xs=new K,Gs={browseModal:null,saveModal:null,categorySelectorEl:null,csrfToken:document.querySelector('meta[name="csrf-token"]')?.content??"",_pendingActivateBtn:null,_previewCapture:null,init(){this.browseModal=document.getElementById("designTemplatesBrowseModal"),this.saveModal=document.getElementById("designTemplatesSaveModal"),this.categorySelectorEl=document.getElementById("dtCategorySelectorModal"),!(!this.browseModal&&!this.saveModal)&&(this._initBrowseModal(),this._initSaveTriggers(),this._initCategorySelector())},_initBrowseModal(){const n=this.browseModal;n&&(n.addEventListener("show.bs.modal",e=>{const t=e.relatedTarget,s=t?.dataset?.pageType??n.dataset.defaultPageType??"post_detail";n.dataset.currentCategoryId=t?.dataset?.categoryId??"",this._loadBrowseContent(n,s)}),n.addEventListener("click",e=>{const t=e.target.closest(".dt-type-filter");if(t){this._applyTypeFilter(n,t);return}const s=e.target.closest(".dt-activate-btn");if(s){this._activateTemplate(s,n);return}const r=e.target.closest(".dt-export-btn");if(r){this._exportTemplate(r);return}const i=e.target.closest(".dt-clone-btn");if(i){this._cloneTemplate(i,n);return}if(e.target.closest(".dt-import-btn")){n.querySelector("#dtImportFile")?.click();return}const a=e.target.closest(".dt-delete-btn");if(a){this._deleteTemplate(a,n);return}}),n.addEventListener("change",e=>{e.target.id==="dtImportFile"&&this._importFile(e.target,n)}))},_loadBrowseContent(n,e){const t=n.querySelector(".design-templates-modal-body");if(!t)return;const s=Habersoft?.adminRoutes?.["design-templates.index"];if(!s){t.innerHTML='<div class="p-4 text-danger">
69Route tanımlanamadı. Sayfayı yenileyin.</div>';return}t.innerHTML='<div class="p-5 text-center text-muted">Yükleniyor...</div>',fetch(`${s}?page_type=${e}`,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}).then(r=>{t.innerHTML=r}).catch(r=>{t.innerHTML=`<div class="p-4 text-danger">Yüklenemedi: ${r.message}</div>`})},_applyTypeFilter(n,e){n.querySelectorAll(".dt-type-filter").forEach(s=>s.classList.remove("active")),e.classList.add("active");const t=e.dataset.typeId;n.querySelectorAll(".dt-card-wrap").forEach(s=>{const r=!t||s.dataset.typeId===t;s.style.display=r?"":"none"})},async _activateTemplate(n,e){if(n.dataset.pageType==="category"){this._openCategorySelector(n);return}const t=n.dataset.templateName;confirm(`"${t}" Åablonunu aktif etmek istediÄinizden emin misiniz? 70 71Mevcut tasarım tamamen kaldırılıp bu Åablon uygulanacaktır.`)&&(n.disabled=!0,n.innerHTML='<span class="spinner-border spinner-border-sm me-1"></span> Uygulanıyor...',await this._maybeExportCurrent(n.dataset.pageType,null),fetch(n.dataset.activateUrl,{method:"POST",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}}).then(s=>s.json()).then(s=>{s.status?(alert("Åablon baÅarıyla uygulandı. Sayfa yenileniyor..."),window.location.reload()):(alert(s.message??"Hata oluÅtu."),n.disabled=!1,n.innerHTML='<i class="fa fa-check me-1"></i> Aktif Et')}).catch(()=>{alert("BaÄlantı hatası."),n.disabled=!1,n.innerHTML='<i class="fa fa-check me-1"></i> Aktif Et'}))},_deleteTemplate(n,e){const t=n.dataset.templateName;confirm(`"${t}" Åablonunu silmek istediÄinizden emin misiniz?`)&&(n.disabled=!0,fetch(n.dataset.deleteUrl,{method:"DELETE",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}}).then(s=>s.json()).then(s=>{s.status?n.closest(".dt-card-wrap")?.remove():(alert(s.message??"Silinemedi."),n.disabled=!1)}).catch(()=>{alert("BaÄlantı hatası."),n.disabled=!1}))},_maybeExportCurrent(n,e){const t=this.browseModal?.querySelector("#dtExportBeforeActivate");if(!t||!t.checked)return Promise.resolve();let s=Habersoft?.adminRoutes?.["design-templates.export-current"];if(!s)return Promise.resolve();if(s+=`?page_type=${encodeURIComponent(n)}`,n==="category"){if(!e)return Promise.resolve();s+=`&category_id=${encodeURIComponent(e)}`}return fetch(s,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(r=>r.ok?r.blob().then(i=>({b:i,r})):null).then(r=>{if(!r)return;const o=(r.r.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/);this._triggerDownload(r.b,o?o[1]:"tasarim-yedek.json")}).catch(()=>{})},_cloneTemplate(n,e){const t=n.dataset.templateName;if(!confirm(`"${t}" Åablonunu kendi Åablonunuza kopyalamak istiyor musunuz? 72 73Kopya düzenlenebilir ve silinebilir olur.`))return;n.disabled=!0;const s=e.querySelector(".design-templates-browser")?.dataset?.pageType??"post_detail";fetch(n.dataset.cloneUrl,{method:"POST",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}}).then(r=>r.json()).then(r=>{r.status?(this._loadBrowseContent(e,s),alert(r.message??"Åablon kopyalandı.")):(alert(r.message??"Kopyalanamadı."),n.disabled=!1)}).catch(()=>{alert("BaÄlantı hatası."),n.disabled=!1})},_exportTemplate(n){const e=n.dataset.exportUrl;e&&fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(t=>t.ok?t.blob().then(s=>({b:s,r:t})):Promise.reject()).then(t=>{const r=(t.r.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/);this._triggerDownload(t.b,r?r[1]:"sablon.json")}).catch(()=>alert("DıÅa aktarılamadı."))},_importFile(n,e){const t=n.files?.[0];if(!t)return;const s=Habersoft?.adminRoutes?.["design-templates.import"];if(!s){n.value="",alert("İçe aktarma adresi bulunamadı.");return}const r=e.querySelector(".design-templates-browser")?.dataset?.pageType??"post_detail",i=new FormData;i.append("file",t),i.append("page_type",r),i.append("_token",this.csrfToken),fetch(s,{method:"POST",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json"},body:i}).then(o=>o.json()).then(o=>{n.value="",o.status?(this._loadBrowseContent(e,r),alert(o.message??"Åablon içe aktarıldı.")):alert(o.message??"İçe aktarılamadı.")}).catch(()=>{n.value="",alert("BaÄlantı hatası.")})},_triggerDownload(n,e){const t=URL.createObjectURL(n),s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(t),4e3)}
73,_initCategorySelector(){const n=this.categorySelectorEl;if(!n)return;const e=n.querySelector("#dtSelectAllCategories");e&&e.addEventListener("change",()=>{n.querySelectorAll('.dt-cat-item:not([style*="none"]) .dt-category-check').forEach(r=>{r.checked=e.checked})});const t=n.querySelector("#dtCategorySearch");t&&t.addEventListener("input",()=>{const r=t.value.toLowerCase().trim();n.querySelectorAll(".dt-cat-item").forEach(i=>{const o=i.querySelector("label")?.textContent?.toLowerCase()??"";i.style.display=!r||o.includes(r)?"":"none"}),e&&(e.checked=!1)});const s=n.querySelector("#dtCategoryApplyBtn");s&&s.addEventListener("click",()=>this._submitCategoryActivation()),n.addEventListener("show.bs.modal",()=>{const r=document.querySelectorAll(".modal.show").length;n.style.zIndex=1055+(r+1)*10}),n.addEventListener("shown.bs.modal",()=>{const r=parseInt(n.style.zIndex)||1065,i=document.querySelectorAll(".modal-backdrop");i.length>1&&(i[i.length-1].style.zIndex=r-1)})},_openCategorySelector(n){const e=this.categorySelectorEl;if(!e)return;this._pendingActivateBtn=n;const t=e.querySelector("#dtCategoryList"),s=e.querySelector("#dtCategoryApplyBtn"),r=e.querySelector("#dtSelectAllCategories"),i=e.querySelector("#dtCategorySearch");t&&(t.innerHTML='<div class="text-center text-muted py-3 fs-13">Yükleniyor...</div>'),r&&(r.checked=!1),i&&(i.value=""),s&&(s.disabled=!1,s.textContent="Uygula");const o=String(this.browseModal?.dataset?.currentCategoryId??""),a=Habersoft?.adminRoutes?.["design-templates.categories"];a?fetch(a,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(l=>l.json()).then(l=>{if(t){if(!l.length){t.innerHTML='<div class="text-muted p-2 fs-13">Kayıtlı kategori bulunamadı.</div>';return}t.innerHTML='<div class="row g-0">'+l.map(c=>{const d=o&&String(c.id)===o?"checked":"";return`<div class="col-6 dt-cat-item"> 74 <label class="d-flex align-items-center gap-2 px-2 py-1 c-pointer fs-13 text-truncate" style="max-width:100%;" title="${c.title}"> 75 <input class="form-check-input flex-shrink-0 dt-category-check m-0" type="checkbox" value="${c.id}" ${d}> 76 <span class="text-truncate">${c.title}</span> 77 </label> 78 </div>`}).join("")+"</div>"}}).catch(()=>{t&&(t.innerHTML='<div class="text-danger p-2 fs-13">Kategoriler yüklenemedi.</div>')}):t&&(t.innerHTML='<div class="text-danger p-2">Kategoriler yüklenemedi.</div>'),bootstrap.Modal.getOrCreateInstance(e).show()},async _submitCategoryActivation(){const n=this.categorySelectorEl,e=this._pendingActivateBtn;if(!n||!e)return;const t=[...n.querySelectorAll(".dt-category-check:checked")];if(!t.length){alert("En az bir kategori seçmelisiniz.");return}const s=n.querySelector("#dtCategoryApplyBtn");s&&(s.disabled=!0,s.textContent="Uygulanıyor..."),await this._maybeExportCurrent("category",this.browseModal?.dataset?.currentCategoryId);const r=new URLSearchParams;t.forEach(i=>r.append("category_ids[]",i.value)),fetch(e.dataset.activateUrl,{method:"POST",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:r.toString()}).then(i=>i.json()).then(i=>{bootstrap.Modal.getInstance(n)?.hide(),i.status?(alert("Åablon baÅarıyla uygulandı. Sayfa yenileniyor..."),window.location.reload()):(alert(i.message??"Hata oluÅtu."),s&&(s.disabled=!1,s.textContent="Uygula"))}).catch(()=>{alert("BaÄlantı hatası."),s&&(s.disabled=!1,s.textContent="Uygula")})},_waitForImages(n=1e4){const e=Array.from(document.images).filter(t=>!t.complete);return e.length?Promise.all(e.map(t=>new Promise(s=>{let r=!1;const i=()=>{r||(r=!0,s())};t.addEventListener("load",i,{once:!0}),t.addEventListener("error",i,{once:!0}),setTimeout(i,n)}))):Promise.resolve()},_scrollThenCapture(){return new Promise(n=>{const e=document.body.style.overflow,t=document.documentElement.style.overflow;document.body.style.overflow="",document.documentElement.style.overflow="";const s=Math.max(Math.floor(window.innerHeight/2),300),r=350,i=600,o=4;let a=0,l=0,c=0;const d=()=>{window.scrollTo(0,0),setTimeout(()=>{document.body.style.overflow=e,document.documentElement.style.overflow=t,n()},400)},u=()=>{const p=document.documentElement.scrollHeight;if(a<p-1){a=Math.min(a+s,p),window.scrollTo(0,a),setTimeout(u,r);return}if(p!==l){l=p,c=0,setTimeout(u,i);return}if(c++,c<o){setTimeout(u,i);return}this._waitForImages().then(d)};u()}).then(()=>this._capturePreview())},_setPreviewStatus(n){const e={scrolling:"Sayfa taranıyor, lütfen bekleyin...",loading:"Ãnizleme oluÅturuluyor...",uploading:"Ãnizleme yükleniyor..."},t=this.saveModal?.querySelector("#dtFooterStatus"),s=t?.querySelector(".dt-footer-status-text");!t||!s||(e[n]?(s.textContent=e[n],t.style.display="flex"):t.style.display="none")},_capturePreview(){this._setPreviewStatus("loading");const n=document.querySelector("main")||document.body,e=window.getComputedStyle(document.body).backgroundColor,t=!e||e==="transparent"||e==="rgba(0, 0, 0, 0)"?"#f8f9fa":e;return Xe(async()=>{const{default:s}
78=await import("./html2canvas.esm-BfxBtG_O.js");return{default:s}},[]).then(({default:s})=>s(n,{useCORS:!0,allowTaint:!0,scale:1,logging:!1,imageTimeout:8e3,backgroundColor:t,onclone:r=>{const i=[".modal",".modal-backdrop","[data-html2canvas-ignore]",".fast-admin-control",".copyright",".module-settings-container",".setting-buttons"];r.querySelectorAll(i.join(",")).forEach(o=>o.remove()),r.body.style.overflow="visible",r.documentElement.style.overflow="visible"}})).then(s=>new Promise(r=>{s.toBlob(i=>r(i),"image/webp",.8)}))},_showPreviewThumbnail(n){const e=this.saveModal?.querySelector("#dtPreviewBox"),t=this.saveModal?.querySelector(".dt-preview-img");if(!e||!t)return;if(t.dataset.objectUrl&&(URL.revokeObjectURL(t.dataset.objectUrl),t.dataset.objectUrl="",t.removeAttribute("src"),t.removeAttribute("data-lightbox-source")),!n){e.style.display="none";return}const s=URL.createObjectURL(n);t.src=s,t.dataset.objectUrl=s,t.dataset.lightboxSource=s,e.style.display=""},_uploadPreview(n,e){const t=new FormData;return t.append("preview",e,"preview.webp"),t.append("_token",this.csrfToken),fetch(n,{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:t}).catch(()=>null)},_initSaveTriggers(){const n=this.saveModal;if(!n)return;let e=!1;n.addEventListener("show.bs.modal",s=>{const r=s.relatedTarget,i=r?.dataset?.pageType??"post_detail",o=r?.dataset?.categoryId??"";n.dataset.currentPageType=i,n.dataset.currentCategoryId=o;const a=n.querySelector(".dt-page-type-label");if(a){const p={post_detail:"Haber Detay",homepage:"Anasayfa",category:"Kategori"};a.textContent=p[i]??i}e||(this._loadTypeChips(n),e=!0);const l=n.querySelector("#dtTypeNameInput");l&&(l.value="");const c=n.querySelector("#dtNewTypeCheck");c&&(c.checked=!1),this._refreshTypeUi(n);const d=n.querySelector("#dtSaveConfirmBtn");d&&(d.disabled=!0,d.dataset.originalText=d.dataset.originalText||d.textContent.trim()||"Kaydet",d.textContent="Ãnizleme hazırlanıyor..."),this._showPreviewThumbnail(null),this._setPreviewStatus("scrolling");const u=p=>(d&&(d.disabled=!1,d.textContent=d.dataset.originalText||"Kaydet"),this._setPreviewStatus("done"),this._showPreviewThumbnail(p),p);this._previewCapture=this._scrollThenCapture().then(u).catch(()=>u(null))});const t=n.querySelector("#dtSaveConfirmBtn");t&&t.addEventListener("click",()=>this._saveTemplate(n)),n.addEventListener("hidden.bs.modal",()=>{this._showPreviewThumbnail(null),this._setPreviewStatus("done")})},_loadTypeChips(n){const e=Habersoft?.adminRoutes?.["design-templates.types"],t=n.querySelector("#dtTypeChips");if(!e){t&&(t.innerHTML='<span class="text-muted fs-13">Tür listesi yüklenemedi.</span>');return}const s=n.querySelector("#dtTypeNameInput");s&&!s.dataset.bound&&(s.dataset.bound="1",s.addEventListener("input",()=>this._refreshTypeUi(n))),fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(r=>r.json()).then(r=>{if(t){if(t.innerHTML="",!r.length){t.innerHTML='<span class="text-muted fs-13">Henüz tür yok. Yazıp yeni tür oluÅturabilirsiniz.</span>';return}r.forEach(i=>{const o=document.createElement("button");o.type="button",o.className="btn btn-outline-secondary dt-type-chip",o.style.cssText="font-size:11px; padding:2px 9px; line-height:1.5; border-radius:6px;",o.dataset.name=i.name,o.textContent=i.name,o.addEventListener("click",()=>{const a=n.querySelector("#dtTypeNameInput");a&&(a.value=i.name,this._refreshTypeUi(n))}),t.appendChild(o)}),this._refreshTypeUi(n)}}).catch(()=>{t&&(t.innerHTML='<span class="text-danger fs-13">Türler yüklenemedi.</span>')})},_normalizeType(n){if(!n)return"";const e={İ:"i",I:"i",ı:"i",Å:"s",Å:"s",Ã:"c",ç:"c",Ä:"g",Ä:"g",Ã:"o",ö:"o",Ã:"u",ü:"u"};return n.replace(/[İIıÅÅÃçÄÄÃöÃü]/g,t=>e[t]||t).toLowerCase().trim().replace(/\s+/g," ")},_refreshTypeUi(n){const e=n.querySelector("#dtTypeNameInput"),t=n.querySelector("#dtNewTypeCheck"),s=n.querySelector("#dtNewTypeWrap"),r=n.querySelector("#dtTypeMatchHint"),i=n.querySelector("#dtTypeChips");if(!e)return;const o=this._normalizeType(e.value);let a=!1;i?.querySelectorAll(".dt-type-chip").forEach(l=>{const c=this._normalizeType(l.dataset.name||""),d=o!==""&&c===o;l.style.display=!o||c.includes(o)?"":"none",l.classList.toggle("active",d),l.classList.toggle("btn-secondary",d),l.classList.toggle("btn-outline-secondary",!d),d&&(a=!0)}),o===""||a?(t&&(t.checked=!1,t.disabled=!0),s&&s.classList.add("opacity-50"),r&&(r.style.display=a?"":"none")):(t&&(t.disabled=!1),s&&s.classList.remove("opacity-50"),r&&(r.style.display="none"))},_saveTemplate(n){const e=n.querySelector("#dtSaveName")?.value?.trim(),t=n.querySelector("#dtSaveDesc")?.value?.trim(),s=n.querySelector("#dtTypeNameInput")?.value?.trim(),r
78=n.querySelector("#dtNewTypeCheck")?.checked,i=n.dataset.currentPageType??"post_detail",o=n.dataset.currentCategoryId??"",a=Habersoft?.adminRoutes?.["design-templates.store"];if(!e){n.querySelector("#dtSaveName")?.focus(),alert("Åablon adı zorunludur.");return}const l=n.querySelector("#dtSaveConfirmBtn");l&&(l.disabled=!0,l.textContent="Kaydediliyor...");const c=new URLSearchParams({name:e,page_type:i});t&&c.append("description",t),s&&c.append("template_type_name",s),r&&c.append("is_new_type","1"),n.querySelector("#dtIsSystem")?.checked&&c.append("is_system","1"),i==="category"&&o&&c.append("category_id",o);const d=this._previewCapture;this._previewCapture=null,fetch(a,{method:"POST",headers:{"X-CSRF-TOKEN":this.csrfToken,"X-Requested-With":"XMLHttpRequest",Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:c.toString()}).then(u=>u.json()).then(async u=>{if(!u.status){alert(u.message??"Kaydedilemedi.");return}if(d&&u.preview_upload_url){l&&(l.textContent="Ãnizleme yükleniyor..."),this._setPreviewStatus("uploading");const S=await d.catch(()=>null);S&&await this._uploadPreview(u.preview_upload_url,S).catch(()=>null),this._setPreviewStatus("done")}n.querySelector("#dtSaveName").value="",n.querySelector("#dtSaveDesc").value="";const p=n.querySelector("#dtTypeNameInput");p&&(p.value="");const v=n.querySelector("#dtNewTypeCheck");v&&(v.checked=!1);const h=n.querySelector("#dtIsSystem");h&&(h.checked=!1),this._refreshTypeUi(n),bootstrap.Modal.getInstance(n)?.hide(),alert("Åablon baÅarıyla kaydedildi.")}).catch(()=>alert("BaÄlantı hatası.")).finally(()=>{l&&(l.disabled=!1,l.textContent="Kaydet")})}},Q="base-style-live-preview",he="data-base-preview";class Js{constructor(){this._linearGradientParser=new De,this._shadowParser=new Be,this._paddingParser=new Re,this._marginParser=new Ve,this._borderParser=new Ne,this._activeInstanceId=null,this._activeContext=null,this._activeCategoryId=null,this._activeModuleEl=null}init(){const e=document.getElementById("moduleEditStylePanel");e&&(document.addEventListener("click",t=>{const s=t.target.closest(".base-style-open");s&&(t.preventDefault(),this._openBaseStylePanel(s))}),e.addEventListener("click",t=>{if(t.target.closest(".developer-base-style-save")){t.preventDefault(),this._saveBaseStyle(e);return}if(t.target.closest(".developer-base-style-back")){t.preventDefault();const s={instanceId:this._activeInstanceId,categoryId:this._activeCategoryId,context:this._activeContext};this._closePreview(),this._reloadStyleForm(e,s)}}),e.addEventListener("input",t=>{e.querySelector(".base-style-form-wrapper")&&this._updateLivePreview(e)}),e.addEventListener("change",t=>{e.querySelector(".base-style-form-wrapper")&&this._updateLivePreview(e)}))}async _openBaseStylePanel(e){const t=e.dataset.instanceId,s=e.dataset.categoryId||"0",r=e.dataset.context||"homepage",i=Habersoft?.adminRoutes?.["developer.basestyle.render"];if(!i)return;this._activeInstanceId=t,this._activeContext=r,this._activeCategoryId=s;const o=r==="post-detail"?`#postdetailmodule${t}`:`#homepagemodule${t}`;this._activeModuleEl=document.querySelector(o),this._activeModuleEl&&this._activeModuleEl.setAttribute(he,`base-${t}`),this._ensurePreviewStyleTag();const a=document.getElementById("moduleEditStylePanel"),l=a?.querySelector(".homepage-edit-panel");if(l){l.innerHTML='<div class="text-center py-4 text-muted fs-13">Yükleniyor...</div>';try{const d=await(await L.customFetch(i,{method:"POST",body:JSON.stringify({instance_id:t,context:r,category_id:s})})).json();l.innerHTML=d,window.eventManager?.emit("initStylePanel"),window.Coloris?.refresh?.(),this._updateLivePreview(a)}catch(c){l.innerHTML='<div class="text-danger px-3 py-2">Form yüklenemedi.</div>',console.error("[DeveloperBaseStyle] render error",c)}}}_ensurePreviewStyleTag(){if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,document.head.appendChild(e)}}_closePreview(){this._activeModuleEl&&(this._activeModuleEl.removeAttribute(he),this._activeModuleEl=null);const e=document.getElementById(Q);e&&(e.textContent=""),this._activeInstanceId=null,this._activeContext=null,this._activeCategoryId=null}_updateLivePreview(e){if(!this._activeInstanceId)return;const t=`base-${this._activeInstanceId}`,s=e.querySelectorAll(".base-style-row[data-style-id]");let r="";
78s.forEach(o=>{const a=o.dataset.className||"",l=`[${he}="${t}"] ${a}`,c={};o.querySelectorAll("input[name], select[name]").forEach(y=>{const g=y.name.match(/styles\[\d+\]\[\]\[([^\]]+)\]/);if(!g)return;const f=g[1];let m=y.value;y.type==="number"&&m!==""&&["font-size","line-height","width","height","border-width","border-radius","letter-spacing"].includes(f)&&(m+="px"),c[f]=m});const d=o.querySelector(".linear-container");if(d){const y={};d.querySelectorAll("input[data-style-target]").forEach(f=>{y[f.dataset.styleTarget]=f.value});const g=y["color-percent"]?`${y["color-percent"]}deg, `:"";c.background=`linear-gradient(${g}transparent ${y["color-transparent-percent"]}%, ${y["colorVal-1"]} ${y["color-1-intensity"]}%, ${y["colorVal-2"]} ${y["color-2-intensity"]}%)`}const u=o.querySelector(".custom-padding-cont");if(u){let y="0",g="0",f="0",m="0";u.querySelectorAll(".padding-setting-input").forEach(b=>{const _=b.value||"0";switch(b.dataset.paddingWay){case"top":y=_;break;case"right":g=_;break;case"bottom":f=_;break;case"left":m=_;break}}),c.padding=`${y}px ${g}px ${f}px ${m}px`}const p=o.querySelector(".custom-margin-cont");if(p){let y="0",g="0",f="0",m="0";p.querySelectorAll(".margin-setting-input").forEach(b=>{const _=b.value||"0";switch(b.dataset.marginWay){case"top":y=_;break;case"right":g=_;break;case"bottom":f=_;break;case"left":m=_;break}}),c.margin=`${y}px ${g}px ${f}px ${m}px`}const v=o.querySelector(".custom-border-cont");if(v){const y=v.querySelector('[data-border-part="width"]')?.value||"1",g=v.querySelector('[data-border-part="style"]')?.value||"solid",f=v.querySelector('[data-border-part="color"]')?.value||"#000000";c.border=`${y}px ${g} ${f}`}const h=o.querySelector(".shadow-control");h&&(c["text-shadow"]=h.checked?"1px 1px 1px #000":"none");const S=Object.entries(c).filter(([,y])=>y!=="");S.length>0&&(r+=`${l} { `,S.forEach(([y,g])=>{r+=`${y}: ${g} !important; `}),r+="} ")});const i=document.getElementById(Q);i&&(i.textContent=r)}async _saveBaseStyle(e){const t=Habersoft?.adminRoutes?.["developer.basestyle.update"];if(!t)return;const s=e.querySelector(".base-style-form-wrapper");if(!s)return;const r=s.querySelector(".base-style-context")?.value||"homepage",i=s.querySelector(".base-style-instance-id")?.value,o=s.querySelector(".base-style-category-id")?.value||"0",a=s,l=new FormData(a);this._linearGradientParser.parse().forEach(d=>{d.elementName&&l.append(d.elementName,d.elementValue)}),this._shadowParser.parse(l),this._paddingParser.parse(l),this._marginParser.parse(l),this._borderParser.parse(l),l.append("context",r),l.append("instance_id",i||""),l.append("category_id",o),await H.run({save:async()=>{const d=await(await L.customFetch(t,{method:"POST",body:l})).json();return d.status&&this._closePreview(),d},button:e.querySelector(".developer-base-style-save")})}_reloadStyleForm(e,t=null){const s=e?.querySelector(".homepage-edit-panel"),r=t?.instanceId??this._activeInstanceId;if(!s||!r)return;const o=(t?.context??this._activeContext??"homepage")==="post-detail"?"post-detail.renderform.modulestyle":"homepage.renderform.modulestyle",a=Habersoft?.routes?.ajax?.[o];a&&(s.innerHTML='<div class="text-center py-4 text-muted fs-13">Yükleniyor...</div>',L.customFetch(a,{method:"POST",body:JSON.stringify({homepageModuleId:r})}).then(l=>l.json()).then(l=>{s.innerHTML=l,window.eventManager?.emit("initStylePanel"),window.Coloris?.refresh?.()}).catch(()=>{s.innerHTML=""}))}}class sn{constructor(){this.partialDesign=new Je({eventManager:U}),this.homePageModules=new it({eventManager:U})}init(){window.eventManager=U,Habersoft.adminRoutes?.["partial.module-setting"]&&new et({partialDesign:this.partialDesign}).init(),Habersoft.adminRoutes?.["sidebars.rendermodule"]&&new tt().init(),new Ge({eventManager:U}).init(),new st({eventManager:U}
78).init(),new ot().init(),new at().init(),new dt().init(),Xs.init(),Gs.init(),Habersoft.adminRoutes?.["developer.basestyle.render"]&&new Js().init(),document.querySelector(".fast-admin-control .open-admin-control")?.addEventListener("click",()=>{document.querySelector(".fast-admin-control")?.classList.toggle("opened")})}}export{sn 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.