!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ada029a6-1da2-4a97-baf4-aa84ea2bdd07",e._sentryDebugIdIdentifier="sentry-dbid-ada029a6-1da2-4a97-baf4-aa84ea2bdd07")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[53979],{14792:function(e,t,i){"use strict";i.d(t,{H:function(){return r}});var s=i(34223),l=i(96747),a=i(34930);let r=()=>{let{t:e}=(0,a.Z)("features/post");return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,s.jsx)(l.L,{size:"xxxlarge",className:"text-object-primary"}),(0,s.jsx)("div",{className:"mt-16",children:(0,s.jsx)("h2",{className:"text-variant-subtitleLg text-secondary",children:e("該当する結果は見つかりませんでした")})}),(0,s.jsx)("p",{className:"text-variant-bodyMd text-tertiary",children:e("条件を変更してみましょう")})]})}},8927:function(e,t,i){"use strict";i.d(t,{O:function(){return j},r:function(){return b}});var s=i(34223),l=i(57799),a=i(33188),r=i(95551),c=i(18180),o=i(66585),n=i(96030),d=i(34930),p=i(2363),u=i(21076),m=i(41865),x=i(4954),h=i(72644),f=i(44751),y=i(11024),g=i.n(y);let j=(0,x.BX)(`
  fragment TopicFilterMenuFragment on TopicFilterGroup {
    id
    title
    topicFilters {
      topicFilterId
      value
    }
  }
`),b=e=>{let{data:t,onSelect:i}=e,[c,x]=(0,p.useState)([]),y=(0,h.vz)(j,t),b=(0,p.useMemo)(()=>0===c.length?y.title:y.topicFilters.find(e=>e.topicFilterId===c[0])?.value,[y.title,y.topicFilters,c]),{onOpen:T,onClose:C,open:I,openConstant:N}=(0,m.R)(),{t:S}=(0,d.Z)("features/post"),k=(0,f.zJ)(),w=(0,p.useCallback)(e=>{x(t=>[...t,e])},[]),z=(0,p.useCallback)(e=>{x(t=>t.filter(t=>t!==e))},[]),F=(0,u.V)(),M=(0,p.useCallback)(()=>{F("topic_filter_select",{topicFilterGroupId:y.id,topicFilterIds:c}),i(y.id,c),C()},[F,y.id,c,i,C]),$=(0,p.useCallback)(()=>{x([])},[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.z,{size:"xsmall",variant:"basic",rounded:!0,className:(0,n.Z)(g()["filter-button"],c.length>0&&"bg-specific-blue-400/10 text-specific-blue-400"),onClick:T,endIcon:(0,s.jsx)(o.F,{size:"xsmall"}),children:(0,s.jsxs)("span",{className:"flex items-center",children:[(0,s.jsx)("span",{className:(0,n.Z)("block truncate",g()["select-filter-name"]),children:b}),c.length>1&&(0,s.jsx)("span",{children:`+${c.length-1}`})]})}),N&&(0,s.jsxs)(a.u_,{open:I,onClose:C,...k?{type:"popup",size:"large"}:{type:"sheet",size:"medium"},fixedSize:!0,children:[(0,s.jsx)(a.xB,{title:y.title,border:!1,startNode:(0,s.jsx)(l.z,{type:"button",variant:"plain",className:"text-tertiary",size:"mini",onClick:C,children:S("キャンセル")})}),(0,s.jsx)(a.hz,{children:y.topicFilters.map(e=>{let t=c.includes(e.topicFilterId);return(0,s.jsxs)("label",{className:"flex cursor-pointer items-center justify-between px-16 py-12",children:[(0,s.jsx)(r.Z,{variant:"bodyLg",children:e.value}),(0,s.jsx)(v,{filterId:e.topicFilterId,onSelect:w,onDeleteSelect:z,isAlreadyChecked:t})]},e.topicFilterId)})}),(0,s.jsx)("div",{className:"pb-safe",children:(0,s.jsxs)("div",{className:"flex flex-col gap-8 px-16 py-8",children:[(0,s.jsx)(l.z,{onClick:M,size:"medium",variant:"primary",fullWidth:!0,children:S("決定")}),(0,s.jsx)(l.z,{onClick:$,size:"medium",variant:"plain",fullWidth:!0,children:S("リセット")})]})})]})]})},v=e=>{let{filterId:t,onSelect:i,onDeleteSelect:l,isAlreadyChecked:a}=e,[r,o]=(0,p.useState)(a);(0,p.useEffect)(()=>{o(a)},[a]);let n=(0,p.useCallback)(()=>{r?(o(!1),l(t)):(o(!0),i(t))},[r,l,t,i]);return(0,s.jsx)(c.X,{name:t,onChange:n,checked:r})}},33111:function(e,t,i){"use strict";i.d(t,{Xj:function(){return el},G:function(){return ee}});var s=i(34223),l=i(98376),a=i(57799),r=i(73432),c=i(95551),o=i(33188),n=i(43147),d=i(63940),p=i(64682),u=i(24337),m=i(96747),x=i(80029),h=i(69714),f=i(5219),y=i(19298),g=i(36918),j=i(9249),b=i(59763),v=i(96030),T=i(62862),C=i(34930),I=i(2363),N=i(72209),S=i(38803),k=i(14792),w=i(13120),z=i(88849);let F=()=>(0,s.jsx)(y.H,{children:(0,s.jsxs)(g.M,{children:[(0,s.jsx)(w.p,{height:48,width:48,radius:"md"}),(0,s.jsxs)(b.c,{className:"w-full",isSecondary:!0,children:[(0,s.jsx)(z.Q,{variant:"subtitleSm"}),(0,s.jsx)(z.Q,{variant:"subtitleXs",width:"20%"})]})]})}),M=()=>(0,s.jsx)(y.H,{children:(0,s.jsxs)(g.M,{children:[(0,s.jsx)(w.p,{height:48,width:48,radius:"md"}),(0,s.jsx)(b.c,{className:"w-full",isSecondary:!0,children:(0,s.jsx)(z.Q,{variant:"subtitleMd"})})]})});var $=i(8927),D=i(60704),_=i(38224),Z=i(86415),B=i(44751),E=i(28136),A=i(89090),P=i(4954),U=i(72644),L=i(41865),G=i(21076),O=i(64728),q=i(71258),R=i(3459),V=i(87613),X=i(14640),H=i(74927),Q=i(53346),W=i.n(Q);let K="communityTopicIds",J=(0,P.BX)(`
  query TopicFormFieldQuery($topicIds: [String!]!, $communityId: String!) {
    postTopicsByIds(topicIds: $topicIds) {
      id
      label
      imageUrl
      categoryIds
      isPostable(communityId: $communityId)
    }
  }
