{"version":3,"file":"ViewCount.gqMj4Irp.mjs","names":["React.useState","__esmMin","window","init_npm_react_18_3_1","init_ssg_sandbox_shims","ce","init_jsx_runtime","c","p","_e","addPropertyControls","RenderTarget","ControlType","init_framer_CKT6jEEQ","loadAll","allCountsPromise","allCountsEndpoint","endpoint","r","d","todayKey","slug","alreadyCounted","markCounted","ViewCount","props","isCanvas","count","setCount","cancelled","url","mode","counts","esc","v","underlineCss","hoverUnderline","titleLayer","hoverLists","n","sel","h","value","placeholder","style","font","prefix","suffix","init_ViewCount"],"sources":["https:/framerusercontent.com/modules/CXNS3hxYFJ1T9T9nKbSA/sUC1bYoxxBWM8Wa6bEBy/ViewCount.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";let allCountsPromise=null;let allCountsEndpoint=\"\";function loadAll(endpoint){if(!allCountsPromise||allCountsEndpoint!==endpoint){allCountsEndpoint=endpoint;allCountsPromise=fetch(`${endpoint}?action=all`).then(r=>r.json()).then(d=>d&&d.counts||{}).catch(()=>{allCountsPromise=null;return{};});}return allCountsPromise;}function todayKey(slug){const d=new Date;const day=`${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()}`;return`p45-view:${slug}:${day}`;}function alreadyCounted(slug){try{return window.localStorage.getItem(todayKey(slug))===\"1\";}catch{return false;}}function markCounted(slug){try{window.localStorage.setItem(todayKey(slug),\"1\");}catch{}}export default function ViewCount(props){const{endpoint,slug,mode,prefix,suffix,placeholder,font,color,hoverUnderline,hoverLists,titleLayer,style}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[count,setCount]=React.useState(null);React.useEffect(()=>{if(isCanvas||!endpoint||!slug)return;let cancelled=false;const url=endpoint.trim();if(mode===\"count\"&&!alreadyCounted(slug)){markCounted(slug);fetch(`${url}?action=hit&slug=${encodeURIComponent(slug)}`).then(r=>r.json()).then(d=>{if(!cancelled&&typeof d.count===\"number\")setCount(d.count);}).catch(()=>{});}else{loadAll(url).then(counts=>{if(!cancelled)setCount(counts[slug]??0);});}return()=>{cancelled=true;};},[endpoint,slug,mode,isCanvas]);// 이전글·다음글 줄에 마우스를 올리면 제목에 밑줄 (게시된 사이트·프리뷰에서만)\nconst esc=v=>v.replace(/\"/g,'\\\\\"');const underlineCss=hoverUnderline&&titleLayer?(hoverLists||\"\").split(\",\").map(n=>n.trim()).filter(Boolean).map(n=>{const sel=h=>'[data-framer-name=\"'+esc(n)+'\"] > *'+h+' [data-framer-name=\"'+esc(titleLayer)+'\"] :is(p,span,h1,h2,h3,h4,h5,h6)';return sel(\"\")+\"{text-decoration-line:underline;text-decoration-color:transparent;text-decoration-thickness:1px;text-underline-offset:0.25em;transition:text-decoration-color 0.2s ease}\"+sel(\":hover\")+\"{text-decoration-color:currentColor}\";}).join(\"\"):\"\";const value=isCanvas?placeholder:count===null?\"-\":count.toLocaleString(\"ko-KR\");return /*#__PURE__*/_jsxs(\"span\",{style:{...style,...font,color,whiteSpace:\"nowrap\",fontVariantNumeric:\"tabular-nums\"},children:[underlineCss?/*#__PURE__*/_jsx(\"style\",{children:underlineCss}):null,prefix,value,suffix]});}ViewCount.defaultProps={hoverUnderline:false,hoverLists:\"Post Nav\",titleLayer:\"Title\",endpoint:\"\",slug:\"\",mode:\"display\",prefix:\"\",suffix:\"\",placeholder:\"128\",color:\"#636363\"};addPropertyControls(ViewCount,{hoverUnderline:{type:ControlType.Boolean,title:\"Hover Underline\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\",description:\"켜면 이전글\\xb7다음글 줄에 마우스를 올렸을 때 제목에 밑줄이 생겨요 (상세 페이지 하나에만 켜 주세요, 게시된 사이트\\xb7프리뷰에서만)\"},hoverLists:{type:ControlType.String,title:\"Hover Lists\",defaultValue:\"Post Nav\",hidden:props=>!props.hoverUnderline,description:\"밑줄 효과를 줄 묶음 레이어 이름 (이 안의 각 줄에 효과). 여러 개는 쉼표로 구분\"},titleLayer:{type:ControlType.String,title:\"Title Layer\",defaultValue:\"Title\",hidden:props=>!props.hoverUnderline,description:\"밑줄을 그을 제목 레이어 이름\"},endpoint:{description:\"조회수 시트 Apps Script 주소 (…/exec)\",type:ControlType.String,title:\"Endpoint\",placeholder:\"Apps Script 웹 앱 URL\"},slug:{description:\"조회수를 세는 기준. 글 제목에 연결돼 있어요\",type:ControlType.String,title:\"Slug\"},mode:{description:\"Count: 열 때 1 올림(상세 페이지) / Display: 숫자만 보여줌(목록)\",type:ControlType.Enum,title:\"Mode\",options:[\"count\",\"display\"],optionTitles:[\"Count (상세)\",\"Display (목록)\"],defaultValue:\"display\",displaySegmentedControl:true},prefix:{description:'숫자 앞에 붙는 글자 (예: \"조회 \")',type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},suffix:{description:\"숫자 뒤에 붙는 글자\",type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},placeholder:{type:ControlType.String,title:\"Canvas\",defaultValue:\"128\",description:\"캔버스에서만 보이는 예시 숫자\"},font:{description:\"글꼴\\xb7크기\",type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:\"1.4em\"}},color:{description:\"글자 색\",type:ControlType.Color,title:\"Color\",defaultValue:\"#636363\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ViewCount\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ViewCount.map"],"mappings":"A,8MAAyM,SAASc,EAAQ,EAAS,CAA0N,OAAtN,CAACC,GAAkBC,IAAoBC,KAAU,EAAkBA,EAAS,EAAiB,MAAM,GAAGA,EAAS,YAAY,CAAC,CAAC,KAAK,GAAGC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,GAAGC,GAAGA,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAiB,KAAW,CAAC,E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