from pathlib import Path
p=Path('resources/js/vue/src/pages/caller/CallerConsolePage.vue'); s=p.read_text()
s=s.replace('item.callback_time','item.callback_at').replace('item.last_called','item.last_called_at')
s=s.replace("    showCallWorkspace () { return this.session.state.live || this.session.state.callState === 'wrapup' || this.softphonePlacing },\n    showSheet () { return !this.record || this.canAttachDuringLive },\n    workspaceClass () { return this.showCallWorkspace ? (this.record ? 'cc-calling' : 'cc-unlinked') : (this.record ? 'cc-focus' : 'cc-choosing') },",'''    screenState () {
      const call = this.softphonePlacing || this.session.state.live || this.session.state.callState === 'wrapup'
      if (!call) return this.record ? 'selected' : 'choosing'
      if (!this.record) return 'unlinked'
      if (this.session.state.callState === 'wrapup') return 'wrapup'
      return this.dispositionSaved ? 'saved-live' : 'calling'
    },
    showCallWorkspace () { return ['calling', 'saved-live', 'wrapup', 'unlinked'].includes(this.screenState) },
    showSheet () { return this.screenState === 'choosing' || this.screenState === 'unlinked' },
    workspaceClass () {
      return { choosing: 'cc-choosing', selected: 'cc-focus', calling: 'cc-calling', 'saved-live': 'cc-calling', wrapup: 'cc-calling', unlinked: 'cc-unlinked' }[this.screenState]
    },''')
s=s.replace('v-if="session.state.live"\n                type="button"\n                class="cc-phone-control"','v-if="session.state.live && session.state.callState !== \'wrapup\'"\n                type="button"\n                class="cc-phone-control"',1)
s=s.replace('v-if="session.state.live" type="button" :class="{ active: padTab', 'v-if="session.state.live && session.state.callState !== \'wrapup\'" type="button" :class="{ active: padTab',1)
s=s.replace("      if (state !== 'connected') this.stopAgentPayPoll()","      if (state === 'wrapup' && this.padTab === 'keypad') this.padTab = this.record ? 'disposition' : 'output'\n      if (state !== 'connected') this.stopAgentPayPoll()",1)
s=s.replace("    'pledge.paymentMethod' () {\n      this.editingCard = false", "    'pledge.paymentMethod' () {\n      this.editingCard = false\n      if (this.pledge.paymentMethod === 'Credit') this.prepareCardStep()",1)
# Separate history/notes from contact and display together in third column.
a=s.index('          <div\n            v-else-if="tab === \'history\'"'); b=s.index('\n        </template>\n      </section>',a)
block=s[a:b].replace('v-else-if="tab === \'history\'"','v-if="record"',1).replace('            v-else\n            class="cc-tab-pane"','            v-if="record"\n            class="cc-tab-pane"',1)
s=s[:a]+s[b:]
# remove record tabs entirely, contact pane unconditional
start=s.index('          <div v-if="showCallWorkspace" class="cc-tabs">'); end=s.index('          <div\n            v-if="!showCallWorkspace || tab === \'contact\'"',start)
s=s[:start]+s[end:]; s=s.replace('v-if="!showCallWorkspace || tab === \'contact\'"','v-if="record"',1)
idx=s.index('\n    </div>\n\n    <div\n      v-if="audioSetupOpen"')
s=s[:idx]+'''\n      <aside v-if="showCallWorkspace && record" class="cc-panel cc-history-column"><h3>History and notes</h3>'''+block+'''\n      </aside>'''+s[idx:]
p.write_text(s)