`),Y=(0,P.BX)(`
    fragment RequiredCategoryTopicsFragment on TopicCategory {
      topicFilterGroups {
        id
        title
        topicFilters {
          topicFilterId
          value
        }
        ...TopicFilterMenuFragment
      }
      topicSortKeys
      ...TopicSortMenuFragment
    }
  `,[$.O,D.F]),ee=(0,P.BX)(`
    fragment TopicFormFieldFragment on PostTemplate {
      id
      title
      requiredPostTopics {
        id
        label
        imageUrl
      }
      requiredTopicCategories {
        id
        title
        ...RequiredCategoryTopicsFragment
      }
    }
  `,[Y]),et={mustTopics:[],selectedTopics:[],selectedCategoryTopicsDic:{},allTopics:[]},ei=(e,t)=>{switch(t.type){case"initialize":{let{initialTopics:e,requiredTopics:i,requiredCategories:s}=t,l=s?.map(e=>e.id)??[];return{selectedTopics:e.filter(e=>(i??[]).every(t=>t.id!==e.id)).filter(e=>!e.categoryIds.some(e=>l.includes(e))),mustTopics:i??[],selectedCategoryTopicsDic:Object.fromEntries(s?.map(t=>[t.id,e.filter(e=>e.categoryIds.includes(t.id)).map(e=>({id:e.id,label:e.label,imageUrl:e.imageUrl}))??[]])??[]),allTopics:e}}case"select":{let{topicId:i,label:s,imageUrl:l,categoryId:a}=t;if(a)return{...e,selectedCategoryTopicsDic:{...e.selectedCategoryTopicsDic,[a]:[...e.selectedCategoryTopicsDic[a]??[],{id:i,label:s,imageUrl:l,isAdditional:!1}]},allTopics:[...e.allTopics,{id:i,label:s,imageUrl:l,isAdditional:!1}]};return{...e,selectedTopics:[...e.selectedTopics,{id:i,label:s,imageUrl:l,isAdditional:!1}],allTopics:[...e.allTopics,{id:i,label:s,imageUrl:l,isAdditional:!1}]}}case"add":{let{label:i}=t,s=(0,S.Z)();return{...e,selectedTopics:[...e.selectedTopics,{id:s,label:i,imageUrl:"",isAdditional:!0}],allTopics:[...e.allTopics,{id:s,label:i,imageUrl:"",isAdditional:!0}]}}case"deselect":{let{topicId:i}=t;return{...e,selectedTopics:e.selectedTopics.filter(e=>e.id!==i),selectedCategoryTopicsDic:Object.fromEntries(Object.entries(e.selectedCategoryTopicsDic).map(e=>{let[t,s]=e;return[t,s.filter(e=>e.id!==i)]})),allTopics:e.allTopics.filter(e=>e.id!==i)}}case"allDeselect":return{...e,selectedTopics:[],selectedCategoryTopicsDic:Object.fromEntries(Object.entries(e.selectedCategoryTopicsDic).map(e=>{let[t,i]=e;return[t,[]]})),allTopics:[]};default:return(0,H.P)(t,e,`Unexpected action ${t} in selectedTopicStateReducer`)}},es=e=>{let{templateData:t,defaultTopicIds:i}=e,{t:s}=(0,C.Z)("features/post"),a=(0,U.vz)(ee,t),r=(0,q.F)(),{communityId:c}=(0,R.U)(),{field:{value:o}}=(0,N.bc)({name:"communityTopicId"}),{formState:{errors:n}}=(0,N.bc)({name:K}),{setValue:d}=(0,N.Gc)(),[p,u]=(0,I.useReducer)(ei,et),[m,x]=(0,I.useState)([]),h=(0,I.useCallback)(e=>{x(e.postTopicsByIds.filter(e=>e.isPostable))},[]),f=(0,I.useMemo)(()=>o?[o,...i]:i,[i,o]);(0,l.a)(J,{variables:{topicIds:f,communityId:c},skip:0===f.length,onCompleted:h}),(0,I.useEffect)(()=>{u({type:"initialize",initialTopics:m,requiredCategories:a?.requiredTopicCategories,requiredTopics:a?.requiredPostTopics})},[a?.requiredPostTopics,a?.requiredTopicCategories,m]);let{maximumNumberOfSelectableTopics:y=5}=(0,O.V)(),g=(0,I.useCallback)(e=>{let{categoryId:t,topicId:i,label:l,imageUrl:a}=e;if(eb(p)>y-1){r(s("選択できるトピックは{{maximumNumberOfSelectableTopics}}個までです",{maximumNumberOfSelectableTopics:y}),"info");return}u({type:"select",topicId:i,categoryId:t,label:l,imageUrl:a})},[y,r,s,p]),j=(0,I.useCallback)(e=>{let{label:t}=e;if(eb(p)>y-1){r(s("選択できるトピックは{{maximumNumberOfSelectableTopics}}個までです",{maximumNumberOfSelectableTopics:y}),"info");return}u({type:"add",label:t})},[y,r,s,p]),b=(0,I.useCallback)(e=>{let{topicId:t}=e;return u({type:"deselect",topicId:t})},[]),[v,T]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{if(d("additionalTopics",p.allTopics.filter(e=>e.isAdditional).map(e=>e.label),{shouldDirty:!1,shouldValidate:!0}),!v&&Object.values(p.selectedCategoryTopicsDic).some(e=>0===e.length)){d(K,"");return}d(K,[...p.mustTopics.filter(e=>!e.isAdditional).map(e=>e.id),...p.selectedTopics.filter(e=>!e.isAdditional).map(e=>e.id),...Object.values(p.selectedCategoryTopicsDic).flatMap(e=>e.filter(e=>!e.isAdditional).map(e=>e.id))],{shouldDirty:!1,shouldValidate:!0})},[d,v,p]),{selectedTopicState:p,handleTopicSelect:g,handleTopicDeselect:b,hasFormError:!v&&!!n[K],skipTopicValidation:v,setSkipTopicValidation:T,handleTopicAdd:j}},el=e=>{let{data:t,postId:i,defaultTopicIds:l}=e,{handleTopicSelect:a,handleTopicDeselect:r,selectedTopicState:c,hasFormError:o,skipTopicValidation:n,setSkipTopicValidation:d,handleTopicAdd:p}=es({postId:i,templateData:t,defaultTopicIds:l}),u=(0,U.vz)(ee,t);return(0,s.jsxs)("div",{className:"grid gap-16 lg:gap-24",children:[u?.requiredTopicCategories?.filter(Boolean)?.map(e=>s.jsx(ea,{shouldShowError:o,data:e,categoryId:e.id,selectedTopicState:c,onSelect:a,onDeselect:r,skipTopicValidation:n,onClickSkipTopicValidation:d},e.id)),(0,s.jsx)(er,{selectedTopicState:c,onSelect:a,onDeselect:r,templateId:u?.id,onAdd:p})]})},ea=e=>{let{data:t,categoryId:i,onSelect:l,onDeselect:m,selectedTopicState:x,shouldShowError:h,skipTopicValidation:f,onClickSkipTopicValidation:y}=e,{t:g}=(0,C.Z)("features/post"),{onOpen:j,onClose:b,open:v,openConstant:N}=(0,L.R)(),S=(0,B.zJ)(),[w,z]=(0,I.useState)(""),M=(0,T.Z)(async e=>{z(e.target.value)},300),[Z,E]=(0,I.useState)([]),P=(0,I.useCallback)((e,t)=>{E(i=>Array.isArray(i)?[...i.filter(t=>t.topicFilterGroupId!==e),{topicFilterGroupId:e,topicFilterIds:t}]:i)},[]),[G,q]=(0,I.useState)({key:"POPULARITY_SCORE",direction:"DESCENDING"}),R=(0,I.useCallback)((e,t)=>{q({key:e,direction:t})},[]),{data:V,loading:X,hasMore:H,handleMore:Q}=(0,_.q)({categoryId:i,keyword:w,topicFilterGroups:Z,topicSort:G}),W=(0,I.useMemo)(()=>!!(V?.topicCategory.topics&&V.topicCategory.topics.edges.length>0),[V?.topicCategory.topics]),K=(0,I.useCallback)(e=>{let{id:t,label:s,imageUrl:a}=e;l({categoryId:i,topicId:t,label:s,imageUrl:a})},[i,l]),J=(0,I.useMemo)(()=>x.allTopics.filter(e=>x.mustTopics.every(t=>t.id!==e.id)),[x.allTopics,x.mustTopics]),ee=x.selectedCategoryTopicsDic[i]??[],et=(0,I.useCallback)(()=>{y(!0),b()},[b,y]),ei=(0,I.useCallback)(()=>{z(""),j()},[j]),es=h&&0===ee.length,{skipRequiredTopicCategoryActivationFlag:el}=(0,O.V)(),ea=(0,U.vz)(Y,t),er=(0,I.useMemo)(()=>(0,s.jsx)(a.z,{type:"button",variant:"plain",className:"text-tertiary",size:"mini",onClick:b,children:g("キャンセル")}),[b,g]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"truncate",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-variant-subtitleMd text-primary",children:V?.topicCategory.title}),ee.length>0&&(0,s.jsxs)("button",{type:"button",className:"flex cursor-pointer items-center",onClick:ei,children:[(0,s.jsx)("p",{className:"text-variant-bodyMd text-secondary",children:g("選択")}),(0,s.jsx)(d.C,{})]})]}),f?(0,s.jsxs)("div",{className:"mt-8 flex w-full items-center justify-between whitespace-nowrap py-4",children:[(0,s.jsxs)("div",{className:"flex w-5/6 items-center",children:[(0,s.jsx)("div",{className:"flex size-48 items-center justify-center rounded-md bg-object-neutral",children:(0,s.jsx)(p.R,{className:"text-object-disable"})}),(0,s.jsx)("p",{className:"text-variant-bodyMd ml-16 truncate text-primary",children:g("選択なし")})]}),(0,s.jsx)(r.h,{size:"medium",onClick:()=>y(!1),children:(0,s.jsx)(u.v,{})})]}):ee.length>0?(0,s.jsx)("div",{className:"mt-8",children:ee.map((e,t)=>(0,s.jsxs)(I.Fragment,{children:[0!==t&&(0,s.jsx)("div",{className:"h-16"}),(0,s.jsx)(ej,{topic:e,onDeselect:m},e.id)]},e.id))}):(0,s.jsx)("div",{className:"mt-8",children:(0,s.jsxs)(a.z,{onClick:ei,loading:X,variant:"outlined",size:"small",fullWidth:!0,children:[V?.topicCategory.title,g("を選択")]})}),es&&(0,s.jsxs)(c.Z,{variant:"bodyMd",className:"pt-8 text-specific-red-400",children:[V?.topicCategory?.title,g("を選択してください")]})]}),N&&(0,s.jsxs)(o.u_,{open:v,onClose:b,...S?{type:"popup",size:"large"}:{type:"sheet",size:"medium"},fixedSize:!0,children:[(0,s.jsx)(o.xB,{title:V?.topicCategory&&g("{{title}}を選択",{title:V.topicCategory.title}),startNode:er,endNode:eo(b,g)}),(0,s.jsxs)("div",{className:"pt-12",children:[(0,s.jsx)("div",{className:"flex justify-between gap-12 px-16",children:(0,s.jsx)("div",{className:"w-full",children:(0,s.jsx)(n.n,{size:"small",label:"",type:"text",placeholder:g("{{title}}を検索",{title:V?.topicCategory.title}),name:"searchTopics",onChange:M,startAdornment:ex})})}),(0,s.jsxs)("div",{className:"flex gap-12 overflow-x-auto px-16 py-12",children:[ea?.topicFilterGroups.map(e=>s.jsx($.r,{data:e,onSelect:P},e.id)),(0,s.jsx)(D.U,{data:ea,onSelectSort:R})]})]}),(0,s.jsx)(o.hz,{children:(0,s.jsxs)("div",{children:[ee.length>0&&!W&&!X&&(0,s.jsx)("div",{className:"mt-96 flex flex-col items-center justify-center",children:(0,s.jsx)(k.H,{})}),(0,s.jsx)(A.Z,{onLoadMore:Q,isLoading:X,isLoadableMore:H,children:(0,s.jsxs)("div",{className:"overflow-auto pb-80 lg:pb-40",children:[X&&em.map(e=>(0,s.jsx)(F,{},e)),V?.topicCategory.topics?.edges.map(e=>{let t=ev({state:x,topicId:e.node.id}),i=eT({state:x,topicId:e.node.id});return s.jsx(eh,{data:e.node,onSelect:K,onDeselect:m,isSelected:t||i,isMust:i},e.node.id)}),0===ee.length&&!X&&!H&&el&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center px-16 py-40",children:[(0,s.jsx)(c.Z,{variant:"subtitleMd",children:g("選択したい{{title}}が見つかりませんか？",{title:V?.topicCategory.title})}),(0,s.jsx)(c.Z,{variant:"bodySm",color:"secondary",className:"mt-4",children:g("{{title}}を選択せずに投稿することもできます",{title:V?.topicCategory.title})}),(0,s.jsx)(a.z,{className:"mt-24",variant:"outlined",size:"small",onClick:et,children:g("{{title}}を選択せずに投稿",{title:V?.topicCategory.title})})]})]})})]})}),(0,s.jsx)("div",{className:"border-t border-border bg-surface-plain pb-safe",children:(0,s.jsx)(ey,{topics:J,onDeselect:m})})]})]})},er=e=>{let{selectedTopicState:t,onSelect:i,onAdd:l,onDeselect:a,templateId:r}=e,{t:c}=(0,C.Z)("features/post"),{onOpen:o,onClose:n,open:p,openConstant:u}=(0,L.R)(),m=(0,I.useMemo)(()=>t.allTopics.filter(e=>t.mustTopics.every(t=>t.id!==e.id)),[t.allTopics,t.mustTopics]);return(0,s.jsxs)("div",{className:"overflow-auto",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-variant-subtitleMd text-primary",children:c("トピック")}),(0,s.jsxs)("button",{type:"button",className:"flex cursor-pointer items-center",onClick:o,children:[(0,s.jsx)("p",{className:"text-variant-bodyMd text-secondary",children:c("選択")}),(0,s.jsx)(d.C,{className:"text-secondary"})]})]}),eb(t)?(0,s.jsx)("div",{className:"mt-8 overflow-auto",children:(0,s.jsxs)("ul",{className:"flex w-fit flex-wrap gap-8",children:[t.mustTopics.map(e=>(0,s.jsx)(eg,{topic:e,type:"view"},e.id)),t.selectedTopics.map(e=>(0,s.jsx)(eg,{onDeselect:a,topic:e,type:"view"},e.id))]})}):(0,s.jsx)("p",{className:"text-variant-bodyMd mt-8 text-tertiary",children:c("好きなトピックを追加しよう")}),u&&(0,s.jsx)(ec,{topics:m,open:p,onClose:n,selectedTopicState:t,onSelect:i,onDeselect:a,templateId:r,onAdd:l})]})},ec=e=>{let{open:t,onClose:i,selectedTopicState:l,onSelect:r,onDeselect:c,templateId:n,topics:d,onAdd:p}=e,{t:u}=(0,C.Z)("features/post"),m=(0,B.zJ)(),x=(0,I.useMemo)(()=>(0,s.jsx)(a.z,{type:"button",variant:"plain",className:"text-tertiary",size:"mini",onClick:i,children:u("キャンセル")}),[i,u]);return(0,s.jsxs)(o.u_,{open:t,onClose:i,...m?{type:"popup",size:"large"}:{type:"sheet",size:"medium"},fixedSize:!0,children:[(0,s.jsx)(o.xB,{title:u("トピックを選択"),startNode:x,endNode:eo(i,u)}),(0,s.jsx)(o.hz,{children:(0,s.jsx)(eu,{selectedTopicState:l,onSelect:r,onDeselect:c,templateId:n,onAdd:p})}),(0,s.jsx)("div",{className:"border-t border-border bg-surface-plain pb-safe",children:(0,s.jsx)(ey,{topics:d,onDeselect:c})})]})},eo=(e,t)=>(0,s.jsx)(a.z,{size:"xsmall",variant:"plain",onClick:e,children:t("完了")}),en=(0,P.BX)(`
  fragment TopicCardFragment on PostTopic {
    id
    label
    imageUrl
    postCount
    isPostable(communityId: $communityId)
  }
`),ed=(0,P.BX)(`
    query TopicListQuery(
      $communityId: String!
      $templateId: String
      $keyword: String!
      $after: String
      $first: Int
      $userId: String
    ) {
      postTopicsByTemplateId(
        communityId: $communityId
        templateId: $templateId
        keyword: $keyword
        after: $after
        first: $first
        userId: $userId
      ) {
        edges {
          node {
            id
            label
            ...TopicCardFragment
          }
        }
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
  `,[en]),ep=e=>{let{templateId:t}=e,{communityId:i}=(0,R.U)(),s=(0,Z.II)(),[a,r]=(0,I.useState)(""),c=(0,T.Z)(async e=>{r(e.target.value)},300),{data:o,fetchMore:n,loading:d}=(0,l.a)(ed,{variables:{communityId:i??"",templateId:t??null,keyword:a,first:30,after:null,userId:s??null},skip:!i}),p=(0,I.useMemo)(()=>o?.postTopicsByTemplateId,[o]),u=(0,I.useMemo)(()=>!!(p&&p.edges.length>0),[p]),m=(0,I.useMemo)(()=>o?.postTopicsByTemplateId.pageInfo.hasNextPage??!1,[o]);return{handleMore:(0,I.useCallback)(()=>{n({variables:{after:p?.pageInfo.endCursor},updateQuery:(e,t)=>{let{fetchMoreResult:i}=t;return i?.postTopicsByTemplateId?{...i,postTopicsByTemplateId:{pageInfo:i.postTopicsByTemplateId.pageInfo,edges:[...e.postTopicsByTemplateId.edges??[],...i.postTopicsByTemplateId.edges??[]]}}:e}})},[p,n]),handleSearch:c,loading:d,data:o,hasTopics:u,hasMore:m,hasSearchWord:!!a,searchWord:a}},eu=e=>{let{onSelect:t,onDeselect:i,selectedTopicState:l,templateId:a,onAdd:r}=e,{t:c}=(0,C.Z)("features/post"),{handleMore:o,handleSearch:d,loading:p,data:u,hasTopics:m,hasMore:x,hasSearchWord:h,searchWord:f}=ep({templateId:a}),{createLabelOnlyTopicActivationFlag:y}=(0,O.V)(),g=(0,I.useMemo)(()=>!(!y||!h||p||l.allTopics.some(e=>e.label===f))&&(u?.postTopicsByTemplateId?.edges?.every(e=>e.node.label!==f)??!1),[y,u?.postTopicsByTemplateId?.edges,h,p,f,l.allTopics]),j=(0,I.useCallback)(e=>t({topicId:e.id,label:e.label,imageUrl:e.imageUrl}),[t]),b=(0,I.useCallback)(e=>r({label:e}),[r]),v=(0,I.useMemo)(()=>l.selectedTopics.filter(e=>e.isAdditional&&(!f||e.label.includes(f))),[f,l.selectedTopics]);return(0,s.jsxs)("div",{className:"cursor-pointer pt-12",children:[(0,s.jsx)("div",{className:"px-16",children:(0,s.jsx)(n.n,{size:"small",label:"",type:"text",placeholder:c("トピックを検索"),name:"searchTopics",onChange:d,startAdornment:ex})}),!y&&!m&&!p&&(0,s.jsx)("div",{className:"mt-96",children:(0,s.jsx)(k.H,{})}),(0,s.jsx)(A.Z,{onLoadMore:o,isLoading:p,isLoadableMore:x,children:(0,s.jsxs)("div",{className:"overflow-auto py-24 pb-80 lg:grid-cols-6 lg:pb-40",children:[g&&(0,s.jsx)(ef,{data:(0,U.Ud)([en],{id:"additional",label:f,imageUrl:"",postCount:0,isPostable:!0}),onSelect:j,onDeselect:i,isSelected:!1,isMust:!1,onAdd:b,isAdditional:!0},"TopicListItem_additional"),v.map(e=>(0,s.jsx)(ef,{data:(0,U.Ud)([en],{id:e.id,label:e.label,imageUrl:"",postCount:0,isPostable:!0}),onSelect:j,onDeselect:i,isSelected:!0,isMust:!1},`TopicListItem_${e.id}`)),p&&em.map(e=>(0,s.jsx)(M,{},e)),u?.postTopicsByTemplateId.edges.map(e=>{let t=ev({state:l,topicId:e.node.id}),a=eT({state:l,topicId:e.node.id});return s.jsx(ef,{data:e.node,onSelect:j,onDeselect:i,isSelected:t||a,isMust:a},`TopicListItem_${e.node.id}`)})]})})]})},em=(0,X.w)(9),ex=(0,s.jsx)(m.L,{size:"small"}),eh=e=>{let{data:t,onSelect:i,onDeselect:l,isSelected:a,isMust:r}=e,{t:o}=(0,C.Z)("features/post"),{id:n,label:d,postCount:p,imageUrl:u,isPostable:m}=(0,U.vz)(en,t),f=(0,I.useCallback)(()=>{r||(a?l({topicId:n}):i({id:n,label:d,imageUrl:u}))},[r,a,l,n,i,d,u]);return m?(0,s.jsxs)(y.H,{onClick:f,children:[(0,s.jsxs)(g.M,{children:[(0,s.jsx)("div",{className:"flex size-48 shrink-0 items-center justify-center overflow-hidden rounded-md bg-object-neutral",children:u?(0,s.jsx)(E.E,{alt:"topic image",src:u,height:48,width:48}):(0,s.jsx)(x.w,{width:"24px",height:"24px"})}),(0,s.jsxs)("div",{className:"ml-16 truncate",children:[(0,s.jsx)(c.Z,{variant:"bodyLg",className:"truncate",children:d}),(0,s.jsxs)(c.Z,{component:"span",variant:"bodySm",color:"tertiary",children:[p,o("投稿")]})]})]}),(0,s.jsx)(j.h,{className:"text-accent",children:a&&(0,s.jsx)(h.G,{width:"20px",height:"20px"})})]}):null},ef=e=>{let{data:t,onSelect:i,onDeselect:l,isSelected:a,isMust:r,isAdditional:o,onAdd:n}=e,{t:d}=(0,C.Z)("features/post"),{id:p,label:u,imageUrl:m,postCount:v,isPostable:T}=(0,U.vz)(en,t),N=(0,I.useCallback)(()=>{if(!r){if(a){l({topicId:p});return}if(o){if(!n){V.k.error({error:"onAdd is not defined"});return}n?.(u)}else i({id:p,label:u,imageUrl:m})}},[r,a,o,l,p,n,u,i,m]);return T?(0,s.jsxs)(y.H,{onClick:N,children:[(0,s.jsxs)(g.M,{children:[(0,s.jsx)("div",{className:"flex size-48 shrink-0 items-center justify-center overflow-hidden rounded-md bg-object-neutral",children:m?(0,s.jsx)(E.E,{alt:"topic image",src:m,height:48,width:48}):(0,s.jsx)(x.w,{width:"24px",height:"24px"})}),(0,s.jsxs)(b.c,{isSecondary:!0,children:[(0,s.jsx)("p",{className:"text-variant-bodyMd truncate",children:u}),!o&&(0,s.jsxs)(c.Z,{component:"span",variant:"bodySm",color:"tertiary",children:[v,d("投稿")]})]}),o&&(0,s.jsx)(b.c,{isSecondary:!0,className:"text-accent",children:(0,s.jsx)(f.F,{})})]}),(0,s.jsx)(j.h,{className:"text-accent",children:a&&(0,s.jsx)(h.G,{width:"20px",height:"20px"})})]}):null},ey=e=>{let{topics:t,onDeselect:i}=e,{t:l}=(0,C.Z)("features/post"),a=t.length;return(0,s.jsxs)("div",{className:"min-h-80 px-16 pb-16 pt-8",children:[(0,s.jsxs)(c.Z,{variant:"subtitleSm",color:"secondary",children:[l("選択中のトピック"),(0,s.jsx)(c.Z,{className:"ml-8",component:"span",variant:"subtitleSm",color:"secondary",children:a})]}),(0,s.jsx)("div",{className:"mt-8 overflow-x-auto",children:(0,s.jsx)("ul",{className:"flex w-fit flex-row gap-8",children:t.map(e=>(0,s.jsx)(eg,{topic:e,onDeselect:i,type:"create"},e.id))})})]})},eg=e=>{let{topic:t,onDeselect:i,type:l}=e,a=(0,G.V)(),r=(0,I.useCallback)(()=>{a("topic_tag_deselect_click",{topicId:t.id}),i?.({topicId:t.id})},[a,i,t.id]);return(0,s.jsxs)("div",{className:(0,v.Z)(W().tag,"flex w-fit items-center justify-between whitespace-nowrap rounded-lg px-8 text-accent","view"===l?"bg-object-neutral hover:bg-object-neutral-hover":"bg-object-accent hover:bg-object-accent-hover"),children:[(0,s.jsx)("p",{className:(0,v.Z)("text-variant-bodySm","view"===l?"text-primary":"text-on-accent"),children:t.label}),i&&(0,s.jsx)("button",{type:"button","aria-label":"Delete this tag",onClick:r,className:"ml-4 flex",children:(0,s.jsx)(u.v,{size:"xsmall",className:"view"===l?"text-primary":"text-on-accent"})})]})},ej=e=>{let{topic:t,onDeselect:i}=e,l=(0,I.useCallback)(()=>{i({topicId:t.id})},[i,t.id]);return(0,s.jsxs)("div",{className:"flex w-full items-center justify-between whitespace-nowrap py-4",children:[(0,s.jsxs)("div",{className:"flex w-5/6 items-center",children:[(0,s.jsx)(E.E,{src:t.imageUrl??"",width:66,height:66,alt:"selected topic image",sizes:"80px",className:"rounded-sm object-cover"}),(0,s.jsx)("p",{className:"text-variant-bodyMd ml-8 truncate text-primary",children:t.label})]}),(0,s.jsx)(r.h,{size:"medium",onClick:l,children:(0,s.jsx)(u.v,{})})]})},eb=e=>e.mustTopics.length+e.selectedTopics.length+Object.values(e.selectedCategoryTopicsDic).reduce((e,t)=>e+t.length,0),ev=e=>{let{state:t,topicId:i}=e;return t.allTopics.some(e=>e.id===i)},eT=e=>{let{state:t,topicId:i}=e;return t.mustTopics.some(e=>e.id===i)}},60704:function(e,t,i){"use strict";i.d(t,{F:function(){return g},U:function(){return v}});var s=i(34223),l=i(57799),a=i(33188),r=i(19943),c=i(66585),o=i(96030),n=i(34930),d=i(2363),p=i(44751),u=i(4954),m=i(72644),x=i(41865),h=i(21076),f=i(74044),y=i.n(f);let g=(0,u.BX)(`
  fragment TopicSortMenuFragment on TopicCategory {
    topicSortKeys
  }
`),j="POPULARITY_SCORE",b="RELEASED_AT",v=e=>{let{data:t,onSelectSort:i}=e,{t:u}=(0,n.Z)("features/post"),f=(0,m.vz)(g,t),{onOpen:v,onClose:T,open:C}=(0,x.R)(),[I,N]=(0,d.useState)({key:j,direction:"DESCENDING"}),S=(0,d.useCallback)(e=>{N({key:e.target.value,direction:"DESCENDING"})},[]),k=(0,h.V)(),w=(0,d.useCallback)(()=>{k("topic_sort_select",{topicSortKey:I.key}),i(I.key,I.direction),T()},[k,T,i,I.direction,I.key]),z=I.key!==j,F=(0,p.zJ)();return 0===f.topicSortKeys.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.z,{size:"xsmall",variant:"basic",rounded:!0,className:(0,o.Z)(y()["filter-button"],z&&"bg-specific-blue-400/10 text-specific-blue-400"),onClick:v,endIcon:(0,s.jsx)(c.F,{size:"xsmall"}),children:I.key===b?u("発売日が新しい順"):u("並び替え")}),(0,s.jsxs)(a.u_,{open:C,onClose:T,...F?{type:"popup",size:"medium"}:{type:"sheet",size:"small"},children:[(0,s.jsx)(a.xB,{title:u("並び替え"),border:!1,startNode:(0,s.jsx)(l.z,{type:"button",variant:"plain",className:"text-tertiary",size:"mini",onClick:T,children:u("キャンセル")})}),(0,s.jsxs)("div",{className:"mx-auto w-full max-w-screen-md pb-safe",children:[f.topicSortKeys.map(e=>{let t=e===I.key;return(0,s.jsxs)("label",{className:"flex cursor-pointer items-center justify-between px-16 py-12",children:[(0,s.jsx)("span",{className:"text-variant-bodyLg",children:e===b?u("発売日が新しい順"):u("人気順")}),(0,s.jsx)(r.Y,{name:e,value:e,checked:t,onChange:S},e)]},e)}),(0,s.jsx)("div",{className:"p-16",children:(0,s.jsx)(l.z,{variant:"primary",onClick:w,fullWidth:!0,children:u("決定")})})]})]})]})}},64847:function(e,t,i){"use strict";i.d(t,{E:function(){return m}});var s=i(34223),l=i(8241),a=i(95551),r=i(97165),c=i(2363),o=i.t(c,2),n=i(72209);let{useCallback:d}=o,p=e=>{let{name:t,label:i,children:l,onChange:c,caption:o,className:p}=e,{setValue:u}=(0,n.Gc)(),{field:m}=(0,n.bc)({name:t}),{value:x}=m,h=d(e=>{let{checked:i}=e.target;c&&c(i),u(t,i)},[u,c,t]);return(0,s.jsxs)("div",{className:p,children:[(0,s.jsxs)("div",{className:"mb-8 flex items-center justify-between",children:[(0,s.jsx)(a.Z,{variant:"bodyMd",children:i}),(0,s.jsx)(r.Z,{name:t,checked:x,onChange:h})]}),o&&(0,s.jsx)(a.Z,{variant:"bodyMd",className:" mb-8",color:"secondary",children:o}),x&&(0,s.jsx)(s.Fragment,{children:l})]})};var u=i(85993);let m=()=>{let e=(0,l.N)();return(0,s.jsx)(p,{name:"spoiler",label:e.spoilerTitle,caption:e.spoilerCaption,children:(0,s.jsx)(u.n,{name:"spoilerMessage",label:"",placeholder:e.spoilerPlaceholder})})}},8241:function(e,t,i){"use strict";i.d(t,{N:function(){return l}});var s=i(34930);let l=()=>{let{t:e}=(0,s.Z)("features/topic"),t=e("タイトルを入力"),i=e("質問タイトルを入力"),l=e("今話したいこと、聞いてみたいこと、興味ある話題を投稿しよう"),a=e("コミュニティの使い方や機能について分からないところなど、みんなに聞いてみよう"),r=e("タイトル"),c=e("本文"),o=e("画像"),n=e("シェア"),d=e("トピックを選択"),p=e("投稿する"),u=e("保存する"),m=e("すべて見る"),x=e("ネタバレを含む");return{titlePlaceholder:t,titlePlaceholderForQA:i,descriptionPlaceholder:l,descriptionPlaceholderForQA:a,titleLabel:r,descriptionLabel:c,imageLabel:o,shareLabel:n,topicLabel:d,post:p,save:u,readMore:m,spoilerTitle:x,spoilerCaption:e("本文と写真を他の人が表示するか選択できるようになります"),spoilerPlaceholder:e("何についてのネタバレですか？（20文字以内）"),event:e("イベント")}}},74025:function(e,t,i){"use strict";i.d(t,{P:function(){return h},u:function(){return f}});var s=i(34223),l=i(95551),a=i(80029),r=i(19298),c=i(36918),o=i(34930),n=i(2363),d=i(4954),p=i(72644),u=i(51479),m=i(70517),x=i(28136);let h=(0,d.BX)(`
  fragment TopicCardFragment on PostTopic {
    id
    label
    imageUrl
    postCount
    isPostable(communityId: $communityId)
  }
`),f=(0,n.memo)(function(e){let{data:t}=e,{t:i}=(0,o.Z)("features/topicCategory"),{id:n,label:d,postCount:f,imageUrl:y}=(0,p.vz)(h,t);return(0,s.jsx)(m.r,{href:u.V.topics._topic_id(n).$url(),children:(0,s.jsx)(r.H,{className:"group rounded-none",children:(0,s.jsxs)(c.M,{children:[(0,s.jsx)("div",{className:"flex size-48 shrink-0 items-center justify-center overflow-hidden rounded-md bg-object-neutral",children:y?(0,s.jsx)(x.E,{alt:"group logo",src:y,height:48,width:48}):(0,s.jsx)(a.w,{width:"24px",height:"24px"})}),(0,s.jsxs)("div",{className:"ml-16 truncate",children:[(0,s.jsx)(l.Z,{variant:"bodyLg",className:"truncate group-hover:text-interactive",children:d}),(0,s.jsxs)(l.Z,{component:"span",variant:"bodySm",color:"tertiary",children:[f,i("投稿")]})]})]})})})})},38224:function(e,t,i){"use strict";i.d(t,{q:function(){return d}});var s=i(98376),l=i(2363),a=i(74025),r=i(86415),c=i(4954),o=i(3459);let n=(0,c.BX)(`
    query TopicCategoryQuery(
      $id: ID!
      $after: String
      $before: String
      $first: Int
      $last: Int
      $communityId: String!
      $search: String!
      $topicCategoryId: String!
      $topicFilterGroups: [TopicFilterGroupConditionInput!]
      $topicSort: TopicSortInput
      $userId: String
    ) {
      topicCategory(communityId: $communityId, id: $id) {
        id
        title
        topics(
          after: $after
          before: $before
          first: $first
          last: $last
          communityId: $communityId
          search: $search
          topicCategoryId: $topicCategoryId
          topicFilterGroups: $topicFilterGroups
          topicSort: $topicSort
          userId: $userId
        ) {
          edges {
            node {
              id
              ...TopicCardFragment
            }
          }
          pageInfo {
            hasNextPage
            endCursor
          }
        }
      }
    }
  `,[a.P]),d=e=>{let{categoryId:t,keyword:i,topicFilterGroups:a,topicSort:c}=e,{communityId:d}=(0,o.U)(),p=(0,r.II)(),{data:u,fetchMore:m,loading:x}=(0,s.a)(n,{variables:{id:t,communityId:d,first:30,search:i,topicCategoryId:t,topicFilterGroups:a||null,topicSort:c?{key:c.key,direction:c.direction}:null,after:null,before:null,last:null,userId:p??null},notifyOnNetworkStatusChange:!0}),h=(0,l.useMemo)(()=>u?.topicCategory.topics,[u]),f=(0,l.useMemo)(()=>u?.topicCategory.topics?.pageInfo.hasNextPage??!1,[u]);return{data:u,loading:x,hasMore:f,handleMore:(0,l.useCallback)(()=>{m({variables:{after:h?.pageInfo.endCursor},updateQuery:(e,t)=>{let{fetchMoreResult:i}=t;return i?.topicCategory.topics?{...i,topicCategory:{...i.topicCategory,topics:{pageInfo:i.topicCategory.topics.pageInfo,edges:[...e.topicCategory.topics?.edges??[],...i.topicCategory.topics.edges??[]]}}}:e}})},[h,m])}}},69727:function(e,t,i){"use strict";var s=i(34223),l=i(96030);t.Z=e=>{let{className:t}=e;return(0,s.jsx)("div",{className:(0,l.Z)("h-8 w-full bg-object-neutral",t)})}},85993:function(e,t,i){"use strict";i.d(t,{n:function(){return c}});var s=i(34223),l=i(43147),a=i(2363),r=i(72209);let c=e=>{let{name:t,onBlur:i,onChange:c,...o}=e,{field:n,fieldState:d}=(0,r.bc)({name:t}),{onChange:p,onBlur:u,value:m}=n,{error:x}=d,h=x?.message,f=a.useCallback(e=>{i&&i(e),u()},[u,i]),y=a.useCallback(e=>{c&&c(e),p(e)},[p,c]);return(0,s.jsx)(l.n,{name:t,value:m,error:!!x,errorText:h,onBlur:f,onChange:y,...o})}},87442:function(e,t,i){"use strict";i.d(t,{H:function(){return s}});let s=/https?:\/\/(youtu\.be|www\.youtube\.com|youtube\.com|m\.youtube\.com)/},32478:function(e,t,i){"use strict";i.d(t,{W:function(){return r}});var s=i(34930),l=i(2363),a=i(89376);let r=()=>{let{t:e}=(0,s.Z)("shared"),[t,i]=(0,a.c)();return[t,(0,l.useCallback)(()=>{i({type:"message",title:e("不適切なワードが含まれています"),subText:e("送信内容が利用規約に違反する可能性があります。ルールを守って楽しみましょう。"),actionLabel:"OK"})},[i,e])]}},21076:function(e,t,i){"use strict";i.d(t,{V:function(){return c}});var s=i(1167),l=i(2363),a=i(60413),r=i(31746);let c=()=>{let{asPath:e,query:t}=(0,s.useRouter)();return(0,l.useCallback)((i,s)=>{(0,r.$)(a.V.customAppEvent,{event_name:i,json_params:JSON.stringify(s),...t,fromUrl:e})},[e,t])}},11024:function(e){e.exports={"select-filter-name":"TopicFilterMenu_select-filter-name__ZW9vj","filter-button":"TopicFilterMenu_filter-button__Q1KWA"}},53346:function(e){e.exports={tag:"TopicFormField_tag__Erj52"}},74044:function(e){e.exports={"filter-button":"TopicSortMenu_filter-button__Gn_ej"}}}]);